-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
There are currently two supported values "explicit" and "node"
- Loading branch information
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Flags: --experimental-modules --es-module-specifier-resolution=node | ||
import { mustNotCall } from '../common'; | ||
import assert from 'assert'; | ||
|
||
// commonJS index.js | ||
import commonjs from '../fixtures/es-module-specifiers/package-type-commonjs'; | ||
// esm index.js | ||
import module from '../fixtures/es-module-specifiers/package-type-module'; | ||
// notice the trailing slash | ||
import success, { explicit, implicit, implicitModule, getImplicitCommonjs } | ||
from '../fixtures/es-module-specifiers/'; | ||
|
||
assert.strictEqual(commonjs, 'commonjs'); | ||
assert.strictEqual(module, 'module'); | ||
assert.strictEqual(success, 'success'); | ||
assert.strictEqual(explicit, 'esm'); | ||
assert.strictEqual(implicit, 'esm'); | ||
assert.strictEqual(implicitModule, 'esm'); | ||
|
||
async function main() { | ||
try { | ||
await import('../fixtures/es-module-specifiers/do-not-exist.js'); | ||
} catch (e) { | ||
// Files that do not exist should throw | ||
assert.strictEqual(e.name, 'Error'); | ||
} | ||
try { | ||
await getImplicitCommonjs(); | ||
} catch (e) { | ||
// Legacy loader cannot resolve .mjs automatically from main | ||
assert.strictEqual(e.name, 'Error'); | ||
} | ||
} | ||
|
||
main().catch(mustNotCall); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import explicit from 'explicit-main'; | ||
import implicit from 'implicit-main'; | ||
import implicitModule from 'implicit-main-type-module'; | ||
|
||
function getImplicitCommonjs () { | ||
return import('implicit-main-type-commonjs'); | ||
} | ||
|
||
export {explicit, implicit, implicitModule, getImplicitCommonjs}; | ||
export default 'success'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "commonjs" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"type": "module" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file was deleted.
This file was deleted.