Dont use tsbundleInfo to determine if bundle needs to be rebuilt
This commit is contained in:
parent
36ae7be415
commit
717dad9ebf
2 changed files with 42 additions and 5 deletions
|
@ -289,7 +289,7 @@ namespace ts {
|
|||
return outputs;
|
||||
}
|
||||
|
||||
function getOutFileOutputs(project: ParsedCommandLine): ReadonlyArray<string> {
|
||||
function getOutFileOutputs(project: ParsedCommandLine, ignoreBundleInfo?: boolean): ReadonlyArray<string> {
|
||||
Debug.assert(!!project.options.outFile || !!project.options.out, "outFile must be set");
|
||||
const { jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, bundleInfoPath } = getOutputPathsForBundle(project.options, /*forceDtsPaths*/ false);
|
||||
|
||||
|
@ -299,7 +299,7 @@ namespace ts {
|
|||
addOutput(sourceMapFilePath);
|
||||
addOutput(declarationFilePath);
|
||||
addOutput(declarationMapPath);
|
||||
addOutput(bundleInfoPath);
|
||||
if (!ignoreBundleInfo) addOutput(bundleInfoPath);
|
||||
return outputs || emptyArray;
|
||||
}
|
||||
|
||||
|
@ -711,7 +711,8 @@ namespace ts {
|
|||
}
|
||||
|
||||
// Collect the expected outputs of this project
|
||||
const outputs = getAllProjectOutputs(project);
|
||||
// Do not use presence or absence of bundleInfo to determine status of build
|
||||
const outputs = getAllProjectOutputs(project, /*ignoreBundleInfo*/ true);
|
||||
|
||||
if (outputs.length === 0) {
|
||||
return {
|
||||
|
@ -1392,9 +1393,9 @@ namespace ts {
|
|||
return combinePaths(project, "tsconfig.json") as ResolvedConfigFileName;
|
||||
}
|
||||
|
||||
export function getAllProjectOutputs(project: ParsedCommandLine): ReadonlyArray<string> {
|
||||
export function getAllProjectOutputs(project: ParsedCommandLine, ignoreBundleInfo?: true): ReadonlyArray<string> {
|
||||
if (project.options.outFile || project.options.out) {
|
||||
return getOutFileOutputs(project);
|
||||
return getOutFileOutputs(project, ignoreBundleInfo);
|
||||
}
|
||||
else {
|
||||
const outputs: string[] = [];
|
||||
|
|
|
@ -621,6 +621,42 @@ export const b = new A();`);
|
|||
builder.cleanAllProjects();
|
||||
});
|
||||
|
||||
it("unittests:: tsbuild - outFile:: verify tsbundleInfo presence or absence does not result in new build", () => {
|
||||
const fs = outFileFs.shadow();
|
||||
const expectedOutputs = [
|
||||
...outputFiles[0],
|
||||
...outputFiles[1],
|
||||
...outputFiles[2]
|
||||
];
|
||||
const host = new fakes.SolutionBuilderHost(fs);
|
||||
const builder = createSolutionBuilder(host, ["/src/third"], { dry: false, force: false, verbose: true });
|
||||
builder.buildAllProjects();
|
||||
host.assertDiagnosticMessages(
|
||||
Diagnostics.Projects_in_this_build_Colon_0,
|
||||
Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist,
|
||||
Diagnostics.Building_project_0,
|
||||
Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist,
|
||||
Diagnostics.Building_project_0,
|
||||
Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist,
|
||||
Diagnostics.Building_project_0
|
||||
);
|
||||
// Verify they exist
|
||||
for (const output of expectedOutputs) {
|
||||
assert(fs.existsSync(output), `Expect file ${output} to exist`);
|
||||
}
|
||||
// Delete bundle info
|
||||
host.clearDiagnostics();
|
||||
host.deleteFile(last(outputFiles[0]));
|
||||
builder.resetBuildContext();
|
||||
builder.buildAllProjects();
|
||||
host.assertDiagnosticMessages(
|
||||
Diagnostics.Projects_in_this_build_Colon_0,
|
||||
Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2,
|
||||
Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2,
|
||||
Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2,
|
||||
);
|
||||
});
|
||||
|
||||
function replaceFileContent(fs: vfs.FileSystem, path: string, searchValue: string, replaceValue: string) {
|
||||
const content = fs.readFileSync(path, "utf8");
|
||||
fs.writeFileSync(path, content.replace(searchValue, replaceValue));
|
||||
|
|
Loading…
Reference in a new issue