Build systems
The tooling that compiles, bundles and packages code.
Build systems turn source code into something that runs. Slow or flaky builds waste time every day. Understanding the build helps with performance, caching and debugging strange errors.
Why it matters for a product engineer
The build runs many times a day, for every engineer and for every CI run. A slow build slows every change. A flaky one teaches people to retry instead of reading the error. A product engineer who understands the build can fix strange errors, make bundles smaller and keep feedback fast.
How to do it
- Measure the build: the total time and the time of each step, locally and in CI.
- Cache by content. If the inputs have not changed, reuse the output. Hash the inputs; do not trust timestamps.
- Run independent steps in parallel.
- Use fast tools on the path you run most, such as a native bundler for development builds.
- Make builds reproducible: pinned versions, a lock file, and the same command locally and in CI.
- Read what the bundle contains, and why. Keep the whole build well under Fowler’s ten-minute guideline.
Common mistakes
- Cache keys based on timestamps or branch names, which give stale or missed results.
- A build that works only on one machine.
- Ignoring warnings until there are hundreds of them.
- A new plugin for every small need.
Example
esbuild was written to show that web build tools could be 10 to 100 times faster. Its FAQ gives the reasons. It is written in Go and compiles to native code, so no JavaScript engine has to read the bundler’s own code first. It uses every CPU core for parsing and code generation, and its threads share memory. And it was written from scratch, with performance in mind from the start.
Time to bundle 10 copies of three.js, from scratch
- esbuild0.39 s
- Parcel 214.91 s
- Rollup 4 + Terser34.1 s
- webpack 541.21 s
The same production bundle, with minification and source maps, takes under half a second or over 40. Nothing is cached, so the difference is the tool.
Reportedesbuild's own benchmark, esbuild.github.io
Sources: Why is esbuild fast? (esbuild FAQ) ↗ · Continuous integration (Martin Fowler) ↗
Resources
1- articleGo deeper
Continuous integration ↗
Martin Fowler · 60 minThe definitive explanation of continuous integration, recently revised, including what it is not.
Tools
2- ToolFreemium
GitHub Actions
CI/CD built into GitHub, for running tests, checks and deployments on every change.
- ToolOpen source
Renovate
Open-source bot that opens pull requests to keep dependencies up to date.