module: trim off internal stack frames for require(esm) warnings

Trim off irrelevant internal stack frames for require(esm) warnings
so it's easier to locate where the call comes from when
--trace-warnings is used.

PR-URL: https://github.com/nodejs/node/pull/55496
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
This commit is contained in:
Joyee Cheung 2024-10-18 16:48:19 +02:00
parent 4354a1de0e
commit 3b3a95ac0c
4 changed files with 48 additions and 3 deletions

View file

@ -1389,7 +1389,10 @@ function loadESMFromCJS(mod, filename) {
messagePrefix = `${from} is loading ES Module ${to} using require().\n`;
}
}
emitExperimentalWarning('Support for loading ES Module in require()', messagePrefix);
emitExperimentalWarning('Support for loading ES Module in require()',
messagePrefix,
undefined,
parent?.require);
const {
wrap,
namespace,