Skip to content

Commit

Permalink
Polymer#3402 resolveBareSpecifiers must be a Program
Browse files Browse the repository at this point in the history
  • Loading branch information
btopro authored Apr 19, 2019
1 parent e898dea commit 910a176
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions packages/build/src/babel-plugin-bare-specifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,26 @@ export const resolveBareSpecifiers = (
inherits: dynamicImportSyntax,

visitor: {
CallExpression(path: NodePath<CallExpression>) {
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<Program>) {
path.traverse({
CallExpression(path: NodePath<CallExpression>) {
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<HasSpecifier>) {
Expand Down

0 comments on commit 910a176

Please sign in to comment.