04.7.4 · Skill in Developer experience

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.

Your status · Build systems

Saved in this browser. Sign in to keep it on every device.It colours this skill's tile on your map.

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

  1. Measure the build: the total time and the time of each step, locally and in CI.
  2. Cache by content. If the inputs have not changed, reuse the output. Hash the inputs; do not trust timestamps.
  3. Run independent steps in parallel.
  4. Use fast tools on the path you run most, such as a native bundler for development builds.
  5. Make builds reproducible: pinned versions, a lock file, and the same command locally and in CI.
  6. 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.

Bars

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 min

    The definitive explanation of continuous integration, recently revised, including what it is not.

Tools

2
Tools for Developer experience