Skip to content

Commit e552163

Browse files
authored
Merge pull request #30439 from Microsoft/forceBuild
Passing --force option to build, builds project from start
2 parents 10b9051 + 52641c5 commit e552163

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/compiler/tsbuild.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,7 @@ namespace ts {
11781178
}
11791179

11801180
function getOldProgram(proj: ResolvedConfigFileName, parsed: ParsedCommandLine) {
1181+
if (options.force) return undefined;
11811182
const value = builderPrograms.getValue(proj);
11821183
if (value) return value;
11831184
return readBuilderProgram(parsed.options, readFileWithCache) as any as T;

src/testRunner/unittests/tsbuild/sample.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,14 @@ namespace ts {
168168
});
169169

170170
describe("can detect when and what to rebuild", () => {
171-
function initializeWithBuild() {
171+
function initializeWithBuild(opts?: BuildOptions) {
172172
const fs = projFs.shadow();
173173
const host = new fakes.SolutionBuilderHost(fs);
174174
const builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true });
175175
builder.buildAllProjects();
176176
host.clearDiagnostics();
177177
tick();
178-
builder.resetBuildContext();
178+
builder.resetBuildContext(opts ? { ...opts, verbose: true } : undefined);
179179
return { fs, host, builder };
180180
}
181181

@@ -254,6 +254,20 @@ namespace ts {
254254
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"],
255255
);
256256
});
257+
258+
it("rebuilds from start if --f is passed", () => {
259+
const { host, builder } = initializeWithBuild({ force: true });
260+
builder.buildAllProjects();
261+
host.assertDiagnosticMessages(
262+
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
263+
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/core/tsconfig.json", "src/core/anotherModule.ts", "src/core/anotherModule.js"],
264+
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"],
265+
[Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, "src/logic/tsconfig.json"],
266+
[Diagnostics.Building_project_0, "/src/logic/tsconfig.json"],
267+
[Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, "src/tests/tsconfig.json"],
268+
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
269+
);
270+
});
257271
});
258272

259273
describe("downstream-blocked compilations", () => {

0 commit comments

Comments
 (0)