readable-stream icon indicating copy to clipboard operation
readable-stream copied to clipboard

fix: circumvent issues with ESM process polyfills

Open WasabiThumb opened this issue 4 months ago • 2 comments

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 or process property of the import is indeed intended to polyfill node:process. The choice of nextTick here is arbitrary, however the method would be required for proper function of this package.

This also inherits the curiosity introduced by #497 where node:process is imported via process/.

WasabiThumb avatar Oct 14 '24 00:10 WasabiThumb