Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Is this needed with Webpack 2 stable? #157

@andresgutgon

Description

@andresgutgon

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

image

All lodash universe

image

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions