[SOLVED] Error at production build step with bundle-visualizer: unknown: Cannot read property 'add' of undefined while minifying

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).

Still while commenting the d3-array/cumsum dependent code:

  • 2.3 no error
  • 2.3.1 Cannot read property 'add' of undefined while minifying dynamic/node_modules/pdfjs-dist/build/pdf.js
  • 2.3.2 Cannot read property 'add' of undefined while minifying dynamic/node_modules/pdfjs-dist/build/pdf.js
  • 2.3.3 Cannot read property 'add' of undefined while minifying dynamic/node_modules/pdfjs-dist/build/pdf.js
  • 2.3.4 Cannot read property 'add' of undefined while minifying dynamic/node_modules/pdfjs-dist/build/pdf.js
  • 2.3.5 Cannot read property 'add' of undefined while minifying dynamic/node_modules/pdfjs-dist/build/pdf.js

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.

Any other test I could run to help you?

Could you create a small reproduction so that we can debug the same code base?

OK! I’ll ping you when that is done.

1 Like

@storyteller Here it is:

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

@storyteller Same result with METEOR@2.3.6:

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

@storyteller Any progress?

I’m experiencing this as well when I upgraded from METEOR@2.0

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.

Even all the way back in 2.0? That is new.

@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.

Sorry I wasn’t clear. It did not happen in 2.0, it occurred when I upgraded from 2.0.

Give a try to this PR: https://github.com/meteor/meteor/pull/11630

Can you guide me on how to run this branch in an new project and in an existing project?

The package patch has been release so just get the latest packages at this point.

Here are the steps for future reference:

1 Like

@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.

1 Like