I am attempting to upgrade to meteor@2.4-rc.0 from meteor@2.2.3. Development with meteor run works fine. I am getting the following stack trace when running the bundle-visualizer:
$ meteor run --extra-packages bundle-visualizer --production
...
=> Errors prevented startup:
While minifying app code:
packages/minifyStdJS/plugin/minify-js.js:49:25: terser minification error (SyntaxError:Unexpected token: punc (.))
Source file: node_modules/pdfjs-dist/build/pdf.js (2165:21)
Line content: if (arguments[0]?.annotationStorage !== undefined) {
at maybeThrowMinifyErrorBySourceFile (packages/minifyStdJS/plugin/minify-js.js:49:25)
at packages/minifyStdJS/plugin/minify-js.js:77:11
at Array.forEach (<anonymous>)
at MeteorMinifier.processFilesForBundle (packages/minifyStdJS/plugin/minify-js.js:66:11)
While minifying app code:
packages/minifyStdJS/plugin/minify-js.js:49:25: terser minification error (SyntaxError:Unexpected token: punc (.))
Source file: node_modules/pdfjs-dist/build/pdf.js (2165:21)
Line content: if (arguments[0]?.annotationStorage !== undefined) {
at maybeThrowMinifyErrorBySourceFile (packages/minifyStdJS/plugin/minify-js.js:49:25)
at packages/minifyStdJS/plugin/minify-js.js:77:11
at Array.forEach (<anonymous>)
at MeteorMinifier.processFilesForBundle (packages/minifyStdJS/plugin/minify-js.js:66:11)
=> Your application has errors. Waiting for file change.
...
That is definitely strange since optional chaining is supported. Could you maybe try recompiling the package to see if that helps (not a solution, but looking for simple workarounds first).
@aureooms Could you make a simple reproduction so that we have a common codebase to debug?
Also could you try to recompile pdfjs-dist. Terser supports optional chaining from 5.2 and we are on 4.8 so I’m wondering what is going on here as maybe the input is not in the correct format.
meteor create --release 2.4-rc.3 meteor-2.4-rc.3
cd meteor-2.4-rc.3
meteor npm i
meteor --production # OK
meteor npm i --save pdfjs-dist
echo "import pdfjs from 'pdfjs-dist';" >> client/main.jsx
echo "console.debug(pdfjs);" >> client/main.jsx
meteor --production # NOT OK
Errors prevented bundling: 47:3: Please do not use display: contents; if you have grid setting enabled
While minifying app code:
packages/minifyStdJS/plugin/minify-js.js:49:25: terser minification error (SyntaxError:Unexpected token: name (package))
Source file: packages/iron_core/lib/iron_core.js (258:29)
Line content: Iron.utils.debug = function (package) {
It seems that the minifier expects strict mode JS, but that is not always true for old packages.
@storyteller I did a last attempt with 2.4.1 today and got the same error. I did not try to change terser’s version by hand. I chose the easy route and went straight for Meteor 2.5.0 which works! I consider this a SOLVED problem.