-
Notifications
You must be signed in to change notification settings - Fork 30.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
esm: leverage loaders when resolving subsequent loaders
- Loading branch information
Showing
14 changed files
with
119 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
export async function load(url, context, next) { | ||
// Otherwise we can't use this loader in chaining context, as it would | ||
// overwrite other subsequent loaders | ||
if (url.includes('loader')) { | ||
return next(url); | ||
} | ||
|
||
console.log('load passthru'); // This log is deliberate | ||
return next(url); | ||
} |
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 |
---|---|---|
@@ -1,4 +1,10 @@ | ||
export async function resolve(specifier, context, next) { | ||
// Otherwise we can't use this loader in chaining context, as it would | ||
// overwrite other subsequent loaders | ||
if (specifier.includes('loader')) { | ||
return next(specifier); | ||
} | ||
|
||
console.log('resolve foo'); // This log is deliberate | ||
return next('file:///foo.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
6 changes: 6 additions & 0 deletions
6
test/fixtures/es-module-loaders/loader-resolve-next-modified.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
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,4 +1,10 @@ | ||
export async function resolve(specifier, context, next) { | ||
// Otherwise we can't use this loader in chaining context, as it would | ||
// overwrite other subsequent loaders | ||
if (specifier.includes('loader')) { | ||
return next(specifier); | ||
} | ||
|
||
console.log('resolve passthru'); // This log is deliberate | ||
return next(specifier); | ||
} |
8 changes: 7 additions & 1 deletion
8
test/fixtures/es-module-loaders/loader-resolve-shortcircuit.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
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,4 @@ | ||
export async function resolve(specifier, context, defaultResolve) { | ||
console.log(`loader-a`, {specifier}); | ||
return defaultResolve(specifier.replace(/^xxx\//, `./`)); | ||
} |
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,4 @@ | ||
export async function resolve(specifier, context, defaultResolve) { | ||
console.log(`loader-b`, {specifier}); | ||
return defaultResolve(specifier.replace(/^yyy\//, `./`)); | ||
} |