diff --git a/packages/build/src/babel-plugin-bare-specifiers.ts b/packages/build/src/babel-plugin-bare-specifiers.ts index c7b3e0cd1..0be5e2b46 100644 --- a/packages/build/src/babel-plugin-bare-specifiers.ts +++ b/packages/build/src/babel-plugin-bare-specifiers.ts @@ -35,23 +35,26 @@ export const resolveBareSpecifiers = ( inherits: dynamicImportSyntax, visitor: { - CallExpression(path: NodePath) { - const node = path.node; - if (node.callee.type as string === 'Import') { - const specifierArg = node.arguments[0]; - if (specifierArg.type !== 'StringLiteral') { - // Should never happen - return; + Program(path: NodePath) { + path.traverse({ + CallExpression(path: NodePath) { + if (path.node.callee.type as string === 'Import') { + const specifierArg = path.node.arguments[0]; + if (specifierArg.type !== 'StringLiteral') { + // Should never happen + return; + } + const specifier = specifierArg.value; + specifierArg.value = maybeResolve( + specifier, + filePath, + isComponentRequest, + packageName, + componentDir, + rootDir); + } } - const specifier = specifierArg.value; - specifierArg.value = maybeResolve( - specifier, - filePath, - isComponentRequest, - packageName, - componentDir, - rootDir); - } + }); }, 'ImportDeclaration|ExportNamedDeclaration|ExportAllDeclaration'( path: NodePath) {