Skip to content

module: derive builtinModules from enabled builtin set - #65418

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
sjungwon03:refactor/module-builtin-exposure
Aug 29, 2026
Merged

module: derive builtinModules from enabled builtin set#65418
nodejs-github-bot merged 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 involving general changes in the lib/ or src/ directories. 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 195 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.

@ljharb ljharb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i love this. drastically minimizes the chance the list will be wrong.

@daeyeon daeyeon added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. labels Aug 23, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 23, 2026
@nodejs-github-bot

This comment was marked as resolved.

@nodejs-github-bot

This comment was marked as resolved.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@daeyeon daeyeon added the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 29, 2026
@nodejs-github-bot
nodejs-github-bot merged commit 7b0de5e into nodejs:main Aug 29, 2026
76 of 77 checks passed
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 7b0de5e

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 29, 2026
panva pushed a commit that referenced this pull request Aug 29, 2026
test-module-builtin-experimental was added in #65418 asserting that
node:ffi is unavailable without --experimental-ffi, but #65475 had
already enabled node:ffi by default in builds with FFI support. The two
landed independently and broke main.

Expect node:ffi to behave like node:sqlite: available by default with
the node: scheme, and gone when opted out with --no-experimental-ffi.

Refs: #65418
Refs: #65475
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #65636
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
aduh95 pushed a commit that referenced this pull request Aug 29, 2026
Signed-off-by: sjungwon03 <sjungwon03@gmail.com>
PR-URL: #65418
Refs: #56185
Refs: #56870
Refs: #63158
Reviewed-By: Jordan Harband <ljharb@gmail.com>
aduh95 pushed a commit that referenced this pull request Aug 29, 2026
test-module-builtin-experimental was added in #65418 asserting that
node:ffi is unavailable without --experimental-ffi, but #65475 had
already enabled node:ffi by default in builds with FFI support. The two
landed independently and broke main.

Expect node:ffi to behave like node:sqlite: available by default with
the node: scheme, and gone when opted out with --no-experimental-ffi.

Refs: #65418
Refs: #65475
Signed-off-by: Matteo Collina <hello@matteocollina.com>
PR-URL: #65636
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. 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.

5 participants