Skip to content

Commit ce490e1

Browse files
committed
Check oldest output time with tsconfig time to see if its out of date
Fixes #26503
1 parent 0f598db commit ce490e1

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/compiler/tsbuild.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,17 @@ namespace ts {
792792
newerInputFileName: newestInputFileName
793793
};
794794
}
795+
else {
796+
// Check tsconfig time
797+
const tsconfigTime = host.getModifiedTime(project.options.configFilePath!) || missingFileModifiedTime;
798+
if (oldestOutputFileTime < tsconfigTime) {
799+
return {
800+
type: UpToDateStatusType.OutOfDateWithSelf,
801+
outOfDateOutputFileName: oldestOutputFileName,
802+
newerInputFileName: project.options.configFilePath!
803+
};
804+
}
805+
}
795806

796807
if (!buildInfoChecked.hasKey(project.options.configFilePath as ResolvedConfigFileName)) {
797808
buildInfoChecked.setValue(project.options.configFilePath as ResolvedConfigFileName, true);

src/testRunner/unittests/tsbuild/sample.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,20 @@ namespace ts {
254254
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"],
255255
);
256256
});
257+
258+
it("rebuilds when tsconfig changes", () => {
259+
const { fs, host, builder } = initializeWithBuild();
260+
replaceText(fs, "/src/tests/tsconfig.json", `"composite": true`, `"composite": true, "target": "es3"`);
261+
builder.buildAllProjects();
262+
host.assertDiagnosticMessages(
263+
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
264+
[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"],
265+
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/logic/tsconfig.json", "src/logic/index.ts", "src/logic/index.js"],
266+
[Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tests/tsconfig.json", "src/tests/index.js", "src/tests/tsconfig.json"],
267+
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"],
268+
[Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tests/tsconfig.json"]
269+
);
270+
});
257271
});
258272

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

0 commit comments

Comments
 (0)