Skip to content

Commit 39271fa

Browse files
repl: deprecate repl.builtinModules
1 parent 8ccbfb6 commit 39271fa

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

doc/api/deprecations.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3849,6 +3849,22 @@ Type: Documentation-only
38493849
`process.features.tls_alpn`, `process.features.tls_ocsp`, and `process.features.tls_sni` are
38503850
deprecated, as their values are guaranteed to be identical to that of `process.features.tls`.
38513851

3852+
### DEP0190: `repl.builtinModules`
3853+
3854+
<!-- YAML
3855+
changes:
3856+
- version: REPLACEME
3857+
pr-url: https://github.com/nodejs/node/pull/57508
3858+
description: Documentation-only (supports [`--pending-deprecation`][]).
3859+
-->
3860+
3861+
Type: Documentation-only
3862+
3863+
The `node:repl` module exports a `builtinModules` property that contains an array
3864+
of built-in modules. This was incomplete and matched the already deprecated
3865+
`repl._builtinLibs` (DEP0142) instead it's better to rely
3866+
upon `require('node:module').builtinModules`.
3867+
38523868
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
38533869
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
38543870
[RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4

doc/api/repl.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,11 @@ with REPL instances programmatically.
646646

647647
<!-- YAML
648648
added: v14.5.0
649+
deprecated: REPLACEME
649650
-->
650651

652+
> Stability: 0 - Deprecated. Use `module.builtinModules` instead.
653+
651654
* {string\[]}
652655

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

lib/repl.js

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

18631863
ObjectDefineProperty(module.exports, 'builtinModules', {
18641864
__proto__: null,
1865-
get: () => _builtinLibs,
1866-
set: (val) => _builtinLibs = val,
1867-
enumerable: true,
1865+
get: pendingDeprecation ? deprecate(
1866+
() => require(''),
1867+
'repl.builtinModules is deprecated. Check module.builtinModules instead',
1868+
'DEP0190',
1869+
) : () => _builtinLibs,
1870+
set: pendingDeprecation ? deprecate(
1871+
(val) => _builtinLibs = val,
1872+
'repl.builtinModules is deprecated. Check module.builtinModules instead',
1873+
'DEP0190',
1874+
) : (val) => _builtinLibs = val,
1875+
enumerable: false,
18681876
configurable: true,
18691877
});
18701878

test/parallel/test-repl-options.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,17 @@ 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+
DEP0190: 'repl.builtinModules is deprecated. Check module.builtinModules instead',
3841
DEP0141: 'repl.inputStream and repl.outputStream are deprecated. ' +
39-
'Use repl.input and repl.output instead',
42+
'Use repl.input and repl.output instead',
4043
}
4144
});
4245

0 commit comments

Comments
 (0)