-
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.
module: expose exports conditions to loaders
PR-URL: #31303 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
- Loading branch information
Showing
8 changed files
with
114 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Flags: --experimental-loader ./test/fixtures/es-module-loaders/loader-with-custom-condition.mjs | ||
import '../common/index.mjs'; | ||
import assert from 'assert'; | ||
|
||
import * as ns from '../fixtures/es-modules/conditional-exports.mjs'; | ||
|
||
assert.deepStrictEqual({ ...ns }, { default: 'from custom condition' }); |
10 changes: 10 additions & 0 deletions
10
test/fixtures/es-module-loaders/loader-with-custom-condition.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,10 @@ | ||
import {ok, deepStrictEqual} from 'assert'; | ||
|
||
export async function resolve(specifier, context, defaultResolve) { | ||
ok(Array.isArray(context.conditions), 'loader receives conditions array'); | ||
deepStrictEqual([...context.conditions].sort(), ['import', 'node']); | ||
return defaultResolve(specifier, { | ||
...context, | ||
conditions: ['custom-condition', ...context.conditions], | ||
}); | ||
} |
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 @@ | ||
export { default } from 'pkgexports/condition'; |
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.