diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 4602c0793b..f2a43e5e79 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -1462,7 +1462,8 @@ namespace ts { const refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath); // Its a circular reference ignore the status of this project - if (refStatus.type === UpToDateStatusType.ComputingUpstream) { + if (refStatus.type === UpToDateStatusType.ComputingUpstream || + refStatus.type === UpToDateStatusType.ContainerOnly) { // Container only ignore this project continue; } diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 07499a998b..b2e7e3e78b 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -90,6 +90,7 @@ "unittests/services/textChanges.ts", "unittests/services/transpile.ts", "unittests/tsbuild/amdModulesWithOut.ts", + "unittests/tsbuild/containerOnlyReferenced.ts", "unittests/tsbuild/emptyFiles.ts", "unittests/tsbuild/graphOrdering.ts", "unittests/tsbuild/inferredTypeFromTransitiveModule.ts", diff --git a/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts b/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts new file mode 100644 index 0000000000..425dbf2e20 --- /dev/null +++ b/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts @@ -0,0 +1,48 @@ +namespace ts { + describe("unittests:: tsbuild:: when containerOnly project is referenced", () => { + let projFs: vfs.FileSystem; + before(() => { + projFs = loadProjectFromDisk("tests/projects/containerOnlyReferenced"); + }); + + after(() => { + projFs = undefined!; // Release the contents + }); + + function outputs(folder: string) { + return [ + `${folder}/index.js`, + `${folder}/index.d.ts`, + `${folder}/tsconfig.tsbuildinfo` + ]; + } + + it("verify that subsequent builds after initial build doesnt build anything", () => { + const fs = projFs.shadow(); + const host = new fakes.SolutionBuilderHost(fs); + createSolutionBuilder(host, ["/src"], { verbose: true }).build(); + host.assertDiagnosticMessages( + getExpectedDiagnosticForProjectsInBuild("src/src/folder/tsconfig.json", "src/src/folder2/tsconfig.json", "src/src/tsconfig.json", "src/tests/tsconfig.json", "src/tsconfig.json"), + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/src/folder/tsconfig.json", "src/src/folder/index.js"], + [Diagnostics.Building_project_0, "/src/src/folder/tsconfig.json"], + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/src/folder2/tsconfig.json", "src/src/folder2/index.js"], + [Diagnostics.Building_project_0, "/src/src/folder2/tsconfig.json"], + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tests/tsconfig.json", "src/tests/index.js"], + [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"], + ); + verifyOutputsPresent(fs, [ + ...outputs("/src/src/folder"), + ...outputs("/src/src/folder2"), + ...outputs("/src/tests"), + ]); + host.clearDiagnostics(); + createSolutionBuilder(host, ["/src"], { verbose: true }).build(); + host.assertDiagnosticMessages( + getExpectedDiagnosticForProjectsInBuild("src/src/folder/tsconfig.json", "src/src/folder2/tsconfig.json", "src/src/tsconfig.json", "src/tests/tsconfig.json", "src/tsconfig.json"), + [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"], + [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"], + [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"], + ); + }); + }); +} diff --git a/src/testRunner/unittests/tsbuild/referencesWithRootDirInParent.ts b/src/testRunner/unittests/tsbuild/referencesWithRootDirInParent.ts index 186a43b3c3..f6a2dca6c2 100644 --- a/src/testRunner/unittests/tsbuild/referencesWithRootDirInParent.ts +++ b/src/testRunner/unittests/tsbuild/referencesWithRootDirInParent.ts @@ -10,7 +10,6 @@ namespace ts { }); it("verify that it builds correctly", () => { - const projFs = loadProjectFromDisk("tests/projects/projectReferenceWithRootDirInParent"); const allExpectedOutputs = [ "/src/dist/other/other.js", "/src/dist/other/other.d.ts", "/src/dist/main/a.js", "/src/dist/main/a.d.ts", diff --git a/tests/projects/containerOnlyReferenced/src/folder/index.ts b/tests/projects/containerOnlyReferenced/src/folder/index.ts new file mode 100644 index 0000000000..a65e423515 --- /dev/null +++ b/tests/projects/containerOnlyReferenced/src/folder/index.ts @@ -0,0 +1 @@ +export const x = 10; \ No newline at end of file diff --git a/tests/projects/containerOnlyReferenced/src/folder/tsconfig.json b/tests/projects/containerOnlyReferenced/src/folder/tsconfig.json new file mode 100644 index 0000000000..d54f4070fe --- /dev/null +++ b/tests/projects/containerOnlyReferenced/src/folder/tsconfig.json @@ -0,0 +1,6 @@ +{ + "files": ["index.ts"], + "compilerOptions": { + "composite": true + } +} \ No newline at end of file diff --git a/tests/projects/containerOnlyReferenced/src/folder2/index.ts b/tests/projects/containerOnlyReferenced/src/folder2/index.ts new file mode 100644 index 0000000000..a65e423515 --- /dev/null +++ b/tests/projects/containerOnlyReferenced/src/folder2/index.ts @@ -0,0 +1 @@ +export const x = 10; \ No newline at end of file diff --git a/tests/projects/containerOnlyReferenced/src/folder2/tsconfig.json b/tests/projects/containerOnlyReferenced/src/folder2/tsconfig.json new file mode 100644 index 0000000000..d54f4070fe --- /dev/null +++ b/tests/projects/containerOnlyReferenced/src/folder2/tsconfig.json @@ -0,0 +1,6 @@ +{ + "files": ["index.ts"], + "compilerOptions": { + "composite": true + } +} \ No newline at end of file diff --git a/tests/projects/containerOnlyReferenced/src/tsconfig.json b/tests/projects/containerOnlyReferenced/src/tsconfig.json new file mode 100644 index 0000000000..4d67b0f8be --- /dev/null +++ b/tests/projects/containerOnlyReferenced/src/tsconfig.json @@ -0,0 +1,10 @@ +{ + "files": [], + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "./folder" }, + { "path": "./folder2"} + ] + } \ No newline at end of file diff --git a/tests/projects/containerOnlyReferenced/tests/index.ts b/tests/projects/containerOnlyReferenced/tests/index.ts new file mode 100644 index 0000000000..a65e423515 --- /dev/null +++ b/tests/projects/containerOnlyReferenced/tests/index.ts @@ -0,0 +1 @@ +export const x = 10; \ No newline at end of file diff --git a/tests/projects/containerOnlyReferenced/tests/tsconfig.json b/tests/projects/containerOnlyReferenced/tests/tsconfig.json new file mode 100644 index 0000000000..987385d974 --- /dev/null +++ b/tests/projects/containerOnlyReferenced/tests/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": ["index.ts"], + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "../src" } + ] +} \ No newline at end of file diff --git a/tests/projects/containerOnlyReferenced/tsconfig.json b/tests/projects/containerOnlyReferenced/tsconfig.json new file mode 100644 index 0000000000..28ea2a4385 --- /dev/null +++ b/tests/projects/containerOnlyReferenced/tsconfig.json @@ -0,0 +1,10 @@ +{ + "files": [], + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "./src" }, + { "path": "./tests"} + ] +} \ No newline at end of file