Build a referenced project graph
A repository is split into library, application, and test projects with project references.
TypeScript · Command
tsc --build (or tsc -b) orchestrates TypeScript projects connected by project references. It discovers dependencies, checks freshness, and builds stale projects in dependency order.
tsc --build is a build orchestrator for TypeScript project references. It examines the supplied configuration projects, determines which are stale, orders dependencies before dependents, and builds only the projects that need work.
tsc --build [projects...] [options]
tsc -b [projects...] [options]| Name | Type | Description |
|---|---|---|
projects | string[] | One or more project configuration paths; a directory resolves to its tsconfig.json, and a conventional filename may be omitted. |
Builds out-of-date referenced projects and their dependencies; with management flags, it can instead report, clean, or force build work.
-b is the abbreviated spelling of --build.tsc does not build referenced dependencies; use --build when the dependency graph must be orchestrated.--dry previews the build without producing the build actions.mkdir -p build && printf '{"compilerOptions":{"composite":true,"outDir":"build"},"include":["src/**/*.ts"]}' > tsconfig.json && mkdir -p src && printf 'export const answer: number = 42;\n' > src/index.ts && tsc --build tsconfig.jsonCreates a composite TypeScript project and builds it with the project build mode.
A repository is split into library, application, and test projects with project references.
A large codebase needs to avoid recompiling projects whose outputs are current.
A developer wants to inspect planned work or remove generated outputs.
tsc --build do?It is TypeScript’s project build mode. It finds referenced projects, checks whether they are current, and builds stale projects in dependency order.
Follow-up: How can a build be previewed or forced? Use --dry to show planned work without building, and --force to treat every project as out of date.
You can pass several configuration paths, such as tsc -b src test. A tsconfig.json filename can be omitted when the configuration has that conventional name.
Follow-up: What happens if the paths are supplied in the wrong order? TypeScript reorders them so dependencies are built before dependents.
The command has a short alias: tsc -b. It can also accept build-management flags such as --verbose, --dry, --clean, and --force.
Follow-up: Which option removes generated outputs? --clean deletes outputs for the specified projects and can be combined with --dry.
Project Referencestsconfig.json--verbose--dry--clean--force