13 ms·
If we broadly include tree shaking (aka dead code elimination) in minification, then yes. They are often considered distinct transformations.
by fulafel 4y ago
If we broadly include tree shaking (aka dead code elimination) in minification, then yes. They are often considered distinct transformations.
- jsmith45 4y agoAt least in webpack, tree shaking and minimization are distinct, but BOTH include dead code elimination. For webpack tree shaking is the removal the declarations of exported values that are never imported. Further, imported values that were used used in functions such exported can be removed (although removing the last import from a file entirely requires knowing the imported file has no side effects). Separately to that the minimizer (terser) has its own dead code elimination process, that performs more in depth analysis. Terser cannot do the tree shaking part itself because of how webpack structures modules that Webpack was unable to concatenate, and because code slitting might make that live in a different file. But if webpack can eliminate unused exports and ensure that split files only access each other via exports, then terser can handleremaining dead code elimination within each module.