-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
esm: disable non-js exts outside package scopes
PR-URL: #30501 Reviewed-By: Jan Krems <[email protected]> Reviewed-By: Myles Borins <[email protected]>
- Loading branch information
1 parent
d9efc7d
commit 250a995
Showing
3 changed files
with
38 additions
and
22 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,21 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const { spawn } = require('child_process'); | ||
const assert = require('assert'); | ||
|
||
const entry = require.resolve('./test-esm-json.mjs'); | ||
|
||
// Verify non-js extensions fail for ESM | ||
const child = spawn(process.execPath, [entry]); | ||
|
||
let stderr = ''; | ||
child.stderr.setEncoding('utf8'); | ||
child.stderr.on('data', (data) => { | ||
stderr += data; | ||
}); | ||
child.on('close', common.mustCall((code, signal) => { | ||
assert.strictEqual(code, 1); | ||
assert.strictEqual(signal, null); | ||
assert.ok(stderr.indexOf('ERR_UNKNOWN_FILE_EXTENSION') !== -1); | ||
})); |