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

Vite bundler warnings for "stream" and "events" nodejs modules

Open hexcowboy opened this issue 1 year ago • 1 comments

When bundling with Vite, we are seeings some warnings

[plugin:vite:resolve] Module "stream" has been externalized for browser compatibility, imported by "/project/node_modules/through/index.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin:vite:resolve] Module "stream" has been externalized for browser compatibility, imported by "/project/node_modules/multipipe/index.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin:vite:resolve] Module "stream" has been externalized for browser compatibility, imported by "/project/node_modules/html-tokenize/node_modules/readable-stream/readable.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin:vite:resolve] Module "events" has been externalized for browser compatibility, imported by "/project/node_modules/html-tokenize/node_modules/readable-stream/lib/_stream_readable.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin:vite:resolve] Module "stream" has been externalized for browser compatibility, imported by "/project/node_modules/html-tokenize/node_modules/readable-stream/lib/_stream_readable.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin:vite:resolve] Module "stream" has been externalized for browser compatibility, imported by "/project/node_modules/html-tokenize/node_modules/readable-stream/lib/_stream_writable.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin:vite:resolve] Module "events" has been externalized for browser compatibility, imported by "/project/node_modules/duplexer2/node_modules/readable-stream/lib/_stream_readable.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin:vite:resolve] Module "events" has been externalized for browser compatibility, imported by "/project/node_modules/duplexer2/node_modules/readable-stream/lib/internal/streams/stream-browser.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.

What is the recommendation for these warnings? It seems like we haven't had any issues in Firefox or Chrome, but I'm assuming some browsers won't provide these modules. Should we be polyfilling them?

hexcowboy avatar May 09 '24 12:05 hexcowboy

Hey @hexcowboy, thanks for bringing that up!

The stream implementation isn't needed in the current state of the library and it is safe to ignore across browsers. However, we will take a look at how we can treeshake to remove the need for them in the first place.

Thanks!

Titou325 avatar May 09 '24 16:05 Titou325