Skip to content

Commit 4fafe0b

Browse files
Merge pull request #25049 from RyanCavanaugh/tsbuild-fixes
Fixes downstream prepend projects not being built correctly on upstream changes
2 parents e060871 + a72fe5d commit 4fafe0b

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed

Jakefile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ task(TaskNames.lint, [TaskNames.buildRules], () => {
204204
if (fold.isTravis()) console.log(fold.end("lint"));
205205
complete();
206206
}));
207-
});
207+
}, { async: true });
208208

209209
desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable");
210210
task('diff', function () {

src/compiler/tsbuild.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ namespace ts {
777777

778778
let pseudoUpToDate = false;
779779
let usesPrepend = false;
780+
let upstreamChangedProject: string | undefined;
780781
if (project.projectReferences) {
781782
for (const ref of project.projectReferences) {
782783
usesPrepend = usesPrepend || !!(ref.prepend);
@@ -809,6 +810,7 @@ namespace ts {
809810
// *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
810811
if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
811812
pseudoUpToDate = true;
813+
upstreamChangedProject = ref.path;
812814
continue;
813815
}
814816

@@ -837,8 +839,12 @@ namespace ts {
837839
};
838840
}
839841

840-
if (usesPrepend) {
841-
pseudoUpToDate = false;
842+
if (usesPrepend && pseudoUpToDate) {
843+
return {
844+
type: UpToDateStatusType.OutOfDateWithUpstream,
845+
outOfDateOutputFileName: oldestOutputFileName,
846+
newerProjectName: upstreamChangedProject!
847+
};
842848
}
843849

844850
// Up to date

src/testRunner/unittests/tsbuild.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,23 @@ namespace ts {
259259
});
260260
});
261261
});
262+
263+
describe("tsbuild - downstream prepend projects always get rebuilt", () => {
264+
const fs = outFileFs.shadow();
265+
const host = new fakes.CompilerHost(fs);
266+
const builder = createSolutionBuilder(host, buildHost, ["/src/third"], { dry: false, force: false, verbose: false });
267+
clearDiagnostics();
268+
builder.buildAllProjects();
269+
assertDiagnosticMessages(/*none*/);
270+
assert.equal(fs.statSync("src/third/thirdjs/output/third-output.js").mtimeMs, time(), "First build timestamp is correct");
271+
tick();
272+
replaceText(fs, "src/first/first_PART1.ts", "Hello", "Hola");
273+
tick();
274+
builder.resetBuildContext();
275+
builder.buildAllProjects();
276+
assertDiagnosticMessages(/*none*/);
277+
assert.equal(fs.statSync("src/third/thirdjs/output/third-output.js").mtimeMs, time(), "Second build timestamp is correct");
278+
});
262279
}
263280

264281
describe("tsbuild - graph-ordering", () => {

tests/projects/outfile-concat/first/tsconfig.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
"declaration": true,
1010
"outFile": "./bin/first-output.js"
1111
},
12+
"files": [
13+
"first_PART1.ts",
14+
"first_part2.ts",
15+
"first_part3.ts"
16+
],
1217
"references": [
1318
]
1419
}

tests/projects/outfile-concat/third/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"declaration": true,
1010
"outFile": "./thirdjs/output/third-output.js"
1111
},
12+
"files": [
13+
"third_part1.ts"
14+
],
1215
"references": [
1316
{ "path": "../first", "prepend": true },
1417
{ "path": "../second", "prepend": true },

0 commit comments

Comments
 (0)