This may not chiefly be an issue with vite-plugin-node-polyfills, but it has been observed that in combination with readable-stream and vite that the process polyfill causes errors due to being used as if it is not an ES module, or conversely, not having its default export properly unwrapped. The purpose of this issue is to hopefully help narrow down the code that could least intrusively be updated to fix this incompatibility, for instance (and not primarily), changing vite-plugin-node-polyfills to export a CJS shim via export = process in addition to a default export¹.
¹ Something like (and attempt to fight the urge to vomit) this:
export = Object.assign(process, { process, default: process })
Any insight, especially on how Vite handles ES module interop in combination with this plugin, would be greatly appreciated. :heart:
Summary
Cross-post of readable-stream #539 (for which a reproducible example was made, also on GitHub Pages) May be related to #98.
This may not chiefly be an issue with
vite-plugin-node-polyfills
, but it has been observed that in combination withreadable-stream
andvite
that theprocess
polyfill causes errors due to being used as if it is not an ES module, or conversely, not having its default export properly unwrapped. The purpose of this issue is to hopefully help narrow down the code that could least intrusively be updated to fix this incompatibility, for instance (and not primarily), changingvite-plugin-node-polyfills
to export a CJS shim viaexport = process
in addition to a default export¹.¹ Something like (and attempt to fight the urge to vomit) this:
Any insight, especially on how Vite handles ES module interop in combination with this plugin, would be greatly appreciated. :heart: