node icon indicating copy to clipboard operation
node copied to clipboard

module: include module information in require(esm) warning

Open joyeecheung opened this issue 1 year ago • 5 comments

When emitting the experimental warning for require(esm), include information about the parent module and the module being require()-d to help users locate and update them.

For example, when using npm which relies on debug which attempts to load supports-color using require():

$ cd tools/doc
$ ../../node ../../deps/npm/bin/npm-cli.js install

npm warn cli npm v10.9.0 does not support Node.js v23.0.0-pre. This version of npm supports the following node versions: `^18.17.0 || >=20.5.0`. You can find the latest version at https://nodejs.org/.
(node:88340) ExperimentalWarning: CommonJS module /Users/joyee/projects/node/deps/npm/node_modules/debug/src/node.js is loading ES Module /Users/joyee/projects/node/deps/npm/node_modules/supports-color/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

joyeecheung avatar Oct 15 '24 19:10 joyeecheung

Review requested:

  • [ ] @nodejs/loaders

nodejs-github-bot avatar Oct 15 '24 19:10 nodejs-github-bot

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

nodejs-github-bot avatar Oct 15 '24 20:10 nodejs-github-bot

Codecov Report

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

Project coverage is 88.42%. Comparing base (bbdfeeb) to head (24d7d4e). Report is 845 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #55397    +/-   ##
========================================
  Coverage   88.41%   88.42%            
========================================
  Files         652      653     +1     
  Lines      186612   187458   +846     
  Branches    36062    36084    +22     
========================================
+ Hits       165001   165752   +751     
- Misses      14885    14954    +69     
- Partials     6726     6752    +26     
Files with missing lines Coverage Δ
lib/internal/modules/cjs/loader.js 97.59% <100.00%> (+0.16%) :arrow_up:
lib/internal/util.js 96.97% <100.00%> (+0.10%) :arrow_up:

... and 177 files with indirect coverage changes

codecov[bot] avatar Oct 15 '24 21:10 codecov[bot]

Fixed linter complaint and Windows path quirks in tests

joyeecheung avatar Oct 18 '24 12:10 joyeecheung

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

nodejs-github-bot avatar Oct 18 '24 12:10 nodejs-github-bot

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

nodejs-github-bot avatar Oct 21 '24 13:10 nodejs-github-bot

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

nodejs-github-bot avatar Oct 21 '24 15:10 nodejs-github-bot

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

nodejs-github-bot avatar Oct 22 '24 09:10 nodejs-github-bot

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

nodejs-github-bot avatar Oct 22 '24 12:10 nodejs-github-bot

Landed in dacbfb1657afc578a6e3f9819825399016653078

nodejs-github-bot avatar Oct 22 '24 16:10 nodejs-github-bot

backport in https://github.com/nodejs/node/pull/56927

joyeecheung avatar Feb 06 '25 01:02 joyeecheung