0
  • Lodash@4.17.4

  • Webpack@3.8.1

  • babel@7

  • babel-plugin-lodash@3.3.2

    I use named imports when it comes to Lodash. I've configured @babel/preset-env with 'modules' set to false to prevent transpilation to Common JS and use 'lodash' as a plugin in the 'babel-loader' config. Despite all this, I realised my chunk has the entire Lodash, and is significantly bloating it up. What can I do to enable lodash from getting pruned? I am neither importing the entire library in my code , nor am I using chaining.

Community
  • 1
  • 1
Mayur Arora
  • 447
  • 5
  • 11

1 Answers1

-1

I maintain a library of (much) smaller versions of lodash functions. It is written using a modern build chain, so tree shaking should happen easily. You could check whether it has everything you need: micro-dash.

Eric Simonton
  • 5,702
  • 2
  • 37
  • 54
  • Got one question about micro-dash, does it support chaining methods like lodash 'chain' does? If yes, then how can we do it? – asdasd Dec 25 '22 at 17:56
  • @asdasd No, it does not. It is only loose functions (which makes it very tree-shakeable) – Eric Simonton Dec 26 '22 at 03:04