Skip to content

Commit 0e5d95f

Browse files
committed
Container only ref needs to be ignored from uptodate status
Fixes #31288
1 parent f2735b5 commit 0e5d95f

File tree

12 files changed

+95
-2
lines changed

12 files changed

+95
-2
lines changed

src/compiler/tsbuild.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,8 @@ namespace ts {
14621462
const refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
14631463

14641464
// Its a circular reference ignore the status of this project
1465-
if (refStatus.type === UpToDateStatusType.ComputingUpstream) {
1465+
if (refStatus.type === UpToDateStatusType.ComputingUpstream ||
1466+
refStatus.type === UpToDateStatusType.ContainerOnly) { // Container only ignore this project
14661467
continue;
14671468
}
14681469

src/testRunner/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"unittests/services/textChanges.ts",
9191
"unittests/services/transpile.ts",
9292
"unittests/tsbuild/amdModulesWithOut.ts",
93+
"unittests/tsbuild/containerOnlyReferenced.ts",
9394
"unittests/tsbuild/emptyFiles.ts",
9495
"unittests/tsbuild/graphOrdering.ts",
9596
"unittests/tsbuild/inferredTypeFromTransitiveModule.ts",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
namespace ts {
2+
describe("unittests:: tsbuild:: when containerOnly project is referenced", () => {
3+
let projFs: vfs.FileSystem;
4+
before(() => {
5+
projFs = loadProjectFromDisk("tests/projects/containerOnlyReferenced");
6+
});
7+
8+
after(() => {
9+
projFs = undefined!; // Release the contents
10+
});
11+
12+
function outputs(folder: string) {
13+
return [
14+
`${folder}/index.js`,
15+
`${folder}/index.d.ts`,
16+
`${folder}/tsconfig.tsbuildinfo`
17+
];
18+
}
19+
20+
it("verify that subsequent builds after initial build doesnt build anything", () => {
21+
const fs = projFs.shadow();
22+
const host = new fakes.SolutionBuilderHost(fs);
23+
createSolutionBuilder(host, ["/src"], { verbose: true }).build();
24+
host.assertDiagnosticMessages(
25+
getExpectedDiagnosticForProjectsInBuild("src/src/folder/tsconfig.json", "src/src/folder2/tsconfig.json", "src/src/tsconfig.json", "src/tests/tsconfig.json", "src/tsconfig.json"),
26+
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/src/folder/tsconfig.json", "src/src/folder/index.js"],
27+
[Diagnostics.Building_project_0, "/src/src/folder/tsconfig.json"],
28+
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/src/folder2/tsconfig.json", "src/src/folder2/index.js"],
29+
[Diagnostics.Building_project_0, "/src/src/folder2/tsconfig.json"],
30+
[Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tests/tsconfig.json", "src/tests/index.js"],
31+
[Diagnostics.Building_project_0, "/src/tests/tsconfig.json"],
32+
);
33+
verifyOutputsPresent(fs, [
34+
...outputs("/src/src/folder"),
35+
...outputs("/src/src/folder2"),
36+
...outputs("/src/tests"),
37+
]);
38+
host.clearDiagnostics();
39+
createSolutionBuilder(host, ["/src"], { verbose: true }).build();
40+
host.assertDiagnosticMessages(
41+
getExpectedDiagnosticForProjectsInBuild("src/src/folder/tsconfig.json", "src/src/folder2/tsconfig.json", "src/src/tsconfig.json", "src/tests/tsconfig.json", "src/tsconfig.json"),
42+
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/src/folder/tsconfig.json", "src/src/folder/index.ts", "src/src/folder/index.js"],
43+
[Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/src/folder2/tsconfig.json", "src/src/folder2/index.ts", "src/src/folder2/index.js"],
44+
[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"],
45+
);
46+
});
47+
});
48+
}

src/testRunner/unittests/tsbuild/referencesWithRootDirInParent.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ namespace ts {
1010
});
1111

1212
it("verify that it builds correctly", () => {
13-
const projFs = loadProjectFromDisk("tests/projects/projectReferenceWithRootDirInParent");
1413
const allExpectedOutputs = [
1514
"/src/dist/other/other.js", "/src/dist/other/other.d.ts",
1615
"/src/dist/main/a.js", "/src/dist/main/a.d.ts",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const x = 10;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"files": ["index.ts"],
3+
"compilerOptions": {
4+
"composite": true
5+
}
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const x = 10;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"files": ["index.ts"],
3+
"compilerOptions": {
4+
"composite": true
5+
}
6+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"files": [],
3+
"compilerOptions": {
4+
"composite": true
5+
},
6+
"references": [
7+
{ "path": "./folder" },
8+
{ "path": "./folder2"}
9+
]
10+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const x = 10;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"files": ["index.ts"],
3+
"compilerOptions": {
4+
"composite": true
5+
},
6+
"references": [
7+
{ "path": "../src" }
8+
]
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"files": [],
3+
"compilerOptions": {
4+
"composite": true
5+
},
6+
"references": [
7+
{ "path": "./src" },
8+
{ "path": "./tests"}
9+
]
10+
}

0 commit comments

Comments
 (0)