From 24bb45e2b95a246f53e82ecf0ada5269660d3593 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Wed, 5 Jul 2023 15:24:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(cli):=20=E7=94=9F=E6=88=90=E7=9A=84entry?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E9=87=8C=E9=9D=A2=E7=9A=84import=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9B=B8=E5=AF=B9=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cli/src/utils/resolveAppPackages.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/utils/resolveAppPackages.ts b/packages/cli/src/utils/resolveAppPackages.ts index 063240b2..2d9ff38f 100644 --- a/packages/cli/src/utils/resolveAppPackages.ts +++ b/packages/cli/src/utils/resolveAppPackages.ts @@ -29,7 +29,7 @@ export const resolveAppPackages = (app: App): ModuleMainFilePath => { const dependencies: Record = {}; - const setPackages = (cwd: string, packagePath: string, key?: string) => { + const setPackages = (cwd: string, tmp: string, packagePath: string, key?: string) => { const { name: moduleName } = splitNameVersion(packagePath); if (!moduleName) throw Error('packages中包含非法配置'); @@ -42,10 +42,10 @@ export const resolveAppPackages = (app: App): ModuleMainFilePath => { const result = typeAssertion({ ast, indexPath }); const setItem = (key: string, entry: Entry) => { - if (entry.component) componentMap[key] = entry.component; - if (entry.config) configMap[key] = entry.config; - if (entry.event) eventMap[key] = entry.event; - if (entry.value) valueMap[key] = entry.value; + if (entry.component) componentMap[key] = path.relative(tmp, entry.component); + if (entry.config) configMap[key] = path.relative(tmp, entry.config); + if (entry.event) eventMap[key] = path.relative(tmp, entry.event); + if (entry.value) valueMap[key] = path.relative(tmp, entry.value); }; if (result.type === PackageType.COMPONENT && key) { @@ -116,10 +116,10 @@ export const resolveAppPackages = (app: App): ModuleMainFilePath => { packages.forEach((item) => { if (typeof item === 'object') { Object.entries(item).forEach(([key, packagePath]) => { - setPackages(app.options.source, packagePath, key); + setPackages(app.options.source, app.options.temp, packagePath, key); }); } else { - setPackages(app.options.source, item); + setPackages(app.options.source, app.options.temp, item); } });