module: include module information in require(esm) warning
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)
Review requested:
- [ ] @nodejs/loaders
CI: https://ci.nodejs.org/job/node-test-pull-request/63128/
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: |
Fixed linter complaint and Windows path quirks in tests
CI: https://ci.nodejs.org/job/node-test-pull-request/63176/
CI: https://ci.nodejs.org/job/node-test-pull-request/63230/
CI: https://ci.nodejs.org/job/node-test-pull-request/63233/
CI: https://ci.nodejs.org/job/node-test-pull-request/63250/
CI: https://ci.nodejs.org/job/node-test-pull-request/63251/
Landed in dacbfb1657afc578a6e3f9819825399016653078
backport in https://github.com/nodejs/node/pull/56927