Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
phy-lei committed Jan 19, 2024
1 parent 0f04564 commit 128edc5
Show file tree
Hide file tree
Showing 19 changed files with 856 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity



# parcel-bundler cache (https://parceljs.org/)
.cache

dist/
deploy_versions/
.temp/
.rn_temp/
.DS_Store
.swc
.yalc
yalc.lock
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
63 changes: 63 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"name": "tarojs-plugin-solid",
"version": "0.0.1",
"description": "taro插件,支持使用 Solid 开发小程序",
"main": "lib/index.js",
"files": [
"lib"
],
"scripts": {
"build": "rollup -c --bundleConfigAsCjs",
"test": "jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/phy-lei/tarojs-plugin-solid"
},
"keywords": [
"taro",
"taro3",
"tarojs",
"solid",
"solidjs"
],
"author": "phy-lei",
"license": "MIT",
"bugs": {
"url": "https://github.com/phy-lei/tarojs-plugin-solid/issues"
},
"homepage": "https://github.com/phy-lei/tarojs-plugin-solid#readme",
"peerDependencies": {
"@tarojs/runtime": ">=3.0.0",
"@tarojs/service": ">=3.0.0",
"@tarojs/shared": ">=3.0.0",
"@tarojs/webpack5-runner": ">=3.0.0",
"solid-js": ">=1"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"volta": {
"node": "18.17.1",
"npm": "9.6.7"
},
"dependencies": {
"solid-js": "^1.8.11"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@tarojs/runtime": "^3.6.22",
"@tarojs/service": "^3.6.22",
"@tarojs/shared": "^3.6.22",
"@tarojs/webpack5-runner": "^3.6.22",
"@types/jest": "^29.5.11",
"jest": "^29.7.0",
"rollup": "^4.9.5",
"rollup-plugin-node-externals": "^6.1.2",
"rollup-plugin-ts": "^3.4.5",
"ts-jest": "^29.1.1",
"typescript": "^5.3.3"
}
}
38 changes: 38 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import * as path from 'path';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { externals } from 'rollup-plugin-node-externals';
import ts from 'rollup-plugin-ts';

const base = {
plugins: [
commonjs(),
nodeResolve(),
externals({
include: [
'@tarojs/runtime',
'@tarojs/service',
'@tarojs/shared',
'@tarojs/webpack5-runner',
],
}),
ts(),
],
};

// 供 CLI 编译时使用的 Taro 插件入口
const compileConfig = {
input: path.join(__dirname, 'src/index.ts'),
output: {
file: path.join(__dirname, 'dist/index.js'),
format: 'cjs',
sourcemap: true,
exports: 'named',
},
...base,
};

// 供 Loader 使用的运行时入口
const runtimeConfig = {
input: path.join(__dirname, 'src/runtime/index.ts'),
output: {
file: path.join(__dirname, 'dist/runtime.js'),
format: 'es',
sourcemap: true,
},
...base,
};

// Solid Loader
const loaderConfig = {
input: path.join(__dirname, 'src/api-loader.ts'),
output: {
file: path.join(__dirname, 'dist/api-loader.js'),
format: 'cjs',
sourcemap: true,
exports: 'auto',
},
...base,
};

export default [compileConfig, runtimeConfig, loaderConfig];
76 changes: 76 additions & 0 deletions src/api-loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
export default function (str: string) {
return `import {
useAddToFavorites,
useDidHide,
useDidShow,
useError,
useLaunch,
useLoad,
useOptionMenuClick,
usePageNotFound,
usePageScroll,
usePullDownRefresh,
usePullIntercept,
useReachBottom,
useReady,
useResize,
useRouter,
useSaveExitState,
useShareAppMessage,
useShareTimeline,
useTabItemTap,
useTitleClick,
useScope,
useUnload
} from 'tarojs-plugin-solid/dist/runtime'
${str}
taro.useAddToFavorites = useAddToFavorites
taro.useDidHide = useDidHide
taro.useDidShow = useDidShow
taro.useError = useError
taro.useLaunch = useLaunch
taro.useLoad = useLoad
taro.useOptionMenuClick = useOptionMenuClick
taro.usePageNotFound = usePageNotFound
taro.usePageScroll = usePageScroll
taro.usePullDownRefresh = usePullDownRefresh
taro.usePullIntercept = usePullIntercept
taro.useReachBottom = useReachBottom
taro.useReady = useReady
taro.useResize = useResize
taro.useRouter = useRouter
taro.useSaveExitState = useSaveExitState
taro.useShareAppMessage = useShareAppMessage
taro.useShareTimeline = useShareTimeline
taro.useTabItemTap = useTabItemTap
taro.useTitleClick = useTitleClick
taro.useScope = useScope
taro.useUnload = useUnload
export {
useAddToFavorites,
useDidHide,
useDidShow,
useError,
useLaunch,
useLoad,
useOptionMenuClick,
usePageNotFound,
usePageScroll,
usePullDownRefresh,
usePullIntercept,
useReachBottom,
useReady,
useResize,
useRouter,
useSaveExitState,
useShareAppMessage,
useShareTimeline,
useTabItemTap,
useTitleClick,
useScope,
useUnload
}
`
}
Loading

0 comments on commit 128edc5

Please sign in to comment.