Handle when no .tsbuildinfo is to be generated

This commit is contained in:
Sheetal Nandi 2019-02-07 16:13:55 -08:00
parent 99df3230aa
commit 1d77008993
3 changed files with 21 additions and 2 deletions

View file

@ -48,7 +48,7 @@ namespace ts {
}
if (includeBuildInfo) {
const buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions(), host.getProjectReferences());
return action({ buildInfoPath }, /*sourceFileOrBundle*/ undefined);
if (buildInfoPath) return action({ buildInfoPath }, /*sourceFileOrBundle*/ undefined);
}
}
}

View file

@ -1487,7 +1487,10 @@ namespace ts {
for (const inputFile of project.fileNames) {
outputs.push(...getOutputFileNames(inputFile, project));
}
if (!ignoreBuildInfo) outputs.push(Debug.assertDefined(getOutputPathForBuildInfo(project.options, project.projectReferences)));
if (!ignoreBuildInfo) {
const buildInfoPath = getOutputPathForBuildInfo(project.options, project.projectReferences);
if (buildInfoPath) outputs.push(buildInfoPath);
}
return outputs;
}
}

View file

@ -65,6 +65,22 @@ namespace ts {
assert(fs.existsSync(output), `Expect file ${output} to exist`);
}
});
it("builds correctly when project is not composite or doesnt have any references", () => {
const fs = projFs.shadow();
replaceText(fs, "/src/core/tsconfig.json", `"composite": true,`, "");
const host = new fakes.SolutionBuilderHost(fs);
const builder = createSolutionBuilder(host, ["/src/core"], { verbose: true });
builder.buildAllProjects();
host.assertDiagnosticMessages(
getExpectedDiagnosticForProjectsInBuild("src/core/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"]
);
for (const output of ["/src/core/index.js", "/src/core/index.d.ts", "/src/core/index.d.ts.map"]) {
assert(fs.existsSync(output), `Expect file ${output} to exist`);
}
});
});
describe("dry builds", () => {