Skip to content

Commit 1a75c62

Browse files
committed
Remove resetBuildContext
1 parent 04a972b commit 1a75c62

4 files changed

Lines changed: 19 additions & 45 deletions

File tree

src/compiler/tsbuild.ts

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ namespace ts {
260260

261261
// Currently used for testing but can be made public if needed:
262262
/*@internal*/ getBuildOrder(): ReadonlyArray<ResolvedConfigFileName>;
263-
/*@internal*/ resetBuildContext(opts?: BuildOptions): void;
264263

265264
// Testing only
266265
/*@internal*/ getUpToDateStatusOfProject(project: string): UpToDateStatus;
@@ -337,8 +336,8 @@ namespace ts {
337336
const parseConfigFileHost = parseConfigHostFromCompilerHostLike(host);
338337

339338
// State of the solution
340-
let options = defaultOptions;
341-
let baseCompilerOptions = getCompilerOptionsOfBuildOptions(options);
339+
const options = defaultOptions;
340+
const baseCompilerOptions = getCompilerOptionsOfBuildOptions(options);
342341
const resolvedConfigFilePaths = createMap<ResolvedConfigFilePath>();
343342
type ConfigFileCacheEntry = ParsedCommandLine | Diagnostic;
344343
const configFileCache = createMap() as ConfigFileMap<ConfigFileCacheEntry>;
@@ -380,7 +379,6 @@ namespace ts {
380379
buildAllProjects,
381380
cleanAllProjects,
382381
getBuildOrder,
383-
resetBuildContext,
384382
getUpToDateStatusOfProject,
385383
invalidateProject,
386384
buildInvalidatedProject,
@@ -399,29 +397,6 @@ namespace ts {
399397
return resolvedPath;
400398
}
401399

402-
function resetBuildContext(opts?: BuildOptions) {
403-
options = opts || defaultOptions;
404-
baseCompilerOptions = getCompilerOptionsOfBuildOptions(options);
405-
resolvedConfigFilePaths.clear();
406-
configFileCache.clear();
407-
projectStatus.clear();
408-
buildOrder = undefined;
409-
buildInfoChecked.clear();
410-
411-
diagnostics.clear();
412-
projectPendingBuild.clear();
413-
projectErrorsReported.clear();
414-
if (timerToBuildInvalidatedProject) {
415-
clearTimeout(timerToBuildInvalidatedProject);
416-
timerToBuildInvalidatedProject = undefined;
417-
}
418-
reportFileChangeDetected = false;
419-
clearMap(allWatchedWildcardDirectories, wildCardWatches => clearMap(wildCardWatches, closeFileWatcherOf));
420-
clearMap(allWatchedInputFiles, inputFileWatches => clearMap(inputFileWatches, closeFileWatcher));
421-
clearMap(allWatchedConfigFiles, closeFileWatcher);
422-
builderPrograms.clear();
423-
}
424-
425400
function isParsedCommandLine(entry: ConfigFileCacheEntry): entry is ParsedCommandLine {
426401
return !!(entry as ParsedCommandLine).options;
427402
}

src/testRunner/unittests/tsbuild/outFile.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ namespace ts {
388388
...outputFiles[project.third]
389389
];
390390
const host = new fakes.SolutionBuilderHost(fs);
391-
const builder = createSolutionBuilder(host);
391+
let builder = createSolutionBuilder(host);
392392
builder.buildAllProjects();
393393
host.assertDiagnosticMessages(...initialExpectedDiagnostics);
394394
// Verify they exist
@@ -398,7 +398,7 @@ namespace ts {
398398
// Delete bundle info
399399
host.clearDiagnostics();
400400
host.deleteFile(outputFiles[project.first][ext.buildinfo]);
401-
builder.resetBuildContext();
401+
builder = createSolutionBuilder(host);
402402
builder.buildAllProjects();
403403
host.assertDiagnosticMessages(
404404
getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]),
@@ -428,11 +428,11 @@ namespace ts {
428428
it("rebuilds completely when version in tsbuildinfo doesnt match ts version", () => {
429429
const fs = outFileFs.shadow();
430430
const host = new fakes.SolutionBuilderHost(fs);
431-
const builder = createSolutionBuilder(host);
431+
let builder = createSolutionBuilder(host);
432432
builder.buildAllProjects();
433433
host.assertDiagnosticMessages(...initialExpectedDiagnostics);
434434
host.clearDiagnostics();
435-
builder.resetBuildContext();
435+
builder = createSolutionBuilder(host);
436436
changeCompilerVersion(host);
437437
builder.buildAllProjects();
438438
host.assertDiagnosticMessages(
@@ -453,15 +453,15 @@ namespace ts {
453453

454454
// Build with command line incremental
455455
const host = new fakes.SolutionBuilderHost(fs);
456-
const builder = createSolutionBuilder(host, { incremental: true });
456+
let builder = createSolutionBuilder(host, { incremental: true });
457457
builder.buildAllProjects();
458458
host.assertDiagnosticMessages(...initialExpectedDiagnostics);
459459
host.clearDiagnostics();
460460
tick();
461461

462462
// Make non incremental build with change in file that doesnt affect dts
463463
appendText(fs, relSources[project.first][source.ts][part.one], "console.log(s);");
464-
builder.resetBuildContext({ verbose: true });
464+
builder = createSolutionBuilder(host, { verbose: true });
465465
builder.buildAllProjects();
466466
host.assertDiagnosticMessages(getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]),
467467
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.first][source.config], relOutputFiles[project.first][ext.js], relSources[project.first][source.ts][part.one]],
@@ -475,7 +475,7 @@ namespace ts {
475475

476476
// Make incremental build with change in file that doesnt affect dts
477477
appendText(fs, relSources[project.first][source.ts][part.one], "console.log(s);");
478-
builder.resetBuildContext({ verbose: true, incremental: true });
478+
builder = createSolutionBuilder(host, { verbose: true, incremental: true });
479479
builder.buildAllProjects();
480480
// Builds completely because tsbuildinfo is old.
481481
host.assertDiagnosticMessages(

src/testRunner/unittests/tsbuild/resolveJsonModule.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default hello.hello`);
6464
const configFile = "src/tsconfig_withFiles.json";
6565
replaceText(fs, configFile, `"composite": true,`, `"composite": true, "sourceMap": true,`);
6666
const host = new fakes.SolutionBuilderHost(fs);
67-
const builder = createSolutionBuilder(host, [configFile], { verbose: true });
67+
let builder = createSolutionBuilder(host, [configFile], { verbose: true });
6868
builder.buildAllProjects();
6969
host.assertDiagnosticMessages(
7070
getExpectedDiagnosticForProjectsInBuild(configFile),
@@ -75,7 +75,7 @@ export default hello.hello`);
7575
assert(fs.existsSync(output), `Expect file ${output} to exist`);
7676
}
7777
host.clearDiagnostics();
78-
builder.resetBuildContext();
78+
builder = createSolutionBuilder(host, [configFile], { verbose: true });
7979
tick();
8080
builder.buildAllProjects();
8181
host.assertDiagnosticMessages(
@@ -89,7 +89,7 @@ export default hello.hello`);
8989
const configFile = "src/tsconfig_withFiles.json";
9090
replaceText(fs, configFile, `"outDir": "dist",`, "");
9191
const host = new fakes.SolutionBuilderHost(fs);
92-
const builder = createSolutionBuilder(host, [configFile], { verbose: true });
92+
let builder = createSolutionBuilder(host, [configFile], { verbose: true });
9393
builder.buildAllProjects();
9494
host.assertDiagnosticMessages(
9595
getExpectedDiagnosticForProjectsInBuild(configFile),
@@ -100,7 +100,7 @@ export default hello.hello`);
100100
assert(fs.existsSync(output), `Expect file ${output} to exist`);
101101
}
102102
host.clearDiagnostics();
103-
builder.resetBuildContext();
103+
builder = createSolutionBuilder(host, [configFile], { verbose: true });
104104
tick();
105105
builder.buildAllProjects();
106106
host.assertDiagnosticMessages(
@@ -128,7 +128,7 @@ export default hello.hello`);
128128
const stringsConfigFile = "src/strings/tsconfig.json";
129129
const mainConfigFile = "src/main/tsconfig.json";
130130
const host = new fakes.SolutionBuilderHost(fs);
131-
const builder = createSolutionBuilder(host, [configFile], { verbose: true });
131+
let builder = createSolutionBuilder(host, [configFile], { verbose: true });
132132
builder.buildAllProjects();
133133
host.assertDiagnosticMessages(
134134
getExpectedDiagnosticForProjectsInBuild(stringsConfigFile, mainConfigFile, configFile),
@@ -139,7 +139,7 @@ export default hello.hello`);
139139
);
140140
assert(fs.existsSync(expectedOutput), `Expect file ${expectedOutput} to exist`);
141141
host.clearDiagnostics();
142-
builder.resetBuildContext();
142+
builder = createSolutionBuilder(host, [configFile], { verbose: true });
143143
tick();
144144
builder.buildAllProjects();
145145
host.assertDiagnosticMessages(

src/testRunner/unittests/tsbuild/sample.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,18 @@ namespace ts {
171171
function initializeWithBuild(opts?: BuildOptions) {
172172
const fs = projFs.shadow();
173173
const host = new fakes.SolutionBuilderHost(fs);
174-
const builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true });
174+
let builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true });
175175
builder.buildAllProjects();
176176
host.clearDiagnostics();
177177
tick();
178-
builder.resetBuildContext(opts ? { ...opts, verbose: true } : undefined);
178+
builder = createSolutionBuilder(host, ["/src/tests"], { ...(opts || {}), verbose: true });
179179
return { fs, host, builder };
180180
}
181181

182182
it("Builds the project", () => {
183183
const fs = projFs.shadow();
184184
const host = new fakes.SolutionBuilderHost(fs);
185185
const builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true });
186-
builder.resetBuildContext();
187186
builder.buildAllProjects();
188187
host.assertDiagnosticMessages(
189188
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
@@ -288,7 +287,7 @@ namespace ts {
288287
fs.writeFileSync("/src/tests/tsconfig.base.json", JSON.stringify({ compilerOptions: { target: "es3" } }));
289288
replaceText(fs, "/src/tests/tsconfig.json", `"references": [`, `"extends": "./tsconfig.base.json", "references": [`);
290289
const host = new fakes.SolutionBuilderHost(fs);
291-
const builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true });
290+
let builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true });
292291
builder.buildAllProjects();
293292
host.assertDiagnosticMessages(
294293
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
@@ -301,7 +300,7 @@ namespace ts {
301300
);
302301
host.clearDiagnostics();
303302
tick();
304-
builder.resetBuildContext();
303+
builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true });
305304
fs.writeFileSync("/src/tests/tsconfig.base.json", JSON.stringify({ compilerOptions: {} }));
306305
builder.buildAllProjects();
307306
host.assertDiagnosticMessages(

0 commit comments

Comments
 (0)