From 717dad9ebfa09f9a8a837fd16a2a967d77e125d0 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 29 Jan 2019 15:26:30 -0800 Subject: [PATCH] Dont use tsbundleInfo to determine if bundle needs to be rebuilt --- src/compiler/tsbuild.ts | 11 +++++---- src/testRunner/unittests/tsbuild.ts | 36 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 2371f771c94..d5b34271d38 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -289,7 +289,7 @@ namespace ts { return outputs; } - function getOutFileOutputs(project: ParsedCommandLine): ReadonlyArray { + function getOutFileOutputs(project: ParsedCommandLine, ignoreBundleInfo?: boolean): ReadonlyArray { 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 { + export function getAllProjectOutputs(project: ParsedCommandLine, ignoreBundleInfo?: true): ReadonlyArray { if (project.options.outFile || project.options.out) { - return getOutFileOutputs(project); + return getOutFileOutputs(project, ignoreBundleInfo); } else { const outputs: string[] = []; diff --git a/src/testRunner/unittests/tsbuild.ts b/src/testRunner/unittests/tsbuild.ts index ef5dca281ba..c2eb6d5aff0 100644 --- a/src/testRunner/unittests/tsbuild.ts +++ b/src/testRunner/unittests/tsbuild.ts @@ -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));