process: add process.getBuiltinModule(id)#52762
Closed
joyeecheung wants to merge 7 commits intonodejs:mainfrom
Closed
process: add process.getBuiltinModule(id)#52762joyeecheung wants to merge 7 commits intonodejs:mainfrom
joyeecheung wants to merge 7 commits intonodejs:mainfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
process.getBuiltinModule(id)provides a way to load built-in modulesin a globally available function. ES Modules that need to support
other environments can use it to conditionally load a Node.js built-in
when it is run in Node.js, without having to deal with the resolution
error that can be thrown by
importin a non-Node.js environment orhaving to use dynamic
import()which either turns the module intoan asynchronous module, or turns a synchronous API into an asynchronous one.
If
idspecifies a built-in module available in the current Node.js process,process.getBuiltinModule(id)method returns the corresponding built-inmodule. If
iddoes not correspond to any built-in module,undefinedis returned.
process.getBuiltinModule(id)accepts built-in module IDs that are recognizedby
module.isBuiltin(id).The references returned by
process.getBuiltinModule(id)always point tothe built-in module corresponding to
ideven if users modifyrequire.cacheso thatrequire(id)returns something else.Fixes: #52599