Project graph scaling
Concept and boundary
Project references divide work into dependency-ordered builds. A clean build and a warm incremental build can differ in work; compare identical inputs and report build state. This finite build checks separate outputs; the follow-up workshop asks for repeated builds, not a promised performance gain.
Accepted project
Create a fresh folder with exactly these files. Use TypeScript 5.8.3 and Node.js 22.16.0. Package stubs under node_modules are local teaching fixtures, not installed dependencies.
app/tsconfig.json
{ "compilerOptions": { "composite": true, "strict": true, "types": [], "rootDir": ".", "outDir": "../dist/app" }, "files": [ "index.ts" ], "references": [ { "path": "../lib" } ]}lib/tsconfig.json
{ "compilerOptions": { "composite": true, "strict": true, "declaration": true, "types": [], "rootDir": ".", "outDir": "../dist/lib" }, "files": [ "index.ts" ]}tsconfig.json
{ "compilerOptions": { "strict": true, "target": "ES2022", "module": "CommonJS", "moduleResolution": "Node10", "moduleDetection": "force", "skipLibCheck": true, "noEmitOnError": true, "types": [] }, "include": [ "**/*" ], "exclude": [ "node_modules", "dist", "build", "cache" ], "files": [], "references": [ { "path": "./app" } ]}From the project root run: tsc -b tsconfig.json --pretty false.
Compilation succeeds (exit 0).
No runtime execution is required for this check.
dist/lib/index.d.ts exists.
Contains "n: number".
dist/app/index.d.ts exists.
Contains "result: number".
Rejected project — diagnosis
Intentionally rejected variant. Do not execute it.
Use a fresh copy of the accepted project, changing only the files shown below.
From the project root run: tsc -b tsconfig.json --pretty false.
Expected compiler diagnostic: TS2322
No runtime execution is required for this check.
A changed upstream type still causes a dependent diagnostic. Restore the accepted configuration/source to compare the result.
Independent comparison: warm-build
The script builds the same graph twice and checks that the second verbose build reports up-to-date projects. Elapsed time is not used as a pass criterion.
Create a fresh folder with exactly these files. Use TypeScript 5.8.3 and Node.js 22.16.0. Package stubs under node_modules are local teaching fixtures, not installed dependencies.
app/tsconfig.json
{ "compilerOptions": { "composite": true, "strict": true, "types": [], "rootDir": ".", "outDir": "../dist/app" }, "files": [ "index.ts" ], "references": [ { "path": "../lib" } ]}lib/tsconfig.json
{ "compilerOptions": { "composite": true, "strict": true, "declaration": true, "types": [], "rootDir": ".", "outDir": "../dist/lib" }, "files": [ "index.ts" ]}tsconfig.json
{ "compilerOptions": { "strict": true, "target": "ES2022", "module": "CommonJS", "moduleResolution": "Node10", "moduleDetection": "force", "skipLibCheck": true, "noEmitOnError": true, "types": [] }, "include": [ "**/*" ], "exclude": [ "node_modules", "dist", "build", "cache" ], "files": [], "references": [ { "path": "./app" } ]}const {spawnSync}=require("node:child_process");const assert=require("node:assert/strict");function build(){const p=spawnSync("tsc",["-b","tsconfig.json","--verbose","--pretty","false"],{encoding:"utf8"});assert.equal(p.status,0,p.stdout+p.stderr);return p.stdout;}const first=build();const second=build();assert.match(second,/up to date/i);console.log("warm build up to date");From the project root run: tsc -b tsconfig.json --dry --pretty false.
Compilation succeeds (exit 0).
Run node warm.cjs. Expected stdout:
warm build up to datePractice and recap
Run tsc -b --verbose twice without changes, then edit lib and compare the messages.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Project graph scaling — knowledge check
Check the concept, interpret the tested project result, and diagnose a rejected configuration or source.
Which statement correctly describes Project graph scaling?
Using the complete accepted project and the exact command in the lesson, which result is expected?
Why does the rejected project fail under its stated configuration?
What is the result of the independent warm-build comparison?