From 2153cfa9c658678ce41be23fcc060c53bfef76ec Mon Sep 17 00:00:00 2001 From: ajaxzheng <894103554@qq.com> Date: Tue, 4 Mar 2025 11:06:27 +0800 Subject: [PATCH] build(cli): fix the version error of utils and hooks packages in vue2 (#3010) --- internals/cli/src/commands/build/build-ui.ts | 18 +++++++++++++----- .../cli/src/commands/create/commonMapping.json | 5 ----- packages/modules.json | 5 ----- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/internals/cli/src/commands/build/build-ui.ts b/internals/cli/src/commands/build/build-ui.ts index c1e4eac11..ffc22400f 100644 --- a/internals/cli/src/commands/build/build-ui.ts +++ b/internals/cli/src/commands/build/build-ui.ts @@ -135,8 +135,16 @@ export const getBaseConfig = ({ vueVersion, dtsInclude, dts, buildTarget, isRunt // 处理tsconfig中配置,主要是处理paths映射,确保dts可以找到正确的包 const compilerOptions = require(pathFromWorkspaceRoot(`tsconfig.vue${vueVersion}.json`)).compilerOptions let versionTarget = isValidVersion(buildTarget) ? buildTarget : `${ns(vueVersion)}.${buildTarget}` - let themeAndRenderlessVersion = isValidVersion(buildTarget) ? buildTarget : `3.${buildTarget}` - const isThemeOrRenderless = (key) => key.includes('@opentiny/vue-theme') || key.includes('@opentiny/vue-renderless') + let onlyHasV3Version = isValidVersion(buildTarget) ? buildTarget : `3.${buildTarget}` + const isOnlyHasV3 = (key) => { + const onlyHasV3Packages = [ + '@opentiny/vue-theme', + '@opentiny/vue-renderless', + '@opentiny/vue-hooks', + '@opentiny/utils' + ] + return onlyHasV3Packages.includes(key) + } return defineConfig({ publicDir: false, @@ -181,14 +189,14 @@ export const getBaseConfig = ({ vueVersion, dtsInclude, dts, buildTarget, isRunt // 如果没有指定版本号,则按源码版本发布 if (!buildTarget) { - themeAndRenderlessVersion = packageVersion + onlyHasV3Version = packageVersion versionTarget = `${vueVersion}${packageVersion.slice(1)}` } Object.entries(content.dependencies).forEach(([key, value]) => { // dependencies里的@opentiny,统一使用:~x.x.0 - if (isThemeOrRenderless(key)) { - dependencies[key] = getPatchVersion(themeAndRenderlessVersion) + if (isOnlyHasV3(key)) { + dependencies[key] = getPatchVersion(onlyHasV3Version) } else if ((value as string).includes('workspace:~')) { dependencies[key] = getPatchVersion(versionTarget) } else { diff --git a/internals/cli/src/commands/create/commonMapping.json b/internals/cli/src/commands/create/commonMapping.json index abbd7ab13..50c8ce6f9 100644 --- a/internals/cli/src/commands/create/commonMapping.json +++ b/internals/cli/src/commands/create/commonMapping.json @@ -49,11 +49,6 @@ "type": "module", "exclude": false }, - "Hooks": { - "path": "vue-hooks/index.ts", - "type": "module", - "exclude": false - }, "FormItemLabelWrap": { "path": "vue/src/form-item/src/label-wrap.ts", "type": "template", diff --git a/packages/modules.json b/packages/modules.json index 853ee9878..012257d9d 100644 --- a/packages/modules.json +++ b/packages/modules.json @@ -1261,11 +1261,6 @@ "type": "template", "exclude": false }, - "Hooks": { - "path": "vue-hooks/index.ts", - "type": "module", - "exclude": false - }, "Hrapprover": { "path": "vue/src/hrapprover/index.ts", "type": "component",