Skip to content

module: derive builtinModules from enabled builtin set - #65418

Open
sjungwon03 wants to merge 1 commit into
nodejs:mainfrom
sjungwon03:refactor/module-builtin-exposure
Open

module: derive builtinModules from enabled builtin set#65418
sjungwon03 wants to merge 1 commit into
nodejs:mainfrom
sjungwon03:refactor/module-builtin-exposure

Conversation

@sjungwon03

Copy link
Copy Markdown
Contributor

Module.builtinModules is expected to contain only builtins accessible
to user code.

During pre-execution, each experimental flag determines whether its
builtin is added to BuiltinModule's user-requirable set via
BuiltinModule.allowRequireByUsers().

Before this change, getAllBuiltinModuleIds() added every scheme-only
builtin to the Module.builtinModules candidate list, including
experimental builtins that had not been added to the user-requirable
set. initializeCJS() then repeated the flag checks and removed
node:dtls, node:quic, node:ffi, and node:vfs.

Derive the scheme-only portion of Module.builtinModules from the
already-established user-requirable set instead. This keeps the list
consistent with the existing require('node:...') access policy and
removes the duplicated filtering in initializeCJS().

Existing scheme-only builtins such as node:test, node:sea, and
node:sqlite remain listed.

Add coverage for Module.builtinModules and require('node:...')
with and without each experimental flag.

Refs: #56185
Refs: #56870
Refs: #63158

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/startup

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run. labels Aug 20, 2026
Signed-off-by: sjungwon03 <sjungwon03@gmail.com>
@sjungwon03
sjungwon03 force-pushed the refactor/module-builtin-exposure branch from 614500e to 79ffed7 Compare August 20, 2026 08:31
@sjungwon03

Copy link
Copy Markdown
Contributor Author

Follow-up: the focused test assumed that node:sqlite is available in
all builds. Slim builds can be compiled without SQLite, so the test now
only verifies node:sqlite when common.hasSQLite is true.

node:test and node:sea remain covered unconditionally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib / src Issues and PRs related to general changes in the lib or src directory. module Issues and PRs related to the module subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants