Skip to content

Commit a127fc1

Browse files
repl: deprecate repl.builtinModules
Co-authored-by: Antoine du Hamel PR-URL: #57508 Reviewed-By: Juan José Arboleda Reviewed-By: Antoine du Hamel Reviewed-By: James M Snell Reviewed-By: Xuguang Mei Reviewed-By: Ruben Bridgewater Reviewed-By: Yagiz Nizipli Reviewed-By: Zijian Liu
1 parent c41facb commit a127fc1

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

doc/api/deprecations.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3749,6 +3749,24 @@ Type: Documentation-only
37493749
When an `args` array is passed to [`child_process.execFile`][] or [`child_process.spawn`][] with the option
37503750
`{ shell: true }`, the values are not escaped, only space-separated, which can lead to shell injection.
37513751

3752+
### DEP0191: `repl.builtinModules`
3753+
3754+
3761+
3762+
Type: Documentation-only (supports [`--pending-deprecation`][])
3763+
3764+
The `node:repl` module exports a `builtinModules` property that contains an array
3765+
of built-in modules. This was incomplete and matched the already deprecated
3766+
`repl._builtinLibs` ([DEP0142][]) instead it's better to rely
3767+
upon `require('node:module').builtinModules`.
3768+
3769+
[DEP0142]: #dep0142-repl_builtinlibs
37523770
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
37533771
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
37543772
[RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4

doc/api/repl.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,11 +666,14 @@ with REPL instances programmatically.
666666

667667
670671

672+
> Stability: 0 - Deprecated. Use [`module.builtinModules`][] instead.
673+
671674
* {string\[]}
672675

673-
A list of the names of all Node.js modules, e.g., `'http'`.
676+
A list of the names of some Node.js modules, e.g., `'http'`.
674677

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

@@ -929,6 +932,7 @@ avoiding open network interfaces.
929932
[`ERR_INVALID_REPL_INPUT`]: errors.md#err_invalid_repl_input
930933
[`curl(1)`]: https://curl.haxx.se/docs/manpage.html
931934
[`domain`]: domain.md
935+
[`module.builtinModules`]: module.md#modulebuiltinmodules
932936
[`process.setUncaughtExceptionCaptureCallback()`]: process.md#processsetuncaughtexceptioncapturecallbackfn
933937
[`readline.InterfaceCompleter`]: readline.md#use-of-the-completer-function
934938
[`repl.ReplServer`]: #class-replserver

lib/repl.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,9 +1860,17 @@ module.exports = {
18601860

18611861
ObjectDefineProperty(module.exports, 'builtinModules', {
18621862
__proto__: null,
1863-
get: () => _builtinLibs,
1864-
set: (val) => _builtinLibs = val,
1865-
enumerable: true,
1863+
get: pendingDeprecation ? deprecate(
1864+
() => _builtinLibs,
1865+
'repl.builtinModules is deprecated. Check module.builtinModules instead',
1866+
'DEP0191',
1867+
) : () => _builtinLibs,
1868+
set: pendingDeprecation ? deprecate(
1869+
(val) => _builtinLibs = val,
1870+
'repl.builtinModules is deprecated. Check module.builtinModules instead',
1871+
'DEP0191',
1872+
) : (val) => _builtinLibs = val,
1873+
enumerable: false,
18661874
configurable: true,
18671875
});
18681876

test/parallel/test-repl-options.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ const repl = require('repl');
2929
const cp = require('child_process');
3030

3131
assert.strictEqual(repl.repl, undefined);
32+
3233
repl._builtinLibs; // eslint-disable-line no-unused-expressions
34+
repl.builtinModules; // eslint-disable-line no-unused-expressions
3335

3436
common.expectWarning({
3537
DeprecationWarning: {
3638
DEP0142:
3739
'repl._builtinLibs is deprecated. Check module.builtinModules instead',
40+
DEP0191: 'repl.builtinModules is deprecated. Check module.builtinModules instead',
3841
DEP0141: 'repl.inputStream and repl.outputStream are deprecated. ' +
3942
'Use repl.input and repl.output instead',
4043
}

0 commit comments

Comments
 (0)