Skip to content

Commit 629bc0c

Browse files
committed
Always emit tsbuild info if path says so (irrespecitive of if there exists bundle and project)
1 parent 89d1475 commit 629bc0c

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

src/compiler/emitter.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ namespace ts {
284284
// Write build information if applicable
285285
if (!buildInfoPath || targetSourceFile || emitSkipped) return;
286286
const program = host.getProgramBuildInfo();
287-
if (!bundle && !program) return;
288287
if (host.isEmitBlocked(buildInfoPath) || compilerOptions.noEmit) {
289288
emitSkipped = true;
290289
return;

src/compiler/tsbuild.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1524,7 +1524,7 @@ namespace ts {
15241524
if (buildInfoPath) {
15251525
const value = state.readFileWithCache(buildInfoPath);
15261526
const buildInfo = value && getBuildInfo(value);
1527-
if (buildInfo && buildInfo.version !== version) {
1527+
if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== version) {
15281528
return {
15291529
type: UpToDateStatusType.TsVersionOutputOfDate,
15301530
version: buildInfo.version

src/harness/fakes.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,12 @@ namespace fakes {
418418
export const version = "FakeTSVersion";
419419

420420
export class SolutionBuilderHost extends CompilerHost implements ts.SolutionBuilderHost<ts.BuilderProgram> {
421-
createProgram = ts.createEmitAndSemanticDiagnosticsBuilderProgram;
421+
createProgram: ts.CreateProgram<ts.BuilderProgram>;
422+
423+
constructor(sys: System | vfs.FileSystem, options?: ts.CompilerOptions, setParentNodes?: boolean, createProgram?: ts.CreateProgram<ts.BuilderProgram>) {
424+
super(sys, options, setParentNodes);
425+
this.createProgram = createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram;
426+
}
422427

423428
readFile(path: string) {
424429
const value = super.readFile(path);

src/testRunner/unittests/tsbuild/sample.ts

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ namespace ts {
22
describe("unittests:: tsbuild:: on 'sample1' project", () => {
33
let projFs: vfs.FileSystem;
44
const { time, tick } = getTime();
5-
const testsOutputs = ["/src/tests/index.js"];
6-
const logicOutputs = ["/src/logic/index.js", "/src/logic/index.js.map", "/src/logic/index.d.ts"];
7-
const coreOutputs = ["/src/core/index.js", "/src/core/index.d.ts", "/src/core/index.d.ts.map"];
5+
const testsOutputs = ["/src/tests/index.js", "/src/tests/index.d.ts", "/src/tests/tsconfig.tsbuildinfo"];
6+
const logicOutputs = ["/src/logic/index.js", "/src/logic/index.js.map", "/src/logic/index.d.ts", "/src/logic/tsconfig.tsbuildinfo"];
7+
const coreOutputs = ["/src/core/index.js", "/src/core/index.d.ts", "/src/core/index.d.ts.map", "/src/core/tsconfig.tsbuildinfo"];
88
const allExpectedOutputs = [...testsOutputs, ...logicOutputs, ...coreOutputs];
99

1010
before(() => {
@@ -272,6 +272,35 @@ namespace ts {
272272
);
273273
});
274274

275+
it("does not rebuild if there is no program and bundle in the ts build info event if version doesnt match ts version", () => {
276+
const fs = projFs.shadow();
277+
const host = new fakes.SolutionBuilderHost(fs, /*options*/ undefined, /*setParentNodes*/ undefined, createAbstractBuilder);
278+
let builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true });
279+
builder.build();
280+
host.assertDiagnosticMessages(
281+
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
282+
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"],
283+
[Diagnostics.Building_project_0, "/src/core/tsconfig.json"],
284+
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/logic/tsconfig.json", "src/logic/index.js"],
285+
[Diagnostics.Building_project_0, "/src/logic/tsconfig.json"],
286+
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tests/tsconfig.json", "src/tests/index.js"],
287+
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"]
288+
);
289+
verifyOutputsPresent(fs, allExpectedOutputs);
290+
291+
host.clearDiagnostics();
292+
tick();
293+
builder = createSolutionBuilder(host, ["/src/tests"], { verbose: true });
294+
changeCompilerVersion(host);
295+
builder.build();
296+
host.assertDiagnosticMessages(
297+
getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json", "src/logic/tsconfig.json", "src/tests/tsconfig.json"),
298+
[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"],
299+
[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"],
300+
[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"]
301+
);
302+
});
303+
275304
it("rebuilds from start if --f is passed", () => {
276305
const { host, builder } = initializeWithBuild({ force: true });
277306
builder.build();

0 commit comments

Comments
 (0)