diff --git a/src/parsing/export-details.ts b/src/parsing/export-details.ts index 8680a82a..c1023d13 100644 --- a/src/parsing/export-details.ts +++ b/src/parsing/export-details.ts @@ -18,34 +18,27 @@ import { ExportNamedDeclaration, ExportDefaultDeclaration } from 'estree'; import { ExportDetails, Range, ExportClosureMapping } from '../types'; export function NamedDeclaration(declaration: ExportNamedDeclaration): Array { - const range: Range = declaration.range as Range; + const exportDetails: Array = []; const source: string | null = typeof declaration?.source?.value === 'string' ? declaration.source.value : null; - if (declaration.specifiers) { - const exportDetails: Array = []; - - for (const specifier of declaration.specifiers) { - exportDetails.push({ - local: specifier.local.name, - exported: specifier.exported.name, - closureName: specifier.exported.name, - type: ExportClosureMapping.NAMED_CONSTANT, - range, - source, - }); - } - - return exportDetails; + for (const specifier of declaration.specifiers) { + exportDetails.push({ + local: specifier.local.name, + exported: specifier.exported.name, + closureName: specifier.exported.name, + type: ExportClosureMapping.NAMED_CONSTANT, + range: declaration.range as Range, + source, + }); } - return []; + return exportDetails; } export function DefaultDeclaration( defaultDeclaration: ExportDefaultDeclaration, ): Array { - const range: Range = defaultDeclaration.range as Range; const { declaration } = defaultDeclaration; if (declaration.type === 'Identifier' && declaration.name) { @@ -55,7 +48,7 @@ export function DefaultDeclaration( exported: declaration.name, closureName: declaration.name, type: ExportClosureMapping.NAMED_DEFAULT_FUNCTION, - range, + range: defaultDeclaration.range as Range, source: null, }, ]; diff --git a/src/parsing/literal-name.ts b/src/parsing/literal-name.ts index 7e3333ea..c51babc4 100644 --- a/src/parsing/literal-name.ts +++ b/src/parsing/literal-name.ts @@ -14,19 +14,9 @@ * limitations under the License. */ -import { PluginContext } from 'rollup'; import { Literal, SimpleLiteral } from 'estree'; -export function literalName(context: PluginContext, literal: Literal): string { - // Literal can either be a SimpleLiteral, or RegExpLiteral - if ('regex' in literal) { - // This is a RegExpLiteral - context.warn( - 'Rollup Plugin Closure Compiler found a Regex Literal Named Import. `import foo from "*/.hbs"`', - ); - return ''; - } - +export function literalName(literal: Literal): string { const literalValue = (literal as SimpleLiteral).value; return typeof literalValue === 'string' ? literalValue : ''; } diff --git a/src/transformers/imports.ts b/src/transformers/imports.ts index 4eb0daf5..127dc61b 100644 --- a/src/transformers/imports.ts +++ b/src/transformers/imports.ts @@ -102,7 +102,7 @@ window['${DYNAMIC_IMPORT_REPLACEMENT}'] = ${DYNAMIC_IMPORT_REPLACEMENT};`; walk.simple(program, { async ImportDeclaration(node: ImportDeclaration) { - const name = literalName(self.context, node.source); + const name = literalName(node.source); const range: Range = node.range as Range; let defaultSpecifier: string | null = null;