-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module: implement "exports" proposal for CommonJS
Refs: jkrems/proposal-pkg-exports#36 Refs: #28568 PR-URL: #28759 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: Bradley Farias <[email protected]>
- Loading branch information
Showing
13 changed files
with
200 additions
and
13 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
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
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { default as asdf } from 'pkgexports/asdf'; | ||
export { default as asdf2 } from 'pkgexports/sub/asdf.js'; | ||
export { default as space } from 'pkgexports/space'; |
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,47 @@ | ||
// Flags: --experimental-exports | ||
'use strict'; | ||
|
||
require('../common'); | ||
|
||
const assert = require('assert'); | ||
const { createRequire } = require('module'); | ||
const path = require('path'); | ||
|
||
const fixtureRequire = | ||
createRequire(path.resolve(__dirname, '../fixtures/imaginary.js')); | ||
|
||
assert.strictEqual(fixtureRequire('pkgexports/valid-cjs'), 'asdf'); | ||
|
||
assert.strictEqual(fixtureRequire('baz/index'), 'eye catcher'); | ||
|
||
assert.strictEqual(fixtureRequire('pkgexports/sub/asdf.js'), 'asdf'); | ||
|
||
assert.strictEqual(fixtureRequire('pkgexports/space'), 'encoded path'); | ||
|
||
assert.throws( | ||
() => fixtureRequire('pkgexports/not-a-known-entry'), | ||
(e) => { | ||
assert.strictEqual(e.code, 'ERR_PATH_NOT_EXPORTED'); | ||
return true; | ||
}); | ||
|
||
assert.throws( | ||
() => fixtureRequire('pkgexports-number/hidden.js'), | ||
(e) => { | ||
assert.strictEqual(e.code, 'ERR_PATH_NOT_EXPORTED'); | ||
return true; | ||
}); | ||
|
||
assert.throws( | ||
() => fixtureRequire('pkgexports/sub/not-a-file.js'), | ||
(e) => { | ||
assert.strictEqual(e.code, 'MODULE_NOT_FOUND'); | ||
return true; | ||
}); | ||
|
||
assert.throws( | ||
() => fixtureRequire('pkgexports/sub/./../asdf.js'), | ||
(e) => { | ||
assert.strictEqual(e.code, 'ERR_PATH_NOT_EXPORTED'); | ||
return true; | ||
}); |