4 ms·
Except in my experience (and others as well) the tree shaking hasn't been working.
by Vevolut 10y ago
Except in my experience (and others as well) the tree shaking hasn't been working.
- boubiyeah 10y agoStrange, I have it working with rc3. I have an ES6 module exporting tons of Array utils. I definitely see the build size fluctuate depending on whether I import 1, 2, etc of these util functions, whether with webpack 1 (or most bundling tool apart from rollup) I would pay the entire file's price upfront.
- frio 10y agoThe problem with tree-shaking is that it's recursive -- every module has to do it properly, and at the moment, I'd wager most frontend modules in NPM don't. If I responsibly say `import { map } from 'lodash'`;, but (say) my frontend rendering library says `import _ from 'lodash'; _.map(things, func);`, then unfortunately, transitively, I'll still get all of lodash.
- jdd 10y agoYou might be able to fix that with something like babel-plugin-lodash which can be ran over your code (and deps) to enforce cherry-picking across the board. https://github.com/lodash/babel-plugin-lodash https://github.com/lodash/babel-plugin-lodash
- frio 10y agoLate reply, but, neat! I'll have a look.