forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
esm: add runtime warning for specifier resolution flag
PR-URL: nodejs#42252 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Rich Trott <rtrott@gmail.com>
- Loading branch information
1 parent
c61fe77
commit bb3990f
Showing
4 changed files
with
44 additions
and
19 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
24 changes: 24 additions & 0 deletions
24
test/es-module/test-esm-specifiers-legacy-flag-warning.mjs
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,24 @@ | ||
import { mustCall } from '../common/index.mjs'; | ||
import { fileURL } from '../common/fixtures.mjs'; | ||
import { match, strictEqual } from 'assert'; | ||
import { spawn } from 'child_process'; | ||
import { execPath } from 'process'; | ||
|
||
// Verify experimental warning is printed | ||
const child = spawn(execPath, [ | ||
'--experimental-specifier-resolution=node', | ||
'--input-type=module', | ||
'--eval', | ||
`import ${JSON.stringify(fileURL('es-module-specifiers', 'package-type-module'))}`, | ||
]); | ||
|
||
let stderr = ''; | ||
child.stderr.setEncoding('utf8'); | ||
child.stderr.on('data', (data) => { | ||
stderr += data; | ||
}); | ||
child.on('close', mustCall((code, signal) => { | ||
strictEqual(code, 0); | ||
strictEqual(signal, null); | ||
match(stderr, /ExperimentalWarning: The Node\.js specifier resolution flag is experimental/); | ||
})); |