refactor(ext/node): merge 02_init.js into 01_require.js#34035
Merged
Conversation
Drop the separate `02_init.js` module by inlining its content into
`01_require.js`. Along the way:
- Remove the `internals.requireImpl` bridge namespace — both files now
live in the same module, so `setUsesLocalNodeModulesDir` collapses
to a direct assignment and `nativeModuleExports` is a local
reference. The dead `setInspectBrk` and `Module` keys go away too.
- Remove the unused `loadCjsModule` helper.
- Replace the nested `internals.node = { closeIdleConnections }`
handle with a flat `internals.closeIdleConnections`, and update the
test runner script string accordingly. `closeIdleConnections` is the
only consumer of that namespace.
- Move the top-level `bindStreamsLazy(console, process)` call into
`initialize`'s non-warmup branch. It only matters for `node:console`
consumers, which can't run until after bootstrap anyway.
- Update `esm_entry_point` to `node:module` and drop `02_init.js`
from the esm list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
The Node polyfill init was split across two files for historical
reasons:
01_require.jsdefinedModuleand the require machinery,then handed a
requireImplbridge object over to02_init.js, whichdid the actual
nodeBootstrapsetup. Inspecting the bridge shows thatmost of it was either dead (the
loadCjsModulehelper had no callers,which made the
ModuleandsetInspectBrkkeys it depended on deadtoo) or pure indirection (
setUsesLocalNodeModulesDirflipping amodule-level boolean,
nativeModuleExportsgetting passed through).This collapses the two files into one.
internals.requireImplisgone, the dead helper and handles are gone, the nested
internals.node = { closeIdleConnections }(whose sole consumer isthe test runner) flattens to
internals.closeIdleConnections, andthe top-level
bindStreamsLazycall moves into the non-warmup branchof
initialize— onlynode:consoleconsumers observe it and theycan't run until after bootstrap. The extension's
esm_entry_pointnow points at
node:modulesince02_init.jsno longer exists.