node icon indicating copy to clipboard operation
node copied to clipboard

repl: avoid deprecated `require.extensions` in tab completion

Open gulbaki opened this issue 6 months ago β€’ 3 comments

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:

  • this.context.require.extensions β†’ Module._extensions in the REPL complete() function
  • Adds an inline comment explaining the deprecation and replacement
  • No functional behavior change

Fixes: https://github.com/nodejs/node/issues/58641

gulbaki avatar Jun 09 '25 21:06 gulbaki

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

It's not runtime deprecated (doc only) so it's not possible to capture the experimental warning

marco-ippolito avatar Jun 10 '25 16:06 marco-ippolito

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.14%. Comparing base (905a722) to head (5cb5079). Report is 71 commits behind head on main.

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     
Files with missing lines Coverage Ξ”
lib/repl.js 95.13% <100.00%> (ΓΈ)

... and 36 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Jun 11 '25 13:06 codecov[bot]

CI: https://ci.nodejs.org/job/node-test-pull-request/67409/

nodejs-github-bot avatar Jun 11 '25 13:06 nodejs-github-bot

Landed in dcfdaab13aa674d88712ca853551fb432dcc77c8

nodejs-github-bot avatar Jun 23 '25 06:06 nodejs-github-bot