react-pdf icon indicating copy to clipboard operation
react-pdf copied to clipboard

Rollup "browser" build includes "Node.js" dependencies

Open kaheglar opened this issue 3 years ago • 3 comments

Describe the bug The following is included in the bundle when building a browser bundle with rollup.

import require$$1$1 from 'events';

To Reproduce See workspace - https://stackblitz.com/edit/node-9tjqve?file=dist/index.js

Expected behavior No Node.js dependencies included in the bundle when building a browser bundle with rollup.

kaheglar avatar Aug 30 '22 11:08 kaheglar

Which react-pdf version are you using?

ghost avatar Aug 30 '22 11:08 ghost

3.0.0 The issue is recreated here https://stackblitz.com/edit/node-9tjqve?file=dist%2Findex.js

kaheglar avatar Aug 30 '22 12:08 kaheglar

Agree that this is an issue, I'm using Vite which uses Rollup under the hood. Found an easy workaround thankfully. Just install the events package from npm which someone had the foresight to create. It's just a browser compatible version of the Node one.

https://www.npmjs.com/package/events

jamesmfriedman avatar Sep 19 '22 14:09 jamesmfriedman

If anyone is having this issue still, I solved it by using the rollup-plugin-polyfill-node plugin.

wuelcas avatar Mar 21 '23 22:03 wuelcas