-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
esm: implement "pkg-exports" proposal
Refs: jkrems/proposal-pkg-exports#36 PR-URL: #28568 Reviewed-By: Anna Henningsen <anna@addaleax.net>
- Loading branch information
1 parent
ff432c8
commit b379c0e
Showing
13 changed files
with
196 additions
and
8 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 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 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,28 @@ | ||
// Flags: --experimental-modules --experimental-exports | ||
|
||
import { mustCall } from '../common/index.mjs'; | ||
import { ok, strictEqual } from 'assert'; | ||
|
||
import { asdf, asdf2 } from '../fixtures/pkgexports.mjs'; | ||
import { | ||
loadMissing, | ||
loadFromNumber, | ||
loadDot, | ||
} from '../fixtures/pkgexports-missing.mjs'; | ||
|
||
strictEqual(asdf, 'asdf'); | ||
strictEqual(asdf2, 'asdf'); | ||
|
||
loadMissing().catch(mustCall((err) => { | ||
ok(err.message.toString().startsWith('Package exports')); | ||
ok(err.message.toString().indexOf('do not define a \'./missing\' subpath')); | ||
})); | ||
|
||
loadFromNumber().catch(mustCall((err) => { | ||
ok(err.message.toString().startsWith('Package exports')); | ||
ok(err.message.toString().indexOf('do not define a \'./missing\' subpath')); | ||
})); | ||
|
||
loadDot().catch(mustCall((err) => { | ||
ok(err.message.toString().startsWith('Cannot find main entry point')); | ||
})); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,11 @@ | ||
export function loadMissing() { | ||
return import('pkgexports/missing'); | ||
} | ||
|
||
export function loadFromNumber() { | ||
return import('pkgexports-number/hidden.js'); | ||
} | ||
|
||
export function loadDot() { | ||
return import('pkgexports'); | ||
} |
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,2 @@ | ||
export { default as asdf } from 'pkgexports/asdf'; | ||
export { default as asdf2 } from 'pkgexports/sub/asdf.js'; |