-
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: do not bind loader hook functions
PR-URL: #44122 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
- Loading branch information
Showing
3 changed files
with
24 additions
and
11 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
14 changes: 14 additions & 0 deletions
14
test/fixtures/es-module-loaders/loader-this-value-inside-hook-functions.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,14 @@ | ||
export function resolve(url, _, next) { | ||
if (this != null) throw new Error('hook function must not be bound to ESMLoader instance'); | ||
return next(url); | ||
} | ||
|
||
export function load(url, _, next) { | ||
if (this != null) throw new Error('hook function must not be bound to ESMLoader instance'); | ||
return next(url); | ||
} | ||
|
||
export function globalPreload() { | ||
if (this != null) throw new Error('hook function must not be bound to ESMLoader instance'); | ||
return ""; | ||
} |
4 changes: 4 additions & 0 deletions
4
test/parallel/test-loaders-this-value-inside-hook-functions.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,4 @@ | ||
// Flags: --experimental-loader ./test/fixtures/es-module-loaders/loader-this-value-inside-hook-functions.mjs | ||
import '../common/index.mjs'; | ||
|
||
// Actual test is inside the loader module. |