Bug: process polyfill causes issues by virtue of being an ES module
WasabiThumb opened this issue · 1 comments
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 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. ❤️