TypeScript Build (tsb)
raw JSON → 3.1.0 verified Sat May 09 auth: no javascript
Extends the TypeScript compiler (tsc) with a configurable file copy step, allowing you to copy non-TypeScript assets (CSS, JSON, etc.) from source to output directories after a successful tsc build. Current stable version is 3.1.0. It operates in two modes: TSC mode (runs tsc with given arguments and then copies files) or Copy-only mode (only copies files based on tsbconfig.json). Key differentiator: it automatically follows TypeScript project references, looking for tsbconfig.json next to each referenced tsconfig.json. Requires Node >=14.16 and a peer dependency on typescript itself.
Common errors
error Error: Cannot find module 'typescript' ↓
cause typescript is a peer dependency, not installed automatically.
fix
Run 'npm install --save-dev typescript' (or add it to peerDependencies).
error tsb: error: unknown option `--watch' ↓
cause tsb does not pass --watch to tsc; copy step only works with --build.
fix
Use 'tsb --build' for building, or run 'tsc --watch' directly for watch mode (copy not supported).
error No tsbconfig.json found, skipping copy step. ↓
cause tsbconfig.json is missing or not in the project root.
fix
Create tsbconfig.json at the same directory where you run tsb.
Warnings
breaking v2.0.0 dropped support for Node < 10 and changed configuration format (was .tsbconfig, now tsbconfig.json). ↓
fix Migrate to tsbconfig.json and upgrade Node to >=10 (v3 requires >=14.16).
breaking v3.0.0 requires Node >=14.16 and dropped Node 10/12 support. ↓
fix Upgrade Node to >=14.16.
gotcha Copy step only runs when --build flag is provided. Without --build, tsb behaves exactly like tsc (no copying). ↓
fix Always include --build to trigger file copying.
gotcha Clean removes output directories entirely unless skipClean is true. This may delete files not produced by tsb. ↓
fix Set skipClean: true in tsbconfig.json to prevent deletion of output directories.
deprecated The old configuration file format (.tsbconfig) was removed in v2.0.0. ↓
fix Rename .tsbconfig to tsbconfig.json and update content.
Install
npm install typescript-build yarn add typescript-build pnpm add typescript-build Imports
- tsb (CLI command) wrong
npx tsc --buildcorrectnpx tsb --build
Quickstart
// 1. Install
npm install --save-dev typescript typescript-build
// 2. Create tsbconfig.json at project root
// {
// "copyFiles": [
// {
// "files": ["src/**/*.css"],
// "outDirectories": ["dist"],
// "up": 1
// }
// ]
// }
// 3. Run build
npx tsb --build
// This runs tsc --build first, then copies matched .css files to dist/