#53547: refactor: register Electron's js2c bundles as internal Node builtins
Description of Change
Electron's framework bundles were registered with Node as electron/js2c/<name>. Node treats every builtin id that does not start with internal/ as public, so they showed up in require('module').builtinModules, and require('node:electron/js2c/browser_init') / process.getBuiltinModule('electron/js2c/browser_init') would load and run the browser init bundle in whatever process asked, which under ELECTRON_RUN_AS_NODE dereferences a null ElectronBrowserClient and crashes. That was only ever "needed" because Node's runMain had to be able to load the bundle by id; with #53537 running the bundles from the embedder callback nothing requires them to be public.
The bundles are now emitted under gen/internal/electron/js2c/, so js2c registers them as internal/electron/js2c/<name>: they disappear from builtinModules, require/getBuiltinModule return ERR_UNKNOWN_BUILTIN_MODULE/undefined for them like any other internal id, and parallel/test-process-get-builtin (which iterates builtinModules) passes and comes off the disabled list. The visible side effect is that stack frames inside Electron's bundles read node:internal/electron/js2c/browser_init instead of node:electron/js2c/browser_init.
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
-
npm testpasses
Release Notes
Notes: Electron's internal JavaScript bundles are no longer listed in require('module').builtinModules or loadable through process.getBuiltinModule().
Backports
Semver Impact
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron