Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAntoine du Hamel <duhamelantoine1995@gmail.com>2022-08-08 11:51:35 +0300
committerGitHub <noreply@github.com>2022-08-08 11:51:35 +0300
commit6f9eff880bc660a80240f23884dcd3253a56fd1e (patch)
treef035cdbd31489c5cdfb0e20fb81a5874390d55a9 /lib
parent80ef02b13ff6f19d98b71ad048046e20fa75db16 (diff)
esm: do not bind loader hook functions
PR-URL: https://github.com/nodejs/node/pull/44122 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/modules/esm/loader.js17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/internal/modules/esm/loader.js b/lib/internal/modules/esm/loader.js
index f2d5600fba6..71c9100a7e7 100644
--- a/lib/internal/modules/esm/loader.js
+++ b/lib/internal/modules/esm/loader.js
@@ -8,7 +8,6 @@ const {
ArrayIsArray,
ArrayPrototypeJoin,
ArrayPrototypePush,
- FunctionPrototypeBind,
FunctionPrototypeCall,
ObjectAssign,
ObjectCreate,
@@ -306,16 +305,14 @@ class ESMLoader {
'DeprecationWarning',
);
- // Use .bind() to avoid giving access to the Loader instance when called.
if (globalPreload) {
- acceptedHooks.globalPreloader =
- FunctionPrototypeBind(globalPreload, null);
+ acceptedHooks.globalPreloader = globalPreload;
}
if (resolve) {
- acceptedHooks.resolver = FunctionPrototypeBind(resolve, null);
+ acceptedHooks.resolver = resolve;
}
if (load) {
- acceptedHooks.loader = FunctionPrototypeBind(load, null);
+ acceptedHooks.loader = load;
}
return acceptedHooks;
@@ -346,7 +343,7 @@ class ESMLoader {
ArrayPrototypePush(
this.#globalPreloaders,
{
- fn: FunctionPrototypeBind(globalPreloader), // [1]
+ fn: globalPreloader,
url,
},
);
@@ -355,7 +352,7 @@ class ESMLoader {
ArrayPrototypePush(
this.#resolvers,
{
- fn: FunctionPrototypeBind(resolver), // [1]
+ fn: resolver,
url,
},
);
@@ -364,15 +361,13 @@ class ESMLoader {
ArrayPrototypePush(
this.#loaders,
{
- fn: FunctionPrototypeBind(loader), // [1]
+ fn: loader,
url,
},
);
}
}
- // [1] ensure hook function is not bound to ESMLoader instance
-
this.preload();
}