3 ms·
Does lodash support tree-shaking if you only import the utilities you require? Sounds like you probably don't need the obscure math Unicode bits.
by hughes 6y ago
Does lodash support tree-shaking if you only import the utilities you require? Sounds like you probably don't need the obscure math Unicode bits.
- city41 6y agoIt is possible to tree-shake Lodash. If that's not practical in this case, Lodash also ships individual function packages (for example: https://www.npmjs.com/package/lodash.isequal https://www.npmjs.com/package/lodash.isequal), as an alternative to tree shaking.
- flanbiscuit 6y agoLodash has deprecated these individual packages and they will be removed in v5: https://lodash.com/per-method-packages https://lodash.com/per-method-packages They recommend adding the main `lodash` package and then importing only the functions you need. import throttle from 'lodash/throttle`; I prefer using the `lodash-es` package for the reasons outlined in these 2 blog posts https://til.hashrocket.com/posts/dnzttruljf-prefer-lodash-es-when-using-webpack https://til.hashrocket.com/posts/dnzttruljf-prefer-lodash-es... https://itnext.io/lodash-es-vs-individual-lodash-utilities-size-comparison-676f14b07568 https://itnext.io/lodash-es-vs-individual-lodash-utilities-s...
- vcanales 6y agoIt's unlikely that they need lodash at all.
- eyelidlessness 6y agoI generally agree, and I actively dislike lodash in general, but getting people to stop using it hasn’t been especially fruitful and some devs/teams prefer it simply for consistency. Good luck with those particular windmills. Frickin jQuery is still in wide use.
- eyelidlessness 6y agoEven with the individual function modules being eliminated as discussed downthread, Rollup plugins are available to treat CJS as ESM and improve that tree shake.