-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, thanks for the PR @gulbaki 😃🙏
I've left a couple of small comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also include a test for this? Here is an example of how I tested process warnings: https://github.com/nodejs/node/blob/main/test/parallel/test-process-warnings.mjs
lib/repl.js
Outdated
// `require.extensions` is runtime-deprecated (DEP0039). | ||
// Use `Module._extensions` to access the same extension map | ||
// without triggering the deprecation warning. | ||
const Module = require('module'); |
There was a problem hiding this comment.
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.
It's not runtime deprecated (doc only) so it's not possible to capture the experimental warning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🙂
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #58653 +/- ##
==========================================
- Coverage 90.15% 90.14% -0.01%
==========================================
Files 636 636
Lines 188040 188057 +17
Branches 36903 36895 -8
==========================================
- Hits 169535 169532 -3
- Misses 11239 11278 +39
+ Partials 7266 7247 -19
🚀 New features to boost your workflow:
|
This PR replaces the usage of require.extensions in the REPL autocompletion logic with Module._extensions.
require.extensions has been runtime-deprecated under DEP0039, and its usage triggers a warning in recent Node.js versions. Since require.extensions is just a user-land alias for Module._extensions, we can safely access the same object via Module._extensions without any behavioral change or deprecation warning.
Changes:
Fixes: #58641