Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repl.builtinModules doesn't contain all node.js builtin modules #57504

Open
dario-piotrowicz opened this issue Mar 16, 2025 · 5 comments · May be fixed by #57508
Open

repl.builtinModules doesn't contain all node.js builtin modules #57504

dario-piotrowicz opened this issue Mar 16, 2025 · 5 comments · May be fixed by #57508

Comments

@dario-piotrowicz
Copy link
Contributor

dario-piotrowicz commented Mar 16, 2025

Version

23.8.0

Platform

Ubuntu Mate 24.04.2 LTS (Linux 6.8.0-55-generic x86_64)

Subsystem

repl

What steps will reproduce the bug?

Run

node -e 'console.log(require("node:repl").builtinModules)'

and

node -e 'console.log(require("node:module").builtinModules)'

and notice how the modules printed in the first command are only a subset of those printed by the second

As you can see here:
screenshot of the two commands run in a terminal

How often does it reproduce? Is there a required condition?

It can be always reproduced and there is no required condition

What is the expected behavior? Why is that the expected behavior?

According to the REPL documentation (permalink) repl.builtinModules should contains a list of the names of all Node.js modules

What do you see instead?

Only a subset of the list

Additional information

  • (unless I'm mistaken) repl.builtinModules is basically just the same thing as the deprecated and removed repl._builtinLibs, in its deprecation note it is also stated that the list was incomplete

  • Modules not included in repl.builtinModules are available in the repl itself (e.g. node:test and node:sea)
    (so it's not like repl.builtinModules includes only modules available in the repl)

  • The deprecation note does recommend to use require('node:module').builtinModules instead, so maybe repl.builtinModules should just be deprecated and removed?

@dario-piotrowicz dario-piotrowicz changed the title repl.builtinModules doesn't contain all node.js builtin modules repl.builtinModules doesn't contain all node.js builtin modules Mar 16, 2025
@aduh95
Copy link
Contributor

aduh95 commented Mar 16, 2025

  • The deprecation note does recommend to use require('node:module').builtinModules instead, so maybe repl.buildinModules should just be deprecated and removed?

SGTM, would you like to send a PR?

@dario-piotrowicz
Copy link
Contributor Author

  • The deprecation note does recommend to use require('node:module').builtinModules instead, so maybe repl.buildinModules should just be deprecated and removed?

SGTM, would you like to send a PR?

Yes for sure! I'll get to it right away, but could you clarify the plan here? is the idea to land this as a breaking change for v24 and leave it as is in v23?

Or if it makes sense I can fix and deprecating it in v23 and remove it altogether in v24, if that's not too much overhead

But I am not sure how to do that (2 PRs one for v23 and one for v24?) could you advice me on how to proceed in this regard? 🙂 🙏

@dario-piotrowicz
Copy link
Contributor Author

Actually sorry it's my bad, _builtinLibs has been deprecated but not actually removed:

node/lib/repl.js

Lines 1871 to 1885 in ab9660b

ObjectDefineProperty(module.exports, '_builtinLibs', {
__proto__: null,
get: pendingDeprecation ? deprecate(
() => _builtinLibs,
'repl._builtinLibs is deprecated. Check module.builtinModules instead',
'DEP0142',
) : () => _builtinLibs,
set: pendingDeprecation ? deprecate(
(val) => _builtinLibs = val,
'repl._builtinLibs is deprecated. Check module.builtinModules instead',
'DEP0142',
) : (val) => _builtinLibs = val,
enumerable: false,
configurable: true,
});

So if we want to follow that I guess the correct solution here is to just deprecate repl.builtinModules instead of remove it altogether, right? 🤔

@aduh95
Copy link
Contributor

aduh95 commented Mar 16, 2025

The first step is to doc-deprecate it, you can check the history of deprecations.md for examples

@dario-piotrowicz dario-piotrowicz linked a pull request Mar 16, 2025 that will close this issue
@dario-piotrowicz
Copy link
Contributor Author

@aduh95 thanks, done 🙂👍

Please have a look: #57508 🙏

PS: the PR is only deprecating the field, I can update the PR to also fix it (basically making it an alias to module.builtinModules), should I? 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants