Hi, I’ve tried to use lodash-es in Meteor project but without the success. I’m getting the following error on the client:
=> Errors prevented startup:
While minifying app code:
packages/minifyStdJS/plugin/minify-js.js:96:26: Babili minification error within packages/modules.js:
node_modules/lodash-es/add.js, line 22
Only one default export allowed per module.:
export default add;
at maybeThrowMinifyErrorBySourceFile (packages/minifyStdJS/plugin/minify-js.js:96:26)
at files.forEach.file (packages/minifyStdJS/plugin/minify-js.js:135:9)
at Array.forEach (<anonymous>)
at MeteorBabelMinifier.processFilesForBundle (packages/minifyStdJS/plugin/minify-js.js:118:9)
=> Your application has errors. Waiting for file change.
or this one on the server:
W20171102-16:38:37.698(1)? (STDERR) packages/modules.js:395
W20171102-16:38:37.699(1)? (STDERR) export { default as add } from './add.js';
W20171102-16:38:37.700(1)? (STDERR) ^^^^^^
W20171102-16:38:37.700(1)? (STDERR)
W20171102-16:38:37.701(1)? (STDERR) SyntaxError: Unexpected token export
W20171102-16:38:37.701(1)? (STDERR) at /Users/jagi/workspace/meteor/test/.meteor/local/build/programs/server/boot.js:392:18
W20171102-16:38:37.703(1)? (STDERR) at Array.forEach (<anonymous>)
W20171102-16:38:37.703(1)? (STDERR) at Function._.each._.forEach (/Users/jagi/.meteor/packages/meteor-tool/.1.6.0.smovct++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20171102-16:38:37.704(1)? (STDERR) at /Users/jagi/workspace/meteor/test/.meteor/local/build/programs/server/boot.js:220:5
W20171102-16:38:37.705(1)? (STDERR) at /Users/jagi/workspace/meteor/test/.meteor/local/build/programs/server/boot.js:463:5
W20171102-16:38:37.706(1)? (STDERR) at Function.run (/Users/jagi/workspace/meteor/test/.meteor/local/build/programs/server/profile.js:510:12)
W20171102-16:38:37.706(1)? (STDERR) at /Users/jagi/workspace/meteor/test/.meteor/local/build/programs/server/boot.js:462:11
I know that Meteor is using Reify for managing imports/exports and probably I can’t use ES npm modules and I have to transpile them which is really sad.
I was also curious if Meteor does tree-shaking and I’ve just read this in a blog post:
Tracing import statements and tree-shaking are also impossible because Meteor wants to be backwards compatible with pre-1.3 versions.
So my question is, what direction is MDG heading if it goes about ES modules support?
Why I’m asking this question is because I want to create NPM module that I will use in Meteor apps but also with other build systems like Rollup or Webpack. So I was investigating this problem and trying decide what module import/export syntax (or transpilation technique) to use. When, I’m transpiling my code using Babel then such a package works great with Meteor and other build systems but tree-shaking is impossible. Of course I could use files/methods cherry-picking like it’s done in lodash
but it also has its downsides, so the best option would be using pure ES modules but apparently they are not supported in Meteor. Any thoughts?