-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: #55496 Backport-PR-URL: #55217 Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Refs: #52697
- Loading branch information
1 parent
28b5b9a
commit 16119f2
Showing
4 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
// This checks the warning and the stack trace emitted by the require(esm) | ||
// experimental warning. It can get removed when `require(esm)` becomes stable. | ||
|
||
require('../common'); | ||
const { spawnSyncAndAssert } = require('../common/child_process'); | ||
const fixtures = require('../common/fixtures'); | ||
const assert = require('assert'); | ||
|
||
spawnSyncAndAssert(process.execPath, [ | ||
'--trace-warnings', | ||
fixtures.path('es-modules', 'require-module.js'), | ||
], { | ||
trim: true, | ||
stderr(output) { | ||
const lines = output.split('\n'); | ||
assert.match( | ||
lines[0], | ||
/ExperimentalWarning: CommonJS module .*require-module\.js is loading ES Module .*message\.mjs/ | ||
); | ||
assert.strictEqual( | ||
lines[1], | ||
'Support for loading ES Module in require() is an experimental feature and might change at any time' | ||
); | ||
assert.match( | ||
lines[2], | ||
/at require \(.*modules\/helpers:\d+:\d+\)/ | ||
); | ||
assert.match( | ||
lines[3], | ||
/at Object\.<anonymous> \(.*require-module\.js:1:1\)/ | ||
); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require('./message.mjs'); |