-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module: drop support for extensionless main entry points in esm
PR-URL: #31415 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Rich Trott <[email protected]>
- Loading branch information
1 parent
ca81af7
commit aa26662
Showing
7 changed files
with
66 additions
and
60 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
This file was deleted.
Oops, something went wrong.
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,36 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const fixtures = require('../common/fixtures'); | ||
const { spawn } = require('child_process'); | ||
const assert = require('assert'); | ||
|
||
// In a "type": "module" package scope, files with unknown extensions or no | ||
// extensions should throw; both when used as a main entry point and also when | ||
// referenced via `import`. | ||
|
||
[ | ||
'/es-modules/package-type-module/noext-esm', | ||
'/es-modules/package-type-module/imports-noext.mjs', | ||
'/es-modules/package-type-module/extension.unknown', | ||
'/es-modules/package-type-module/imports-unknownext.mjs', | ||
].forEach((fixturePath) => { | ||
const entry = fixtures.path(fixturePath); | ||
const child = spawn(process.execPath, [entry]); | ||
let stdout = ''; | ||
let stderr = ''; | ||
child.stderr.setEncoding('utf8'); | ||
child.stdout.setEncoding('utf8'); | ||
child.stdout.on('data', (data) => { | ||
stdout += data; | ||
}); | ||
child.stderr.on('data', (data) => { | ||
stderr += data; | ||
}); | ||
child.on('close', common.mustCall((code, signal) => { | ||
assert.strictEqual(code, 1); | ||
assert.strictEqual(signal, null); | ||
assert.strictEqual(stdout, ''); | ||
assert.ok(stderr.indexOf('ERR_UNKNOWN_FILE_EXTENSION') !== -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 @@ | ||
import './noext-esm'; |
1 change: 1 addition & 0 deletions
1
test/fixtures/es-modules/package-type-module/imports-unknownext.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 @@ | ||
import './extension.unknown'; |