Revert "[Master] wip-dynamic import" (#16264)

This commit is contained in:
Mohamed Hegazy
2017-06-05 10:49:20 -07:00
committed by GitHub
parent 9d16d34c6a
commit ccc60c8b3b
169 changed files with 103 additions and 5271 deletions

View File

@@ -1366,7 +1366,6 @@ namespace ts {
const isJavaScriptFile = isSourceFileJavaScript(file);
const isExternalModuleFile = isExternalModule(file);
// file.imports may not be undefined if there exists dynamic import
let imports: LiteralExpression[];
let moduleAugmentations: LiteralExpression[];
let ambientModules: string[];
@@ -1386,8 +1385,8 @@ namespace ts {
for (const node of file.statements) {
collectModuleReferences(node, /*inAmbientModule*/ false);
if ((file.flags & NodeFlags.PossiblyContainDynamicImport) || isJavaScriptFile) {
collectDynamicImportOrRequireCalls(node);
if (isJavaScriptFile) {
collectRequireCalls(node);
}
}
@@ -1450,16 +1449,12 @@ namespace ts {
}
}
function collectDynamicImportOrRequireCalls(node: Node): void {
function collectRequireCalls(node: Node): void {
if (isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) {
(imports || (imports = [])).push(<StringLiteral>(<CallExpression>node).arguments[0]);
}
// we have to check the argument list has length of 1. We will still have to process these even though we have parsing error.
else if (isImportCall(node) && node.arguments.length === 1 && node.arguments[0].kind === SyntaxKind.StringLiteral) {
(imports || (imports = [])).push(<StringLiteral>(<CallExpression>node).arguments[0]);
}
else {
forEachChild(node, collectDynamicImportOrRequireCalls);
forEachChild(node, collectRequireCalls);
}
}
}