jargon

Comparison

Barrel filevsTree shaking

Barrel file

you imported one icon from the package index and the build pulled in every icon it exports.

An `index` module that re-exports everything in a directory so consumers can import from one path. It is pleasant to write against and a well-known cause of bloat, because tree shaking through a large re-export chain often fails and because the module graph gains a node that depends on everything. Deep imports are uglier and reliably smaller.

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