Skip to content

module: runtime deprecate module.register()#62401

Open
GeoffreyBooth wants to merge 2 commits intonodejs:mainfrom
GeoffreyBooth:runtime-deprecate-module-register
Open

module: runtime deprecate module.register()#62401
GeoffreyBooth wants to merge 2 commits intonodejs:mainfrom
GeoffreyBooth:runtime-deprecate-module-register

Conversation

@GeoffreyBooth
Copy link
Member

Building on #62395, this runtime-deprecates module.register().

I’m not sure when we want to land and release this; I think the options are basically either:

  1. When module.registerHooks() goes stable, hopefully sometime before 26 goes LTS; module: doc-deprecate module.register() #62395 (comment)
  2. In 26.0.0; the doc-deprecation is backported to the 25.x line, and the runtime deprecation is 26+; module: doc-deprecate module.register() #62395 (comment)

I’m opening this now in case the team wants to do the second option. cc @nodejs/loaders @nodejs/userland-migrations

@GeoffreyBooth GeoffreyBooth added the loaders Issues and PRs related to ES module loaders label Mar 23, 2026
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/userland-migrations

@nodejs-github-bot nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. labels Mar 23, 2026
@GeoffreyBooth GeoffreyBooth force-pushed the runtime-deprecate-module-register branch from c5ce15e to 77638cb Compare March 23, 2026 03:18
@GeoffreyBooth GeoffreyBooth added dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. dont-land-on-v25.x PRs that should not land on the v25.x-staging branch and should not be released in v25.x. labels Mar 23, 2026
@GeoffreyBooth GeoffreyBooth force-pushed the runtime-deprecate-module-register branch from 77638cb to 1a08254 Compare March 23, 2026 03:51
@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.67%. Comparing base (8199f9c) to head (1a08254).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62401      +/-   ##
==========================================
- Coverage   89.69%   89.67%   -0.03%     
==========================================
  Files         676      676              
  Lines      206693   206704      +11     
  Branches    39577    39582       +5     
==========================================
- Hits       185402   185361      -41     
- Misses      13435    13489      +54     
+ Partials     7856     7854       -2     
Files with missing lines Coverage Δ
lib/internal/modules/esm/loader.js 98.78% <100.00%> (+0.01%) ⬆️

... and 33 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.

Copy link
Member

@AugustinMauroy AugustinMauroy left a comment

Choose a reason for hiding this comment

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

In general that seem good.

);

function register(specifier, parentURL = undefined, options) {
emitRegisterDeprecation();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
emitRegisterDeprecation();
emitRegisterDeprecation();

separate core logic & deprecation by space


[`module.register()`][] is deprecated. Use [`module.registerHooks()`][]
instead.

Copy link
Member

Choose a reason for hiding this comment

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

we should add small paragraph that exaplain why and what is the gap between theses api mainly one is only async and the other can do both

Copy link

@themavik themavik left a comment

Choose a reason for hiding this comment

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

getDeprecationWarningEmitter + emitRegisterDeprecation() in lib/internal/modules/esm/loader.js lines up with DEP0205 docs. nit: new regression in test/es-module/test-esm-register-deprecation.mjs only counts [DEP0205] substrings — if stderr ever gains unrelated DEP0205 text, the “once per process” check could skew (unlikely).

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

I think we should aim for 26.x, so we can actually drop in 27

Comment on lines +961 to +969
const emitRegisterDeprecation = getDeprecationWarningEmitter(
'DEP0205',
'`module.register()` is deprecated. Use `module.registerHooks()` instead.',
undefined,
false,
);

function register(specifier, parentURL = undefined, options) {
emitRegisterDeprecation();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const emitRegisterDeprecation = getDeprecationWarningEmitter(
'DEP0205',
'`module.register()` is deprecated. Use `module.registerHooks()` instead.',
undefined,
false,
);
function register(specifier, parentURL = undefined, options) {
emitRegisterDeprecation();
let emittedRegisterWarning = false;
function register(specifier, parentURL = undefined, options) {
if (!emittedRegisterWarning) {
process.emitWarning(
'`module.register()` is experimental and planned to be removed. Use `module.registerHooks()` instead.',
'ExperimentalWarning',
);
emittedRegisterWarning = true;
}

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

Labels

dont-land-on-v20.x PRs that should not land on the v20.x-staging branch and should not be released in v20.x. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. dont-land-on-v25.x PRs that should not land on the v25.x-staging branch and should not be released in v25.x. esm Issues and PRs related to the ECMAScript Modules implementation. loaders Issues and PRs related to ES module loaders needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants