Skip to content

repl: deprecate repl.builtinModules #57508

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -3879,6 +3879,24 @@ Type: Runtime
When an `args` array is passed to [`child_process.execFile`][] or [`child_process.spawn`][] with the option
`{ shell: true }`, the values are not escaped, only space-separated, which can lead to shell injection.

### DEP0191: `repl.builtinModules`

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/57508
description: Documentation-only deprecation
with `--pending-deprecation` support.
-->

Type: Documentation-only (supports [`--pending-deprecation`][])

The `node:repl` module exports a `builtinModules` property that contains an array
of built-in modules. This was incomplete and matched the already deprecated
`repl._builtinLibs` ([DEP0142][]) instead it's better to rely
upon `require('node:module').builtinModules`.

[DEP0142]: #dep0142-repl_builtinlibs
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
[RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4
Expand Down
6 changes: 5 additions & 1 deletion doc/api/repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,14 @@ with REPL instances programmatically.

<!-- YAML
added: v14.5.0
deprecated: REPLACEME
-->

> Stability: 0 - Deprecated. Use [`module.builtinModules`][] instead.

* {string\[]}

A list of the names of all Node.js modules, e.g., `'http'`.
A list of the names of some Node.js modules, e.g., `'http'`.

## `repl.start([options])`

Expand Down Expand Up @@ -908,6 +911,7 @@ avoiding open network interfaces.
[`ERR_INVALID_REPL_INPUT`]: errors.md#err_invalid_repl_input
[`curl(1)`]: https://curl.haxx.se/docs/manpage.html
[`domain`]: domain.md
[`module.builtinModules`]: module.md#modulebuiltinmodules
[`process.setUncaughtExceptionCaptureCallback()`]: process.md#processsetuncaughtexceptioncapturecallbackfn
[`readline.InterfaceCompleter`]: readline.md#use-of-the-completer-function
[`repl.ReplServer`]: #class-replserver
Expand Down
14 changes: 11 additions & 3 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1858,9 +1858,17 @@ module.exports = {

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

Expand Down
3 changes: 3 additions & 0 deletions test/parallel/test-repl-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ const repl = require('repl');
const cp = require('child_process');

assert.strictEqual(repl.repl, undefined);

repl._builtinLibs; // eslint-disable-line no-unused-expressions
repl.builtinModules; // eslint-disable-line no-unused-expressions

common.expectWarning({
DeprecationWarning: {
DEP0142:
'repl._builtinLibs is deprecated. Check module.builtinModules instead',
DEP0191: 'repl.builtinModules is deprecated. Check module.builtinModules instead',
DEP0141: 'repl.inputStream and repl.outputStream are deprecated. ' +
'Use repl.input and repl.output instead',
}
Expand Down
Loading