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.

@codecov

codecov Bot commented Aug 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.12%. Comparing base (55e4ca3) to head (79ffed7).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #65418      +/-   ##
==========================================
- Coverage   90.14%   90.12%   -0.02%     
==========================================
  Files         752      752              
  Lines      251870   252321     +451     
  Branches    47365    47441      +76     
==========================================
+ Hits       227037   227404     +367     
- Misses      16177    16216      +39     
- Partials     8656     8701      +45     
Files with missing lines Coverage Δ
lib/internal/bootstrap/realm.js 96.36% <100.00%> (+0.06%) ⬆️
lib/internal/modules/cjs/loader.js 98.22% <100.00%> (+0.07%) ⬆️

... and 58 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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