From 065b41672014e1537b5d9ad83f840e7b6376564f Mon Sep 17 00:00:00 2001 From: phy-lei <765373325@qq.com> Date: Sat, 20 Jan 2024 16:37:35 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=E4=B8=BAmonorepo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 36 ++-------- packages/tarojs-plugin-solid/LICENSE | 21 ++++++ packages/tarojs-plugin-solid/README.md | 2 + .../tarojs-plugin-solid}/api-loader.ts | 0 .../tarojs-plugin-solid}/index.ts | 0 .../tarojs-plugin-solid}/loader-meta.ts | 0 packages/tarojs-plugin-solid/package.json | 66 +++++++++++++++++++ .../tarojs-plugin-solid}/runtime/connect.ts | 2 +- .../tarojs-plugin-solid}/runtime/dom.ts | 0 .../tarojs-plugin-solid}/runtime/index.ts | 0 .../tarojs-plugin-solid}/webpack.h5.ts | 0 .../tarojs-plugin-solid}/webpack.mini.ts | 0 packages/tarojs-solid-custom-render/LICENSE | 21 ++++++ packages/tarojs-solid-custom-render/README.md | 2 + .../tarojs-solid-custom-render}/index.ts | 6 +- .../tarojs-solid-custom-render/jest.config.js | 0 .../tarojs-solid-custom-render/package.json | 61 +++++++++++++++++ .../rollup.config.js | 33 ++++++++++ .../tarojs-solid-custom-render/src}/h.ts | 0 .../tarojs-solid-custom-render/src}/render.ts | 0 .../tarojs-solid-custom-render/src}/utils.ts | 0 pnpm-workspace.yaml | 2 + rollup.config.js | 58 ---------------- todo | 1 - tsconfig.json | 4 +- 25 files changed, 219 insertions(+), 96 deletions(-) create mode 100644 packages/tarojs-plugin-solid/LICENSE create mode 100644 packages/tarojs-plugin-solid/README.md rename {src => packages/tarojs-plugin-solid}/api-loader.ts (100%) rename {src => packages/tarojs-plugin-solid}/index.ts (100%) rename {src => packages/tarojs-plugin-solid}/loader-meta.ts (100%) create mode 100644 packages/tarojs-plugin-solid/package.json rename {src => packages/tarojs-plugin-solid}/runtime/connect.ts (97%) rename {src => packages/tarojs-plugin-solid}/runtime/dom.ts (100%) rename {src => packages/tarojs-plugin-solid}/runtime/index.ts (100%) rename {src => packages/tarojs-plugin-solid}/webpack.h5.ts (100%) rename {src => packages/tarojs-plugin-solid}/webpack.mini.ts (100%) create mode 100644 packages/tarojs-solid-custom-render/LICENSE create mode 100644 packages/tarojs-solid-custom-render/README.md rename {src/custom-render => packages/tarojs-solid-custom-render}/index.ts (61%) rename jest.config.js => packages/tarojs-solid-custom-render/jest.config.js (100%) create mode 100644 packages/tarojs-solid-custom-render/package.json create mode 100644 packages/tarojs-solid-custom-render/rollup.config.js rename {src/custom-render => packages/tarojs-solid-custom-render/src}/h.ts (100%) rename {src/custom-render => packages/tarojs-solid-custom-render/src}/render.ts (100%) rename {src/custom-render => packages/tarojs-solid-custom-render/src}/utils.ts (100%) create mode 100644 pnpm-workspace.yaml delete mode 100644 rollup.config.js delete mode 100644 todo diff --git a/package.json b/package.json index e1eaefe..f4be367 100644 --- a/package.json +++ b/package.json @@ -3,14 +3,13 @@ "version": "0.0.1", "description": "taro插件,支持使用 Solid 开发小程序", "main": "dist/index.js", - "type": "module", - "files": [ - "dist" + "workspaces": [ + "packages/*" ], + "type": "module", "scripts": { - "dev": "rollup -c -w --bundleConfigAsCjs", - "build": "rollup -c --bundleConfigAsCjs", - "test": "jest" + "dev-all": "pnpm run dev --parallel --filter ./packages/", + "build-all": "pnpm run dev --parallel --filter ./packages/", }, "repository": { "type": "git", @@ -29,13 +28,6 @@ "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" @@ -43,23 +35,5 @@ "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.23", - "@tarojs/service": "^3.6.23", - "@tarojs/shared": "^3.6.23", - "@tarojs/webpack5-runner": "^3.6.23", - "@types/jest": "^29.5.11", - "jest": "^29.7.0", - "rollup": "^4.9.5", - "rollup-plugin-node-externals": "^4.0.0", - "rollup-plugin-ts": "^3.4.5", - "ts-jest": "^29.1.1", - "typescript": "^5.3.3" } } diff --git a/packages/tarojs-plugin-solid/LICENSE b/packages/tarojs-plugin-solid/LICENSE new file mode 100644 index 0000000..809022e --- /dev/null +++ b/packages/tarojs-plugin-solid/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 phy-lei + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/tarojs-plugin-solid/README.md b/packages/tarojs-plugin-solid/README.md new file mode 100644 index 0000000..2c585c7 --- /dev/null +++ b/packages/tarojs-plugin-solid/README.md @@ -0,0 +1,2 @@ +# tarojs-plugin-solid +使用solidjs开发小程序🤖 diff --git a/src/api-loader.ts b/packages/tarojs-plugin-solid/api-loader.ts similarity index 100% rename from src/api-loader.ts rename to packages/tarojs-plugin-solid/api-loader.ts diff --git a/src/index.ts b/packages/tarojs-plugin-solid/index.ts similarity index 100% rename from src/index.ts rename to packages/tarojs-plugin-solid/index.ts diff --git a/src/loader-meta.ts b/packages/tarojs-plugin-solid/loader-meta.ts similarity index 100% rename from src/loader-meta.ts rename to packages/tarojs-plugin-solid/loader-meta.ts diff --git a/packages/tarojs-plugin-solid/package.json b/packages/tarojs-plugin-solid/package.json new file mode 100644 index 0000000..e5500b1 --- /dev/null +++ b/packages/tarojs-plugin-solid/package.json @@ -0,0 +1,66 @@ +{ + "name": "tarojs-plugin-solid", + "version": "0.0.1", + "description": "taro插件,支持使用 Solid 开发小程序", + "main": "dist/index.js", + "workspaces": [ + "packages/*" + ], + "type": "module", + "files": [ + "dist" + ], + "scripts": { + "dev": "rollup -c -w --bundleConfigAsCjs", + "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/shared": ">=3.0.0", + "solid-js": ">=1", + "tarojs-solid-custom-render": "*" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org/", + "access": "public" + }, + "volta": { + "node": "18.17.1", + "npm": "9.6.7" + }, + "dependencies": { + "solid-js": "^1.8.11", + "tarojs-solid-custom-render": "workspace:*" + }, + "devDependencies": { + "@rollup/plugin-commonjs": "^25.0.7", + "@rollup/plugin-node-resolve": "^15.2.3", + "@tarojs/runtime": "^3.6.23", + "@tarojs/shared": "^3.6.23", + "@types/jest": "^29.5.11", + "jest": "^29.7.0", + "rollup": "^4.9.5", + "rollup-plugin-node-externals": "^4.0.0", + "rollup-plugin-ts": "^3.4.5", + "ts-jest": "^29.1.1", + "typescript": "^5.3.3" + } +} diff --git a/src/runtime/connect.ts b/packages/tarojs-plugin-solid/runtime/connect.ts similarity index 97% rename from src/runtime/connect.ts rename to packages/tarojs-plugin-solid/runtime/connect.ts index 611a6c5..d54d814 100644 --- a/src/runtime/connect.ts +++ b/packages/tarojs-plugin-solid/runtime/connect.ts @@ -8,7 +8,7 @@ import { } from "@tarojs/runtime"; import { For } from "solid-js"; import { installGlobalShims } from './dom' -import { createComponent, render, h } from "../custom-render"; +import { createComponent, render, h } from "tarojs-solid-custom-render" import { hooks } from '@tarojs/shared' diff --git a/src/runtime/dom.ts b/packages/tarojs-plugin-solid/runtime/dom.ts similarity index 100% rename from src/runtime/dom.ts rename to packages/tarojs-plugin-solid/runtime/dom.ts diff --git a/src/runtime/index.ts b/packages/tarojs-plugin-solid/runtime/index.ts similarity index 100% rename from src/runtime/index.ts rename to packages/tarojs-plugin-solid/runtime/index.ts diff --git a/src/webpack.h5.ts b/packages/tarojs-plugin-solid/webpack.h5.ts similarity index 100% rename from src/webpack.h5.ts rename to packages/tarojs-plugin-solid/webpack.h5.ts diff --git a/src/webpack.mini.ts b/packages/tarojs-plugin-solid/webpack.mini.ts similarity index 100% rename from src/webpack.mini.ts rename to packages/tarojs-plugin-solid/webpack.mini.ts diff --git a/packages/tarojs-solid-custom-render/LICENSE b/packages/tarojs-solid-custom-render/LICENSE new file mode 100644 index 0000000..809022e --- /dev/null +++ b/packages/tarojs-solid-custom-render/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 phy-lei + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/tarojs-solid-custom-render/README.md b/packages/tarojs-solid-custom-render/README.md new file mode 100644 index 0000000..2c585c7 --- /dev/null +++ b/packages/tarojs-solid-custom-render/README.md @@ -0,0 +1,2 @@ +# tarojs-plugin-solid +使用solidjs开发小程序🤖 diff --git a/src/custom-render/index.ts b/packages/tarojs-solid-custom-render/index.ts similarity index 61% rename from src/custom-render/index.ts rename to packages/tarojs-solid-custom-render/index.ts index 2e0d93d..3c660ad 100644 --- a/src/custom-render/index.ts +++ b/packages/tarojs-solid-custom-render/index.ts @@ -1,5 +1,5 @@ -export * from './render' -export * from './h' +export * from './src/render' +export * from './src/h' -// todo 将其打包成一个lib 外部使用该render进行调用 +// todo 将其打包成一个lib 外部使用该render进行调用 // 需要改为monorepo了 \ No newline at end of file diff --git a/jest.config.js b/packages/tarojs-solid-custom-render/jest.config.js similarity index 100% rename from jest.config.js rename to packages/tarojs-solid-custom-render/jest.config.js diff --git a/packages/tarojs-solid-custom-render/package.json b/packages/tarojs-solid-custom-render/package.json new file mode 100644 index 0000000..7f8721d --- /dev/null +++ b/packages/tarojs-solid-custom-render/package.json @@ -0,0 +1,61 @@ +{ + "name": "tarojs-solid-custom-render", + "version": "0.0.1", + "description": "自定义solid编译器", + "main": "dist/index.js", + "files": [ + "dist" + ], + "scripts": { + "dev": "rollup -c -w --bundleConfigAsCjs", + "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/shared": ">=3.0.0", + "solid-js": ">=1", + "babel-preset-solid": ">=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.23", + "@tarojs/shared": "^3.6.23", + "@types/jest": "^29.5.11", + "jest": "^29.7.0", + "rollup": "^4.9.5", + "rollup-plugin-node-externals": "^4.0.0", + "rollup-plugin-ts": "^3.4.5", + "ts-jest": "^29.1.1", + "typescript": "^5.3.3" + } +} diff --git a/packages/tarojs-solid-custom-render/rollup.config.js b/packages/tarojs-solid-custom-render/rollup.config.js new file mode 100644 index 0000000..3cc65da --- /dev/null +++ b/packages/tarojs-solid-custom-render/rollup.config.js @@ -0,0 +1,33 @@ +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/shared', + ], + }), + ts(), + ], +}; + +// Solid custom render +const customRenderConfig = { + input: path.join(__dirname, 'src/custom-render/index.ts'), + output: { + file: path.join(__dirname, 'dist/custom-render.js'), + format: 'cjs', + sourcemap: true, + exports: 'named', + }, + ...base, +}; + +export default [customRenderConfig]; diff --git a/src/custom-render/h.ts b/packages/tarojs-solid-custom-render/src/h.ts similarity index 100% rename from src/custom-render/h.ts rename to packages/tarojs-solid-custom-render/src/h.ts diff --git a/src/custom-render/render.ts b/packages/tarojs-solid-custom-render/src/render.ts similarity index 100% rename from src/custom-render/render.ts rename to packages/tarojs-solid-custom-render/src/render.ts diff --git a/src/custom-render/utils.ts b/packages/tarojs-solid-custom-render/src/utils.ts similarity index 100% rename from src/custom-render/utils.ts rename to packages/tarojs-solid-custom-render/src/utils.ts diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..600b4bb --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - 'packages/**' diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index d503a73..0000000 --- a/rollup.config.js +++ /dev/null @@ -1,58 +0,0 @@ -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]; diff --git a/todo b/todo deleted file mode 100644 index e8e5444..0000000 --- a/todo +++ /dev/null @@ -1 +0,0 @@ -babel-preset-solid npm \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 2258f3f..fce4e0d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,6 @@ { "compilerOptions": { "baseUrl": ".", - "outDir": "lib", "module": "CommonJS", "sourceMap": true, "allowSyntheticDefaultImports": true, @@ -16,5 +15,6 @@ "target": "ES6", "lib": ["DOM"] }, - "include": ["src"] + "include": ["packages/*"], + "exclude": ["node_modules"] }