repl: deprecate repl.builtinModules

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/57508
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
This commit is contained in:
Dario Piotrowicz 2025-04-05 14:40:18 +01:00 committed by GitHub
parent e739559e46
commit e232b4a69a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 37 additions and 4 deletions

View File

@ -3882,6 +3882,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

View File

@ -666,11 +666,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])`
@ -929,6 +932,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

View File

@ -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,
});

View File

@ -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',
}