This repository was archived by the owner on Sep 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 98
Is this needed with Webpack 2 stable? #157
Copy link
Copy link
Closed
Labels
Description
What?
Hi, first of all thank you for all your hard work. Is amazing all the effort you're putting on make lodash modular and produce smaller bundles.
I'm trying to understand Webpack 2 tree shaking. First my versions:
"webpack": "2.2.1",
"lodash": "^4.17.4",
With those options I'm trying this code:
// picking map
import _map from 'lodash/map';
const mapAdd = _map([1, 2, 3], (item) => item + 1);
console.log('result', mapAdd);
// All lodash universe
import _ from 'lodash';
const mapAdd = _.map([1, 2, 3], (item) => item + 1);
console.log('result', mapAdd);
Results
Look at yellow line. Vendor bundle
Picking map
All lodash universe
It's pretty cool. Looks like some tree shaking is happening in my webpack 😄
The thing is that I tried babel-plugin-lodash putting this on my .babelrc
:
{
"presets": [
["es2015", { "modules": false }],
"react"
],
"plugins": [
"lodash",
"...more"
]
}
But the results are the same. Is that normal?
Is important to highlight that ["es2015", { "modules": false }]
is fundamental to make tree shaking work on Webpack 2. Right?