OnedocLabs / react-print-pdf

Build and generate PDF using React 📄 UI kit for PDFs and print documents. Simple, reusable components and templates to create great invoices, docs, brochures. Use your favorite front-end framework React to build your next PDF.
https://docs.fileforge.com/react-print/welcome/getting-started
Apache License 2.0
2.11k stars 62 forks source link

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

Open hexcowboy opened 2 months ago

hexcowboy commented 2 months ago

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?

Titou325 commented 2 months ago

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!