3 ms·
It won't. UglifyJS's dead code elimination is snake oil and mirrors anywhere but in the most trivial of cases. See: - https://github.com/webpack/webpack/issue
by dmitriid 9y ago
It won't. UglifyJS's dead code elimination is snake oil and mirrors anywhere but in the most trivial of cases.
See:
- https://github.com/webpack/webpack/issues/2867 https://github.com/webpack/webpack/issues/2867
- https://github.com/webpack/webpack/issues/4784 https://github.com/webpack/webpack/issues/4784
(Note: webpack doesn't do any dead code elimination, it relies on UglifyJS to do so)
- aurbano 9y agoThose are good links to interesting discussions on the topic, I guess UglifyJS is better than nothing although you're right there. Are you aware of any alternative that can do tree shaking? Reading those issues' comments there is a link to babel-webpack-tree-shaking [1] which seems to do it? [1] https://github.com/Aladdin-ADD/babel-webpack-tree-shaking https://github.com/Aladdin-ADD/babel-webpack-tree-shaking
- dmitriid 9y agoRollup [1] seems to be pretty good at tree-shaking and apparently babel's babili minifier [2] is better than UglifyJS (but I guess it's too early to tell) But both come with their own tradeoffs: Rollup is ES6 only and doesn't support certain features from TC39's Stage 3. Babili is very very new :) [1] https://rollupjs.org https://rollupjs.org [2] https://github.com/babel/minify https://github.com/babel/minify