Documentation is
Explain in Detail
Hi! Can we please have some docs on how to do node polyfills in modern (Rolldown) vite?
I understand the project's decision not to do this automatically (since frontend packages should not be relying on node functions). But in reality, not all mainstream NPM packages have caught up, and node polyfills are still sometimes needed.
I think many in the community are relying on the vite-plugin-node-polyfills NPM package, but my impression is it's not being actively maintained or upgraded for rolldown-vite and Vite 8 (e.g. see recent bug tickets on security, optimizeDeps.esbuildOptions warnings, runtime error regression).
I've also seen projects using:
And recently found
- rolldown-plugin-node-polyfills, but it wasn't immediately clear to me if that's directly usable in Vite, or if it applies to both PROD and DEV builds.
Currently all I can find in the Vite docs is this statement, but no tips on how.
Your Suggestion for Changes
Could we please have an example / recommendation in the docs on how to add a polyfill for a node dependency (e.g. Buffer). That would really help me unblock two projects if vite-plugin-node-polyfills doesn't get some maintenance for Vite 8 support. Thank you!
Reproduction
https://vite.dev/guide/troubleshooting#module-externalized-for-browser-compatibility
Steps to reproduce
N/A (docs update request)
Documentation is
Explain in Detail
Hi! Can we please have some docs on how to do node polyfills in modern (Rolldown) vite?
I understand the project's decision not to do this automatically (since frontend packages should not be relying on node functions). But in reality, not all mainstream NPM packages have caught up, and node polyfills are still sometimes needed.
I think many in the community are relying on the vite-plugin-node-polyfills NPM package, but my impression is it's not being actively maintained or upgraded for
rolldown-viteandVite 8(e.g. see recent bug tickets on security,optimizeDeps.esbuildOptionswarnings, runtime error regression).I've also seen projects using:
optimizeDeps.esbuildOptions.plugins(presumably only relevant for dev server builds in older pre-rolldown versions of Vite)And recently found
Currently all I can find in the Vite docs is this statement, but no tips on how.
Your Suggestion for Changes
Could we please have an example / recommendation in the docs on how to add a polyfill for a node dependency (e.g.
Buffer). That would really help me unblock two projects ifvite-plugin-node-polyfillsdoesn't get some maintenance for Vite 8 support. Thank you!Reproduction
https://vite.dev/guide/troubleshooting#module-externalized-for-browser-compatibility
Steps to reproduce
N/A (docs update request)