Build project if existing project was built with different compiler version

This commit is contained in:
Sheetal Nandi
2019-03-08 15:05:30 -08:00
parent ecb2ce429d
commit 68e28da141
8 changed files with 65 additions and 17 deletions

View File

@@ -8,7 +8,7 @@ namespace ts {
host.readFile = path => {
const value = originalReadFile.call(host, path);
if (!value || !isBuildInfoFile(path)) return value;
const buildInfo = JSON.parse(value) as BuildInfo;
const buildInfo = getBuildInfo(value);
buildInfo.version = fakes.version;
return getBuildInfoText(buildInfo);
};
@@ -101,7 +101,7 @@ namespace ts {
for (const [file, jsFile, dtsFile] of buildInfoFileNames) {
if (!fs.existsSync(file)) continue;
const buildInfo = JSON.parse(fs.readFileSync(file, "utf8")) as BuildInfo;
const buildInfo = getBuildInfo(fs.readFileSync(file, "utf8"));
const bundle = buildInfo.bundle;
if (!bundle || (!length(bundle.js && bundle.js.sections) && !length(bundle.dts && bundle.dts.sections))) continue;

View File

@@ -451,9 +451,12 @@ namespace ts {
host.assertDiagnosticMessages(
// TODO:: This should build all instead
getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]),
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relSources[project.first][source.config], relSources[project.first][source.ts][part.one], relOutputFiles[project.first][ext.js]],
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relSources[project.second][source.config], relSources[project.second][source.ts][part.one], relOutputFiles[project.second][ext.js]],
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relSources[project.third][source.config], relSources[project.third][source.ts][part.one], relOutputFiles[project.third][ext.js]],
[Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relSources[project.first][source.config], fakes.version, version],
[Diagnostics.Building_project_0, sources[project.first][source.config]],
[Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relSources[project.second][source.config], fakes.version, version],
[Diagnostics.Building_project_0, sources[project.second][source.config]],
[Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relSources[project.third][source.config], fakes.version, version],
[Diagnostics.Building_project_0, sources[project.third][source.config]],
);
});

View File

@@ -245,11 +245,13 @@ namespace ts {
changeCompilerVersion(host);
builder.buildAllProjects();
host.assertDiagnosticMessages(
// TODO:: This should build all instead
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_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/tests/tsconfig.json", "src/tests/index.ts", "src/tests/index.js"]
[Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, "src/core/tsconfig.json", fakes.version, version],
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"],
[Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, "src/logic/tsconfig.json", fakes.version, version],
[Diagnostics.Building_project_0, "/src/logic/tsconfig.json"],
[Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, "src/tests/tsconfig.json", fakes.version, version],
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"],
);
});
});
@@ -508,6 +510,8 @@ class someClass { }`),
// build info
"/src/core/tsconfig.tsbuildinfo",
"/src/logic/tsconfig.tsbuildinfo",
"/src/tests/tsconfig.tsbuildinfo",
],
)
},
@@ -571,6 +575,7 @@ class someClass { }`),
"/src/logic/decls/index.d.ts",
// build info
"/src/core/tsconfig.tsbuildinfo",
"/src/logic/tsconfig.tsbuildinfo",
"/src/tests/tsconfig.tsbuildinfo",