From 1636fbc966a425fafd860d36add46ec946df6fa2 Mon Sep 17 00:00:00 2001 From: Yui T Date: Wed, 14 Jun 2017 17:13:35 -0700 Subject: [PATCH] Wip-fix incremental parsing --- src/compiler/parser.ts | 2 +- src/compiler/program.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index ac517575266..491e7b6a9c8 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3700,7 +3700,7 @@ namespace ts { // 3)we have a MemberExpression which either completes the LeftHandSideExpression, // or starts the beginning of the first four CallExpression productions. let expression: MemberExpression; - if (token() === SyntaxKind.ImportKeyword) { + if (token() === SyntaxKind.ImportKeyword && lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look a head to find "(" // For example: // var foo3 = require("subfolder diff --git a/src/compiler/program.ts b/src/compiler/program.ts index cc6ae1a5813..dd29588593a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -802,6 +802,10 @@ namespace ts { // moduleAugmentations has changed oldProgram.structureIsReused = StructureIsReused.SafeModules; } + if ((oldSourceFile.flags & NodeFlags.PossiblyContainsDynamicImport) !== (newSourceFile.flags & NodeFlags.PossiblyContainsDynamicImport)) { + // dynamicImport has changed + oldProgram.structureIsReused = StructureIsReused.Not; + } if (!arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { // 'types' references has changed