jargon

Comparison

Dead code eliminationvsTree shaking

Dead code elimination

the branch behind `if (process.env.NODE_ENV !== 'production')` disappeared entirely from the output.

Removing code that can be proven unreachable after constants are substituted, done by the minifier rather than the module resolver. It is what makes development-only warnings free in production, and it is why build-time environment variables are inlined rather than read at runtime. It works inside a module; tree shaking works between modules, which is why both are needed and neither substitutes for the other.

Full entry →

Tree shaking

you import one function from a library and the other two hundred never reach the bundle.

Dropping exports that are never imported, using the static structure of ES modules to prove nothing references them. It works far less often than people assume: a CommonJS build, a re-export barrel, or a module the bundler cannot prove is side-effect free will all keep everything. Checking the analyser rather than trusting the term is the difference between an optimisation and a belief.

Full entry →

Related comparisons