From 910a176532bf67e25a6d283ea105f4352e03a97e Mon Sep 17 00:00:00 2001 From: Bryan Ollendyke Date: Fri, 19 Apr 2019 16:06:48 -0400 Subject: [PATCH 1/2] #3402 resolveBareSpecifiers must be a Program --- .../build/src/babel-plugin-bare-specifiers.ts | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) 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) { From e53d1c5e372011a514ed3a08cebc15175335bdef Mon Sep 17 00:00:00 2001 From: Bryan Ollendyke Date: Fri, 19 Apr 2019 16:45:21 -0400 Subject: [PATCH 2/2] Program needed type definition --- packages/build/src/babel-plugin-bare-specifiers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/build/src/babel-plugin-bare-specifiers.ts b/packages/build/src/babel-plugin-bare-specifiers.ts index 0be5e2b46..3eae9bc6d 100644 --- a/packages/build/src/babel-plugin-bare-specifiers.ts +++ b/packages/build/src/babel-plugin-bare-specifiers.ts @@ -14,7 +14,7 @@ import dynamicImportSyntax from '@babel/plugin-syntax-dynamic-import'; import {NodePath} from '@babel/traverse'; -import {CallExpression, ExportAllDeclaration, ExportNamedDeclaration, ImportDeclaration} from 'babel-types'; +import {CallExpression, ExportAllDeclaration, ExportNamedDeclaration, ImportDeclaration, Program} from 'babel-types'; import {resolve} from 'polymer-analyzer/lib/javascript/resolve-specifier-node'; const isPathSpecifier = (s: string) => /^\.{0,2}\//.test(s);