Cannot run @react-pdf/renderer


React PDF renderer is relying on a few polyfills, like “zlib”. I believe Meteor should automatically load them using “meteor-node-stubs”, however it doesn’t seem to work out of the box.

I always end up with “Cannot find module ‘zlib’” client-side, indicating that the module is not polyfilled.

I tried to force an import “import zlib from ‘zlib’”, in case this could have been related to Meteor not finding this dependency. But I still get the error message.

Any hint how I could debug this and make sure zlib is polyfilled client-side?

Have you tried installing all the shims required as indicated?

e.g. browserify-zlib

It doesn’t seem to work at the moment. Also it affects only the production build as far as I can tell, not dev. Is Meteor doing some additional things during dev, like adding more polyfills?
Using a dynamic import limit the issue to the page that triggers the import but we still have the same problem when we reach this page and @react-pdf is loaded

What bothers me is that I have no equivalent to the proposed webpack setup in Meteor, it’s supposed to be automated via meteor-node-stubs but then it’s not transparent for us and we can’t debug those polyfill out :frowning:

I used an alias via npm package

npm i stream@npm:stream-browserify
(to do with other packages if necessary)

1 Like