Build a Turborepo pipeline
Turborepo speeds up monorepo builds by running tasks in dependency order and caching their results so unchanged work is never repeated. The brain of that system is turbo.json, where you declare each task and how it relates to others. This builder generates a correct turbo.json for the standard build, test, lint, and dev tasks.
How it works
Each entry under tasks describes one runnable script. dependsOn controls ordering: a plain name like build means an in-package dependency, while a ^build caret means “run this task in all dependency packages first” — that topological ordering is what makes Turborepo correct for inter-package builds.
outputs is a list of globs Turbo saves to its cache after a successful run, like dist/** or .next/**. On a later run with the same inputs, Turbo restores those files instantly instead of re-running the task. Setting cache: false opts a task out of caching, which you want for dev. Marking a task persistent: true tells Turbo it never exits, which is required for watch and dev servers.
At the top level, globalEnv and globalDependencies add inputs to every task’s cache hash, so changing NODE_ENV or a root tsconfig.json correctly invalidates all caches.
Tips and notes
- Always pair a cached
buildwith anoutputsglob, or the cache restores nothing. - Use
^buildforbuildso dependency packages compile first. - Set
cache: falseandpersistent: truefordev. - This file uses the
taskskey (Turborepo 2.x); rename topipelinefor 1.x.