From 901fe4dd9485e369bdd16126d7a22c5cd5b2066a Mon Sep 17 00:00:00 2001 From: roymondchen Date: Tue, 14 May 2024 14:25:47 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=AE=8C=E5=96=84=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- packages/core/package.json | 8 +++++--- packages/core/vite.config.ts | 5 ++++- packages/data-source/package.json | 6 ++++-- packages/data-source/vite.config.ts | 5 ++++- packages/dep/package.json | 2 +- packages/dep/vite.config.ts | 2 +- packages/design/package.json | 3 --- packages/design/vite.config.ts | 2 +- packages/editor/package.json | 14 +++++--------- packages/editor/vite.config.ts | 5 ++++- packages/element-plus-adapter/package.json | 4 ---- packages/element-plus-adapter/vite.config.ts | 2 +- packages/form/package.json | 7 +++---- packages/form/vite.config.ts | 10 ++++------ packages/stage/package.json | 8 +++++--- packages/stage/vite.config.ts | 9 ++++----- packages/table/package.json | 8 +++----- packages/table/vite.config.ts | 10 ++++------ packages/tdesign-vue-next-adapter/package.json | 5 ----- packages/tdesign-vue-next-adapter/vite.config.ts | 2 +- packages/utils/package.json | 3 +-- packages/utils/vite.config.ts | 7 ++++--- 23 files changed, 60 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index 64e9c36c..33884ff6 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ https://tencent.github.io/tmagic-editor/playground/index.html node.js >= 18 -pnpm >= 8 +pnpm >= 9 先安装 pnpm diff --git a/packages/core/package.json b/packages/core/package.json index 7dfbe817..ef9e83b0 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -38,12 +38,14 @@ "vue" ], "dependencies": { - "@tmagic/data-source": "workspace:*", - "@tmagic/schema": "workspace:*", - "@tmagic/utils": "workspace:*", "events": "^3.3.0", "lodash-es": "^4.17.21" }, + "peerDependencies": { + "@tmagic/data-source": "workspace:*", + "@tmagic/schema": "workspace:*", + "@tmagic/utils": "workspace:*" + }, "devDependencies": { "@types/events": "^3.0.0", "@types/lodash-es": "^4.17.4", diff --git a/packages/core/vite.config.ts b/packages/core/vite.config.ts index 931818fa..99bb4f0f 100644 --- a/packages/core/vite.config.ts +++ b/packages/core/vite.config.ts @@ -48,7 +48,10 @@ export default defineConfig({ rollupOptions: { // 确保外部化处理那些你不想打包进库的依赖 external(id: string) { - return Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id)); + return Object.keys({ + ...pkg.dependencies, + ...pkg.peerDependencies, + }).some((k) => new RegExp(`^${k}`).test(id)); }, }, }, diff --git a/packages/data-source/package.json b/packages/data-source/package.json index 8536c086..e99a40fc 100644 --- a/packages/data-source/package.json +++ b/packages/data-source/package.json @@ -35,12 +35,14 @@ ], "dependencies": { "@tmagic/dep": "workspace:*", - "@tmagic/schema": "workspace:*", - "@tmagic/utils": "workspace:*", "deep-state-observer": "^5.5.13", "events": "^3.3.0", "lodash-es": "^4.17.21" }, + "peerDependencies": { + "@tmagic/schema": "workspace:*", + "@tmagic/utils": "workspace:*" + }, "devDependencies": { "@types/events": "^3.0.0", "@types/lodash-es": "^4.17.4", diff --git a/packages/data-source/vite.config.ts b/packages/data-source/vite.config.ts index 7faf4e6f..10a8fee8 100644 --- a/packages/data-source/vite.config.ts +++ b/packages/data-source/vite.config.ts @@ -52,7 +52,10 @@ export default defineConfig(({ mode }) => ({ if (mode === 'umd' && id === 'lodash-es') { return false; } - return Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id)); + return Object.keys({ + ...pkg.dependencies, + ...pkg.peerDependencies, + }).some((k) => new RegExp(`^${k}`).test(id)); }, }, }, diff --git a/packages/dep/package.json b/packages/dep/package.json index 654b34a0..1b316ed8 100644 --- a/packages/dep/package.json +++ b/packages/dep/package.json @@ -30,7 +30,7 @@ "type": "git", "url": "https://github.com/Tencent/tmagic-editor.git" }, - "dependencies": { + "peerDependencies": { "@tmagic/schema": "workspace:*", "@tmagic/utils": "workspace:*" }, diff --git a/packages/dep/vite.config.ts b/packages/dep/vite.config.ts index 5ff7d3da..84e6464d 100644 --- a/packages/dep/vite.config.ts +++ b/packages/dep/vite.config.ts @@ -44,7 +44,7 @@ export default defineConfig({ rollupOptions: { // 确保外部化处理那些你不想打包进库的依赖 external(id: string) { - return Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id)); + return Object.keys(pkg.peerDependencies).some((k) => new RegExp(`^${k}`).test(id)); }, }, }, diff --git a/packages/design/package.json b/packages/design/package.json index eec2054b..a2fa01e4 100644 --- a/packages/design/package.json +++ b/packages/design/package.json @@ -37,9 +37,6 @@ "vue3", "typescript" ], - "dependencies": { - "vue": "^3.4.27" - }, "peerDependencies": { "vue": "^3.4.27" }, diff --git a/packages/design/vite.config.ts b/packages/design/vite.config.ts index 12a86a1e..f67b608e 100644 --- a/packages/design/vite.config.ts +++ b/packages/design/vite.config.ts @@ -47,7 +47,7 @@ export default defineConfig({ rollupOptions: { // 确保外部化处理那些你不想打包进库的依赖 external(id: string) { - return Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id)); + return Object.keys(pkg.peerDependencies).some((k) => new RegExp(`^${k}`).test(id)); }, output: { diff --git a/packages/editor/package.json b/packages/editor/package.json index ec5875cd..cc546da6 100644 --- a/packages/editor/package.json +++ b/packages/editor/package.json @@ -47,14 +47,8 @@ ], "dependencies": { "@element-plus/icons-vue": "^2.3.1", - "@tmagic/core": "workspace:*", "@tmagic/dep": "workspace:*", - "@tmagic/design": "workspace:*", - "@tmagic/form": "workspace:*", - "@tmagic/schema": "workspace:*", - "@tmagic/stage": "workspace:*", "@tmagic/table": "workspace:*", - "@tmagic/utils": "workspace:*", "buffer": "^6.0.3", "color": "^3.1.3", "emmet-monaco-es": "^5.3.0", @@ -62,14 +56,16 @@ "gesto": "^1.19.1", "keycon": "^1.4.0", "lodash-es": "^4.17.21", - "monaco-editor": "^0.48.0", "moveable": "^0.53.0", - "serialize-javascript": "^6.0.0", - "vue": "^3.4.27" + "serialize-javascript": "^6.0.0" }, "peerDependencies": { + "@tmagic/core": "workspace:*", "@tmagic/design": "workspace:*", "@tmagic/form": "workspace:*", + "@tmagic/schema": "workspace:*", + "@tmagic/stage": "workspace:*", + "@tmagic/utils": "workspace:*", "monaco-editor": "^0.48.0", "vue": "^3.4.27" }, diff --git a/packages/editor/vite.config.ts b/packages/editor/vite.config.ts index 51e64093..356da394 100644 --- a/packages/editor/vite.config.ts +++ b/packages/editor/vite.config.ts @@ -63,7 +63,10 @@ export default defineConfig({ rollupOptions: { // 确保外部化处理那些你不想打包进库的依赖 external(id: string) { - return Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id)); + return Object.keys({ + ...pkg.dependencies, + ...pkg.peerDependencies, + }).some((k) => new RegExp(`^${k}`).test(id)); }, output: { diff --git a/packages/element-plus-adapter/package.json b/packages/element-plus-adapter/package.json index b6c6b71c..76ccfe52 100644 --- a/packages/element-plus-adapter/package.json +++ b/packages/element-plus-adapter/package.json @@ -37,10 +37,6 @@ "vue3", "typescript" ], - "dependencies": { - "@tmagic/design": "workspace:*", - "element-plus": "^2.6.1" - }, "peerDependencies": { "@tmagic/design": "workspace:*", "element-plus": "^2.6.1" diff --git a/packages/element-plus-adapter/vite.config.ts b/packages/element-plus-adapter/vite.config.ts index aaad38c9..b9dc5fbe 100644 --- a/packages/element-plus-adapter/vite.config.ts +++ b/packages/element-plus-adapter/vite.config.ts @@ -35,7 +35,7 @@ export default defineConfig({ rollupOptions: { // 确保外部化处理那些你不想打包进库的依赖 external(id: string) { - return Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id)); + return Object.keys(pkg.peerDependencies).some((k) => new RegExp(`^${k}`).test(id)); }, }, }, diff --git a/packages/form/package.json b/packages/form/package.json index 0748b177..a8b35b84 100644 --- a/packages/form/package.json +++ b/packages/form/package.json @@ -38,13 +38,12 @@ }, "dependencies": { "@element-plus/icons-vue": "^2.3.1", - "@tmagic/design": "workspace:*", - "@tmagic/utils": "workspace:*", "lodash-es": "^4.17.21", - "sortablejs": "^1.15.2", - "vue": "^3.4.27" + "sortablejs": "^1.15.2" }, "peerDependencies": { + "@tmagic/design": "workspace:*", + "@tmagic/utils": "workspace:*", "vue": "^3.4.27" }, "devDependencies": { diff --git a/packages/form/vite.config.ts b/packages/form/vite.config.ts index ce356894..ae87674b 100644 --- a/packages/form/vite.config.ts +++ b/packages/form/vite.config.ts @@ -51,12 +51,10 @@ export default defineConfig({ rollupOptions: { // 确保外部化处理那些你不想打包进库的依赖 external(id: string) { - return ( - /^vue/.test(id) || - /^element-plus/.test(id) || - /^@tmagic\//.test(id) || - Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id)) - ); + return Object.keys({ + ...pkg.dependencies, + ...pkg.peerDependencies, + }).some((k) => new RegExp(`^${k}`).test(id)); }, output: { diff --git a/packages/stage/package.json b/packages/stage/package.json index d74a8f9f..3f708007 100644 --- a/packages/stage/package.json +++ b/packages/stage/package.json @@ -32,15 +32,17 @@ }, "dependencies": { "@scena/guides": "^0.29.2", - "@tmagic/core": "workspace:*", - "@tmagic/schema": "workspace:*", - "@tmagic/utils": "workspace:*", "events": "^3.3.0", "keycon": "^1.4.0", "lodash-es": "^4.17.21", "moveable": "^0.53.0", "moveable-helper": "^0.4.0" }, + "peerDependencies": { + "@tmagic/core": "workspace:*", + "@tmagic/schema": "workspace:*", + "@tmagic/utils": "workspace:*" + }, "devDependencies": { "@types/events": "^3.0.0", "@types/lodash-es": "^4.17.4", diff --git a/packages/stage/vite.config.ts b/packages/stage/vite.config.ts index 73a1465a..545f2e8a 100644 --- a/packages/stage/vite.config.ts +++ b/packages/stage/vite.config.ts @@ -49,11 +49,10 @@ export default defineConfig({ rollupOptions: { // 确保外部化处理那些你不想打包进库的依赖 external(id: string) { - return ( - /^vue/.test(id) || - /^@tmagic\//.test(id) || - Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id)) - ); + return Object.keys({ + ...pkg.dependencies, + ...pkg.peerDependencies, + }).some((k) => new RegExp(`^${k}`).test(id)); }, }, }, diff --git a/packages/table/package.json b/packages/table/package.json index c5059c8b..6fcbf2e7 100644 --- a/packages/table/package.json +++ b/packages/table/package.json @@ -35,14 +35,12 @@ "url": "https://github.com/Tencent/tmagic-editor.git" }, "dependencies": { + "lodash-es": "^4.17.21" + }, + "peerDependencies": { "@tmagic/design": "workspace:*", "@tmagic/form": "workspace:*", "@tmagic/utils": "workspace:*", - "lodash-es": "^4.17.21", - "vue": "^3.4.27" - }, - "peerDependencies": { - "@tmagic/form": "workspace:*", "vue": "^3.4.27" }, "devDependencies": { diff --git a/packages/table/vite.config.ts b/packages/table/vite.config.ts index e42b6410..7e2e1feb 100644 --- a/packages/table/vite.config.ts +++ b/packages/table/vite.config.ts @@ -51,12 +51,10 @@ export default defineConfig({ rollupOptions: { // 确保外部化处理那些你不想打包进库的依赖 external(id: string) { - return ( - /^vue/.test(id) || - /^element-plus/.test(id) || - /^@tmagic\//.test(id) || - Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id)) - ); + return Object.keys({ + ...pkg.dependencies, + ...pkg.peerDependencies, + }).some((k) => new RegExp(`^${k}`).test(id)); }, output: { diff --git a/packages/tdesign-vue-next-adapter/package.json b/packages/tdesign-vue-next-adapter/package.json index 64280605..2a3eeef7 100644 --- a/packages/tdesign-vue-next-adapter/package.json +++ b/packages/tdesign-vue-next-adapter/package.json @@ -37,11 +37,6 @@ "vue3", "typescript" ], - "dependencies": { - "@tmagic/design": "workspace:*", - "tdesign-vue-next": "^1.8.1", - "vue": "^3.4.27" - }, "peerDependencies": { "@tmagic/design": "workspace:*", "tdesign-vue-next": "^1.8.1", diff --git a/packages/tdesign-vue-next-adapter/vite.config.ts b/packages/tdesign-vue-next-adapter/vite.config.ts index b210ccf1..a4817bc2 100644 --- a/packages/tdesign-vue-next-adapter/vite.config.ts +++ b/packages/tdesign-vue-next-adapter/vite.config.ts @@ -38,7 +38,7 @@ export default defineConfig({ rollupOptions: { // 确保外部化处理那些你不想打包进库的依赖 external(id: string) { - return Object.keys(pkg.dependencies).some((k) => new RegExp(`^${k}`).test(id)); + return Object.keys(pkg.peerDependencies).some((k) => new RegExp(`^${k}`).test(id)); }, }, }, diff --git a/packages/utils/package.json b/packages/utils/package.json index cfaf3e88..60e56c33 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -31,12 +31,11 @@ "url": "https://github.com/Tencent/tmagic-editor.git" }, "dependencies": { - "@tmagic/schema": "workspace:*", "dayjs": "^1.11.11", "lodash-es": "^4.17.21" }, "peerDependencies": { - "dayjs": "^1.11.11" + "@tmagic/schema": "workspace:*" }, "devDependencies": { "@types/lodash-es": "^4.17.4", diff --git a/packages/utils/vite.config.ts b/packages/utils/vite.config.ts index 32d4a571..3d5a4b35 100644 --- a/packages/utils/vite.config.ts +++ b/packages/utils/vite.config.ts @@ -20,8 +20,6 @@ import { defineConfig, type LibraryFormats } from 'vite'; import pkg from './package.json'; -const deps = Object.keys(pkg.dependencies); - export default defineConfig(({ mode }) => ({ build: { cssCodeSplit: false, @@ -43,7 +41,10 @@ export default defineConfig(({ mode }) => ({ if (mode === 'umd' && id === 'lodash-es') { return false; } - return deps.some((k) => new RegExp(`^${k}`).test(id)); + return Object.keys({ + ...pkg.dependencies, + ...pkg.peerDependencies, + }).some((k) => new RegExp(`^${k}`).test(id)); }, }, },