webpack: Incompatible with unmodified lodash-es

When connecting to lodash-es, webpack and/or the babel-loader fails until you edit jsnext:main to just main - I have the babel-loader set to translate all modules (as I am using es6 across the board). For now, I’m just manually patching lodash-es in the node_modules directory, but it seems like this is probably just a simple issue in node dependency parsing.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 20 (17 by maintainers)

Most upvoted comments

@sokra Is there a command line form of resolve.packageMains?

Also, I’m noticing the cherry-picking (auto tree shaking) isn’t working for the edge version of lodash-es with webpack 2 (master branch)

First clone into node_modules:

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

with test.js:

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

then:

webpack --display-chunks --display-modules --display-origins test.js bundle.js

Also using the -p param failed with:

ERROR in bundle.js from UglifyJs
Unexpected token punc «[», expected punc «:» [./~/lodash-es/array.default.js:62,0]