Logical assignment breaks --production build

Here is the error I get trying to build an app using the operator ??= with --production. Works fine without the --production flag.

Your app is crashing. Here's the latest log:

Started MongoDB.
Errors prevented startup:

While minifying app code:
packages/minifyStdJS/plugin/minify-js.js:96:26: Babili minification error within dynamic/imports/client/pdf.js:
imports/client/pdf.js

This experimental syntax requires enabling the parser plugin: 'logicalAssignment':

    cMapUrl ??= CMAP_URL;

  at maybeThrowMinifyErrorBySourceFile (packages/minifyStdJS/plugin/minify-js.js:96:26)
  at packages/minifyStdJS/plugin/minify-js.js:135:9
  at Array.forEach (<anonymous>)
  at MeteorBabelMinifier.processFilesForBundle (packages/minifyStdJS/plugin/minify-js.js:118:9)


While minifying app code:
packages/minifyStdJS/plugin/minify-js.js:96:26: Babili minification error within dynamic/imports/client/pdf.js:
imports/client/pdf.js

This experimental syntax requires enabling the parser plugin: 'logicalAssignment':

    cMapUrl ??= CMAP_URL;

  at maybeThrowMinifyErrorBySourceFile (packages/minifyStdJS/plugin/minify-js.js:96:26)
  at 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.

Two questions:

  • How does one configure babel to allow the use of logicalAssigment (this is a dynamic import, no idea if it matters)?
  • Also why is it talking about babili which was replaced by babel-minifier 4 years ago?

EDIT: same error with ||=.

1 Like

I believe this is fixed with the Meteor 2.3 release (see meteor-babel under Meteor version release in Meteor 2.3 Release Candidate (Node.js major upgrade)). The necessary preset was added to babel-preset-meteor@7.10.0 in Add @babel/plugin-proposal-logical-assignment-operators · meteor/babel-preset-meteor@7903d5e · GitHub. meteor-babel@7.11.0/@meteorjs/babel@7.11.1 includes that version with Update dependencies · meteor/babel@f23cb8d · GitHub. These versions were included in meteor with Meteor Babel 7.11.0 by StorytellerCZ · Pull Request #11411 · meteor/meteor · GitHub. I found them inside the source of Release release/METEOR@2.3-rc.2 · meteor/meteor · GitHub.

Yes, that should be the case, please give the RC a try to confirm.