Yes
N/A (but yes)
test, lodash, es module
node -v: v8.4.0npm -v: 5.3.0yarn --version: 0.27.5npm ls react-scripts: 1.0.10lodash-esimport { flatten } from 'lodash-es';npm testTest passes.
Test fails due to ES module syntax in lodash-es causing a syntax error.

From what I understand, this happens because Jest doesn't do Babel transforms on any node_modules (as configured here). And because Node doesn't support ES modules yet, it causes syntax error.
Not sure about the fix. The only idea I can come up with is to add popular libraries that are ES modules (are there others apart from lodash-es?) to the regex pattern (maybe like this).
We realize this is sub-optimal, and hope Node adds official support for ES Modules soon. This should make things easier, but not immediately.
The most appropriate answer I can give you currently is to not use lodash-es; packages which are published and are expected to work in a Node environment must be shipped in commonjs.
The usage of ES Modules is often enchanting because it promises to trim bundle sizes, but it hardly happens in practice (this is changing in the future; current static analysis limitations).
You'd be better off requiring just the bits you need [from lodash].
In the current state of the ecosystem, Node and webpack considered, packages should be shipped as commonjs, with their commonjs entry point specified in the main of package.json.
For packages who wish to ship a ES Modules build of their module, they should ship them in addition to their commonjs source files, under the module field in package.json (not as a separate package, like lodash-es). Note that these sources must be compiled, meaning they should not use any ES6+ syntax.
In the future, packages may be able to define an esnext field in package.json which says "compile me", so that package authors may ship an uncompiled version of their package (and with modules, basically anything stage 3+).
We realize this is sub-optimal, and hope Node adds official support for ES Modules soon. This should make things easier, but not immediately.
The most appropriate answer I can give you currently is to not use
lodash-es; packages which are published and are expected to work in a Node environment _must_ be shipped incommonjs.
The usage of ES Modules is often enchanting because it promises to trim bundle sizes, but it hardly happens in practice (this is changing in the future; current static analysis limitations).You'd be better off requiring just the bits you need [from
lodash].In the current state of the ecosystem, Node and webpack considered, packages should be shipped as
commonjs, with theircommonjsentry point specified in themainofpackage.json.For packages who wish to ship a ES Modules build of their module, they should ship them in _addition_ to their
commonjssource files, under themodulefield inpackage.json(not as a separate package, likelodash-es). Note that these sources must be compiled, meaning they should not use any ES6+ syntax.In the future, packages may be able to define an
esnextfield inpackage.jsonwhich says "compile me", so that package authors may ship an uncompiled version of their package (and with modules, basically anything stage 3+).
Thanks @Timer
I would like to add that the correct json property for the es6 dist is the esnext, not the module
Most helpful comment
We realize this is sub-optimal, and hope Node adds official support for ES Modules soon. This should make things easier, but not immediately.
The most appropriate answer I can give you currently is to not use
lodash-es; packages which are published and are expected to work in a Node environment must be shipped incommonjs.The usage of ES Modules is often enchanting because it promises to trim bundle sizes, but it hardly happens in practice (this is changing in the future; current static analysis limitations).
You'd be better off requiring just the bits you need [from
lodash].In the current state of the ecosystem, Node and webpack considered, packages should be shipped as
commonjs, with theircommonjsentry point specified in themainofpackage.json.For packages who wish to ship a ES Modules build of their module, they should ship them in addition to their
commonjssource files, under themodulefield inpackage.json(not as a separate package, likelodash-es). Note that these sources must be compiled, meaning they should not use any ES6+ syntax.In the future, packages may be able to define an
esnextfield inpackage.jsonwhich says "compile me", so that package authors may ship an uncompiled version of their package (and with modules, basically anything stage 3+).