From 0f0d83480ebd8db2946c27da0e6c556ee8497c93 Mon Sep 17 00:00:00 2001 From: luckyadam Date: Tue, 3 Dec 2019 22:30:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(mini-runner):=20=E7=BB=84=E4=BB=B6=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E6=94=AF=E6=8C=81=20import=20as=20=E8=AF=AD=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-mini-runner/src/plugins/MiniPlugin.ts | 5 +++-- packages/taro-mini-runner/src/utils/index.ts | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/taro-mini-runner/src/plugins/MiniPlugin.ts b/packages/taro-mini-runner/src/plugins/MiniPlugin.ts index 623f99235a21..62b1ff2c99db 100644 --- a/packages/taro-mini-runner/src/plugins/MiniPlugin.ts +++ b/packages/taro-mini-runner/src/plugins/MiniPlugin.ts @@ -265,6 +265,7 @@ export default class MiniPlugin { if (isTaroComponent) { return component.path } + const componentName = component.name!.split('|')[1] || component.name const { ast } = transformResult traverse(ast, { ExportNamedDeclaration (astPath) { @@ -274,14 +275,14 @@ export default class MiniPlugin { if (source && source.type === 'StringLiteral') { specifiers.forEach(specifier => { const exported = specifier.exported - if (kebabCase(exported.name) === component.name) { + if (kebabCase(exported.name) === componentName) { componentRealPath = resolveScriptPath(path.resolve(path.dirname(component.path as string), source.value)) } }) } else { specifiers.forEach(specifier => { const exported = specifier.exported - if (kebabCase(exported.name) === component.name) { + if (kebabCase(exported.name) === componentName) { importExportName = exported.name } }) diff --git a/packages/taro-mini-runner/src/utils/index.ts b/packages/taro-mini-runner/src/utils/index.ts index 92027e71c320..a3dae33b0459 100644 --- a/packages/taro-mini-runner/src/utils/index.ts +++ b/packages/taro-mini-runner/src/utils/index.ts @@ -175,7 +175,8 @@ export function buildUsingComponents ( componentPath = component.path } if (component.name) { - usingComponents[component.name] = (componentPath as string).replace(path.extname(componentPath as string), '') + const componentName = component.name.split('|')[0] + usingComponents[componentName] = (componentPath as string).replace(path.extname(componentPath as string), '') } } return Object.assign({}, isComponent ? { component: true } : { usingComponents: {} }, components.length ? {