OK. I made wrong assumptions. Here is what I can reproduce on the 2.2.x range:
2.2 with typescript (I had just added typescript to the project without running meteor update) or typescript@4.2.2: no error
2.2.1 with typescript@4.2.2: d3-array/cumsum error
2.2.2 with typescript@4.2.2: d3-array/cumsum error
2.2.3 with typescript@4.3.5: no error
I cannot combine for instance 2.2.1 with typescript@4.3.5 since this errors due to incompatible versions.
If I comment out the code dependent on d3-array/cumsum it goes through without errors, so this does not seem related to the problem I am having with pdfjs-dist.
PS: All other explicit version ranges stayed the same (.meteor/packages, .meteor/versions, and package.json).
2.2.3 was after the Node upgrade focused on fixing that d3-array error which was an error in Babel which they were constantly fixing and reverting.
It is strange that the error appeared going to 2.3.1. Though there was update to @babel/runtime. This to me suggest that maybe there might an input change to the terser which produces theses issues…
Here is how I proceeded: I ran meteor update --release 2.x.y then meteor run --extra-packages bundle-visualizer --production for each version in increasing order. I ran meteor npm ci when updating from 2.2.x to 2.3 since the NodeJS version changed.
meteor create --release 2.3.5 meteor-2.3.5
cd meteor-2.3.5
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
Same outcome with TypeScript:
meteor create --release 2.3.5 --typescript meteor-2.3.5-typescript
cd meteor-2.3.5-typescript
meteor npm i
meteor --production # OK
meteor npm i --save pdfjs-dist
echo "import pdfjs from 'pdfjs-dist';" >> client/main.tsx
echo "console.debug(pdfjs);" >> client/main.tsx
meteor --production # NOT OK
meteor create --release 2.3.6 meteor-2.3.6
cd meteor-2.3.6
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
@storyteller Mmh. Same problem with METEOR@2.2.3, which is the one I am running without problem in my app…
meteor create --release 2.2.3 meteor-2.2.3
cd meteor-2.2.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
Sorry no progress so far except ruling out the usual workarounds. Next I will try playing with the terser version to see if there wasn’t a regression of some sorts.
@aureooms I have tried with the latest terser and that seems to fix the issue. I’ll submit a PR soon.
A bit of a discussion will have to be had if it is OK to release as a patch or if it is going to be a feature release for the next Meteor release.
@storyteller I did a last attempt with 2.3.7 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.