Skip to content

Commit 409e076

Browse files
authored
Merge pull request #30232 from Microsoft/incrementalWithNormalTsc
Use .tsbuildinfo to build with tsc and tsc --w when not using build mode
2 parents 97fbc87 + f8ec54c commit 409e076

File tree

13 files changed

+5176
-4765
lines changed

13 files changed

+5176
-4765
lines changed

lib/tsc.js

Lines changed: 628 additions & 538 deletions
Large diffs are not rendered by default.

lib/tsserver.js

Lines changed: 792 additions & 831 deletions
Large diffs are not rendered by default.

lib/tsserverlibrary.js

Lines changed: 792 additions & 831 deletions
Large diffs are not rendered by default.

lib/typescript.js

Lines changed: 792 additions & 831 deletions
Large diffs are not rendered by default.

lib/typescriptServices.js

Lines changed: 792 additions & 831 deletions
Large diffs are not rendered by default.

lib/typingsInstaller.js

Lines changed: 789 additions & 828 deletions
Large diffs are not rendered by default.

src/compiler/tsbuild.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -451,15 +451,7 @@ namespace ts {
451451
let readFileWithCache = (f: string) => host.readFile(f);
452452
let projectCompilerOptions = baseCompilerOptions;
453453
const compilerHost = createCompilerHostFromProgramHost(host, () => projectCompilerOptions);
454-
const originalGetSourceFile = compilerHost.getSourceFile;
455-
const computeHash = host.createHash || generateDjb2Hash;
456-
compilerHost.getSourceFile = (...args) => {
457-
const result = originalGetSourceFile.call(compilerHost, ...args);
458-
if (result) {
459-
result.version = computeHash.call(host, result.text);
460-
}
461-
return result;
462-
};
454+
setGetSourceFileAsHashVersioned(compilerHost, host);
463455

464456
const buildInfoChecked = createFileMap<true>(toPath);
465457

@@ -1241,13 +1233,7 @@ namespace ts {
12411233
function getOldProgram(proj: ResolvedConfigFileName, parsed: ParsedCommandLine) {
12421234
const value = builderPrograms.getValue(proj);
12431235
if (value) return value;
1244-
const buildInfoPath = getOutputPathForBuildInfo(parsed.options);
1245-
if (!buildInfoPath) return undefined;
1246-
const content = readFileWithCache(buildInfoPath);
1247-
if (!content) return undefined;
1248-
const buildInfo = getBuildInfo(content);
1249-
if (buildInfo.version !== version) return undefined;
1250-
return buildInfo.program && createBuildProgramUsingProgramBuildInfo(buildInfo.program) as any as T;
1236+
return readBuilderProgram(parsed.options, readFileWithCache) as any as T;
12511237
}
12521238

12531239
function updateBundle(proj: ResolvedConfigFileName): BuildResultFlags {

src/compiler/watch.ts

Lines changed: 86 additions & 45 deletions
Large diffs are not rendered by default.

src/testRunner/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
"unittests/tscWatch/consoleClearing.ts",
102102
"unittests/tscWatch/emit.ts",
103103
"unittests/tscWatch/emitAndErrorUpdates.ts",
104+
"unittests/tscWatch/incremental.ts",
104105
"unittests/tscWatch/programUpdates.ts",
105106
"unittests/tscWatch/resolutionCache.ts",
106107
"unittests/tscWatch/watchEnvironment.ts",

src/testRunner/unittests/tsbuild/outFile.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,7 @@ namespace ts {
9999
// outputs
100100
...outputFiles[project.first],
101101
...outputFiles[project.second],
102-
103-
// build info
104-
outputFiles[project.third][ext.buildinfo],
105-
],
106-
// These are first not present and later read new contents to generate third output
107-
outputFiles[project.first][ext.buildinfo],
108-
outputFiles[project.second][ext.buildinfo]
102+
]
109103
);
110104

111105
let dtsChangedExpectedDiagnostics: ReadonlyArray<fakes.ExpectedDiagnostic> = [
@@ -131,12 +125,8 @@ namespace ts {
131125
...outputFiles[project.first],
132126
...outputFiles[project.second],
133127
outputFiles[project.third][ext.dts],
134-
135-
// build info
136-
outputFiles[project.third][ext.buildinfo],
137128
],
138129
outputFiles[project.first][ext.dts], // dts changes so once read old content, and once new (to emit third)
139-
outputFiles[project.first][ext.buildinfo], // since first build info changes
140130
);
141131

142132
let dtsChangedExpectedDiagnosticsDependOrdered: ReadonlyArray<fakes.ExpectedDiagnostic> = [
@@ -173,8 +163,7 @@ namespace ts {
173163
...outputFiles[project.first],
174164
...outputFiles[project.second],
175165
...outputFiles[project.third],
176-
],
177-
outputFiles[project.first][ext.buildinfo], // since first build info changes
166+
]
178167
);
179168

180169
let dtsUnchangedExpectedDiagnosticsDependOrdered: ReadonlyArray<fakes.ExpectedDiagnostic> = [
@@ -227,7 +216,6 @@ namespace ts {
227216
value.set(path, 1);
228217
}
229218
value.set(outputFiles[project.second][ext.dts], 2); // dts changes so once read old content, and once new (to emit third)
230-
value.set(outputFiles[project.second][ext.buildinfo], 2); // since first build info changes
231219
return value;
232220
}
233221

src/testRunner/unittests/tscWatch/helpers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace ts.tscWatch {
3232
export interface Watch {
3333
(): Program;
3434
getBuilderProgram(): EmitAndSemanticDiagnosticsBuilderProgram;
35+
close(): void;
3536
}
3637

3738
export function createWatchOfConfigFile(configFileName: string, host: WatchedSystem, maxNumberOfFilesToIterateForInvalidation?: number) {
@@ -40,6 +41,7 @@ namespace ts.tscWatch {
4041
const watch = createWatchProgram(compilerHost);
4142
const result = (() => watch.getCurrentProgram().getProgram()) as Watch;
4243
result.getBuilderProgram = () => watch.getCurrentProgram();
44+
result.close = () => watch.close();
4345
return result;
4446
}
4547

0 commit comments

Comments
 (0)