-
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.
esm: leverage loaders when resolving subsequent loaders
PR-URL: #43772 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
- Loading branch information
Showing
15 changed files
with
140 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
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,12 @@ | ||
export async function load(url, context, next) { | ||
// This check is needed to make sure that we don't prevent the | ||
// resolution from follow-up loaders. It wouldn't be a problem | ||
// in real life because loaders aren't supposed to break the | ||
// resolution, but the ones used in our tests do, for convenience. | ||
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,12 @@ | ||
export async function resolve(specifier, context, next) { | ||
// This check is needed to make sure that we don't prevent the | ||
// resolution from follow-up loaders. It wouldn't be a problem | ||
// in real life because loaders aren't supposed to break the | ||
// resolution, but the ones used in our tests do, for convenience. | ||
if (specifier.includes('loader')) { | ||
return next(specifier); | ||
} | ||
|
||
console.log('resolve foo'); // This log is deliberate | ||
return next('file:///foo.mjs'); | ||
} |
10 changes: 9 additions & 1 deletion
10
test/fixtures/es-module-loaders/loader-resolve-incomplete.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
8 changes: 8 additions & 0 deletions
8
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,12 @@ | ||
export async function resolve(specifier, context, next) { | ||
// This check is needed to make sure that we don't prevent the | ||
// resolution from follow-up loaders. It wouldn't be a problem | ||
// in real life because loaders aren't supposed to break the | ||
// resolution, but the ones used in our tests do, for convenience. | ||
if (specifier.includes('loader')) { | ||
return next(specifier); | ||
} | ||
|
||
console.log('resolve passthru'); // This log is deliberate | ||
return next(specifier); | ||
} |
10 changes: 9 additions & 1 deletion
10
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, nextResolve) { | ||
console.log(`loader-a`, {specifier}); | ||
return nextResolve(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, nextResolve) { | ||
console.log(`loader-b`, {specifier}); | ||
return nextResolve(specifier.replace(/^yyy\//, `./`)); | ||
} |