Skip to content

Commit 4760197

Browse files
committed
fix: import 别名判断问题
1 parent 17eef97 commit 4760197

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/parser/lib/parseJavascript.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ export function parseJavascript(
5353
const importDeclarationMap: {
5454
[key: string]: string
5555
} = {}
56+
const importOriginNameMap: {
57+
[key: string]: string
58+
} = {}
5659
const vueComponentVisitor = {
5760
Decorator(path: NodePath<bt.Decorator>): void {
5861
if (
@@ -549,6 +552,11 @@ export function parseJavascript(
549552
const sourcePath = rootPath.node.source.value
550553
const specifiers = rootPath.node.specifiers
551554
specifiers.map(item => {
555+
if (item.type === 'ImportSpecifier') {
556+
importOriginNameMap[item.local.name] = item.imported ? item.imported.name : item.local.name
557+
} else {
558+
importOriginNameMap[item.local.name] = item.local.name
559+
}
552560
importDeclarationMap[item.local.name] = sourcePath
553561
})
554562
},
@@ -571,7 +579,7 @@ export function parseJavascript(
571579
}
572580
}
573581
if (isHelpCreate) {
574-
_helpCreateName = callee.name
582+
_helpCreateName = importOriginNameMap[callee.name]
575583
}
576584
},
577585
VariableDeclaration(rootPath: NodePath<bt.VariableDeclaration>) {

0 commit comments

Comments
 (0)