-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(NODE-7306): Replace global process with import node:process #4820
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
base: main
Are you sure you want to change the base?
Conversation
|
Are you sure you want this? How does it reduce runtime dependencies? globals are generally much easier to polyfill (/existing polyfills already handle them), so this seems counterintuitive. The vast majority of these are accesses to |
This is one of the intentions of this doc, to remove the dependence on a global process: Design: Remove dependence on runtime specific APIs.
This change itself doesn't, but it allows bundlers to supplant the variable consistently.
The |
That line is perhaps ill informed, I wrote that with some experience bundling the driver being more difficult when needing to replace a global vs an imported module, since importing had a clearer entry point for the stub. This was in the very early stages of the driver bundling project when it was more of a hackathon project. I defer to @addaleax on what is actually easier to achieve now that the driver stubbing is more isolated. If I recall a sticking point was that the I do think that the |
Description
Summary of Changes
The driver will explicitly import node:process instead of relying on the global.
eslint rule
no-restricted-globalsis also enabled.What is the motivation for this change?
This helps us reduce our runtime dependencies, as part of https://jira.mongodb.org/browse/NODE-6601
Release Highlight
Replaced global process with node-specific process
This forces an explicit require and doesn't use
global.process, allowing bundlers to supplant the variable consistently.Double check the following
npm run check:lint)type(NODE-xxxx)[!]: descriptionfeat(NODE-1234)!: rewriting everything in coffeescript