Skip to content

tree-shaking with lodash-es #1750

@jdalton

Description

@jdalton

See #1612 (comment).
Currently tree-shaking lodash-es modules is not possible with webpack 2 beta.

First clone into node_modules:

git clone -b es --depth=1 https://github.com/lodash/lodash.git ./node_modules/lodash-es

then:

npm i -g webpack@beta

then:

npm i babel-loader@^5 babel-core@^5

with test.js:

import { chunk } from 'lodash-es';
console.log(chunk([1,2,3,4], 2));

then:

webpack ./test.js ./bundle.js -p --display-chunks --display-modules --display-origins --module-bind js=babel-loader?blacklist[]=es6.modules

is

> gzip-size bundle.js | pretty-bytes
30.41 kB

While the output of import { chunk } from 'lodash-es/array/chunk'
is

> gzip-size bundle.js | pretty-bytes
1.19 kB

Related to rollup/rollup#45

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions