Skip to content

repl: avoid deprecated require.extensions in tab completion #58653

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
merged 3 commits into from
Jun 23, 2025
Merged
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,11 @@ function complete(line, callback) {
filter = completeOn;
if (this.allowBlockingCompletions) {
const subdir = match[2] || '';
const extensions = ObjectKeys(this.context.require.extensions);
// `require.extensions` is runtime-deprecated (DEP0039).
// Use `Module._extensions` to access the same extension map
// without triggering the deprecation warning.
const Module = require('module');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving this to the top of the file.

const extensions = ObjectKeys(Module._extensions);
const indexes = ArrayPrototypeMap(extensions,
(extension) => `index${extension}`);
ArrayPrototypePush(indexes, 'package.json', 'index');
Expand Down