Glossary / Incremental builds
Incremental builds
Incremental builds perform only the work affected by changes since a previous build, using dependency graphs, timestamps, hashes, or compiler state to avoid rebuilding everything. They improve developer feedback and CI efficiency, but require reliable dependency tracking and a clean-build escape hatch.
Dependency graph and invalidation
A build system models tasks and inputs. When a source, configuration, dependency, or upstream output changes, it invalidates affected tasks and recomputes downstream results. TypeScript project references and build mode can emit and reuse project metadata; bundlers and monorepo tools maintain their own caches and graphs. Timestamp-based invalidation can be fragile across file copies, while content hashing is more robust but costs computation.
Incremental state can become stale or incompatible after tool upgrades, configuration changes, branch switches, or interrupted builds. Generated files accidentally included as inputs can create loops or nondeterminism. A successful incremental build should produce the same relevant outputs as a clean build.
Engineering guidance
Define task inputs/outputs, keep generated artifacts out of source globs, and version caches when toolchain semantics change. Provide clean/rebuild commands and validate representative clean builds in CI. Track whether incremental mode saves time and ensure failures are surfaced rather than silently reusing partial output.
Interview questions
- What enables incremental builds? A dependency graph and a way to detect changed inputs and invalidate downstream work.
- Why can stale outputs occur? Missing dependencies, broken invalidation, or incompatible cached state.
- Hash vs timestamp? Hashes identify content changes more reliably; timestamps may be faster but have filesystem edge cases.
- How verify correctness? Compare clean and incremental outputs for representative changes.
- What is a common generated-file problem? It gets treated as source input and creates cycles or noisy invalidation.