-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: circumvent issues with ESM process polyfills #543
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening a PR! Can you please add a unit test?
Sorry for the delay! I've added the task |
This is strange- despite using the reprex as a reference, the test does not break when commenting out the patching functionality of the shim introduced by this PR. It's possible that the issue only crops up when the Vite source is TypeScript, since that's the only obvious difference. I may have to consider updating the test to use TypeScript- or perhaps throw this all out and consider it a TypeScript issue. EDIT: Or maybe Vite is caching the version of EDIT 2: Made the apparent version change randomly from run to run in an attempt to bust any caches that may exist; same behavior. |
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
"nextTick" in require("node:process")["default"] || "nextTick" in require("node:process")["process"]
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.This also inherits the curiosity introduced by #497 where
node:process
is imported viaprocess/
.