Merge pull request #30438 from Microsoft/tsconfigChangeDetection
Check oldest output time with tsconfig time to see if its out of date
This commit is contained in:
commit
fa9705455f
2 changed files with 66 additions and 0 deletions
|
@ -792,6 +792,15 @@ namespace ts {
|
||||||
newerInputFileName: newestInputFileName
|
newerInputFileName: newestInputFileName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Check tsconfig time
|
||||||
|
const configStatus = checkConfigFileUpToDateStatus(project.options.configFilePath!, oldestOutputFileTime, oldestOutputFileName);
|
||||||
|
if (configStatus) return configStatus;
|
||||||
|
|
||||||
|
// Check extended config time
|
||||||
|
const extendedConfigStatus = forEach(project.options.configFile!.extendedSourceFiles || emptyArray, configFile => checkConfigFileUpToDateStatus(configFile, oldestOutputFileTime, oldestOutputFileName));
|
||||||
|
if (extendedConfigStatus) return extendedConfigStatus;
|
||||||
|
}
|
||||||
|
|
||||||
if (!buildInfoChecked.hasKey(project.options.configFilePath as ResolvedConfigFileName)) {
|
if (!buildInfoChecked.hasKey(project.options.configFilePath as ResolvedConfigFileName)) {
|
||||||
buildInfoChecked.setValue(project.options.configFilePath as ResolvedConfigFileName, true);
|
buildInfoChecked.setValue(project.options.configFilePath as ResolvedConfigFileName, true);
|
||||||
|
@ -828,6 +837,18 @@ namespace ts {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkConfigFileUpToDateStatus(configFile: string, oldestOutputFileTime: Date, oldestOutputFileName: string): Status.OutOfDateWithSelf | undefined {
|
||||||
|
// Check tsconfig time
|
||||||
|
const tsconfigTime = host.getModifiedTime(configFile) || missingFileModifiedTime;
|
||||||
|
if (oldestOutputFileTime < tsconfigTime) {
|
||||||
|
return {
|
||||||
|
type: UpToDateStatusType.OutOfDateWithSelf,
|
||||||
|
outOfDateOutputFileName: oldestOutputFileName,
|
||||||
|
newerInputFileName: configFile
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function invalidateProject(configFileName: string, reloadLevel?: ConfigFileProgramReloadLevel) {
|
function invalidateProject(configFileName: string, reloadLevel?: ConfigFileProgramReloadLevel) {
|
||||||
invalidateResolvedProject(resolveProjectName(configFileName), reloadLevel);
|
invalidateResolvedProject(resolveProjectName(configFileName), reloadLevel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -268,6 +268,51 @@ namespace ts {
|
||||||
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
|
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("rebuilds when tsconfig changes", () => {
|
||||||
|
const { fs, host, builder } = initializeWithBuild();
|
||||||
|
replaceText(fs, "/src/tests/tsconfig.json", `"composite": true`, `"composite": true, "target": "es3"`);
|
||||||
|
builder.buildAllProjects();
|
||||||
|
host.assertDiagnosticMessages(
|
||||||
|
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
|
||||||
|
[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"],
|
||||||
|
[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"],
|
||||||
|
[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"],
|
||||||
|
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"],
|
||||||
|
[Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tests/tsconfig.json"]
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("rebuilds when extended config file changes", () => {
|
||||||
|
const fs = projFs.shadow();
|
||||||
|
fs.writeFileSync("/src/tests/tsconfig.base.json", JSON.stringify({ compilerOptions: { target: "es3" } }));
|
||||||
|
replaceText(fs, "/src/tests/tsconfig.json", `"references": [`, `"extends": "./tsconfig.base.json", "references": [`);
|
||||||
|
const host = new fakes.SolutionBuilderHost(fs);
|
||||||
|
const builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true });
|
||||||
|
builder.buildAllProjects();
|
||||||
|
host.assertDiagnosticMessages(
|
||||||
|
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
|
||||||
|
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"],
|
||||||
|
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"],
|
||||||
|
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/logic/tsconfig.json", "src/logic/index.js"],
|
||||||
|
[Diagnostics.Building_project_0, "/src/logic/tsconfig.json"],
|
||||||
|
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tests/tsconfig.json", "src/tests/index.js"],
|
||||||
|
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
|
||||||
|
);
|
||||||
|
host.clearDiagnostics();
|
||||||
|
tick();
|
||||||
|
builder.resetBuildContext();
|
||||||
|
fs.writeFileSync("/src/tests/tsconfig.base.json", JSON.stringify({ compilerOptions: {} }));
|
||||||
|
builder.buildAllProjects();
|
||||||
|
host.assertDiagnosticMessages(
|
||||||
|
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
|
||||||
|
[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"],
|
||||||
|
[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"],
|
||||||
|
[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.base.json"],
|
||||||
|
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"],
|
||||||
|
[Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tests/tsconfig.json"]
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("downstream-blocked compilations", () => {
|
describe("downstream-blocked compilations", () => {
|
||||||
|
|
Loading…
Reference in a new issue