feat(48702): Emit for dynamic import (import()) when target >= ES2020 and module == None (#50942)

This commit is contained in:
Oleksandr T
2023-02-07 02:18:06 +02:00
committed by GitHub
parent 76c23e43da
commit cdeb1e3660
8 changed files with 72 additions and 0 deletions

View File

@@ -850,6 +850,9 @@ export function transformModule(context: TransformationContext): (x: SourceFile
}
function visitImportCallExpression(node: ImportCall): Expression {
if (moduleKind === ModuleKind.None && languageVersion >= ScriptTarget.ES2020) {
return visitEachChild(node, visitor, context);
}
const externalModuleName = getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions);
const firstArgument = visitNode(firstOrUndefined(node.arguments), visitor, isExpression);
// Only use the external module name if it differs from the first argument. This allows us to preserve the quote style of the argument on output.