-
Notifications
You must be signed in to change notification settings - Fork 29.1k
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
esm: globals should be wrapped to stay in sync with ESM #29426
Conversation
|
// proxify the global process to keep in sync with ESM | ||
const mod = NativeModule.map.get('process'); | ||
mod.compileForPublicLoader(true); | ||
globalThis.process = mod.exports; |
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.
If this is done when ESM is not even used doesn't this just slow down access to globalThis.process
unconditionally?
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.
Yup, but that's how to keep ESM names synced
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.
I’m provisionally -1 as it’ll slow down access to process and it sits in a lot of hot paths (because of process.nextTick).
This needs a benchmark run on nextTick and stream at a minimum.
@mcollina the way that |
An alternative option is not to expose static export for the There is correlation between My overall assumption about ESM is that it should not slow down normal execution, while it could slow down application startup. This PR is going to affect execution. |
Could we internally us a non proxy instance (maybe via internal reference)? |
Shall we close this PR? |
closed in favor of #29737 |
This fixes the behavior of the builtin module proxy for
process
so thattest/parallel/test-global-setters.js
works even when ESM is turned on via--experimental-modules
by changing the global to use theProxy
form that ESM creates for named export syncing.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes