readable-stream
readable-stream copied to clipboard
fix: circumvent issues with ESM process polyfills
Would resolve #539. This is a hacky solution that may preferrably be made obsolete by resolution of davidmyersdev/vite-plugin-node-polyfills#106.
The root issue is that some node:process
polyfills export an ES module that is not unwrapped at runtime. This change would introduce a patch that conditionally unwraps the module in the event that checks pass indicating that it is wrapped. Those checks are:
-
require("node:process")["__esModule"] === true
- Intent is to quickly eliminate false positives
-
"nextTick" in require("node:process")["default"] || "nextTick" in require("node:process")["process"]
- Indicates that the
default
orprocess
property of the import is indeed intended to polyfillnode:process
. The choice ofnextTick
here is arbitrary, however the method would be required for proper function of this package.
- Indicates that the
This also inherits the curiosity introduced by #497 where node:process
is imported via process/
.