diff options
author | Antoine du Hamel <duhamelantoine1995@gmail.com> | 2022-08-08 11:51:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-08 11:51:35 +0300 |
commit | 6f9eff880bc660a80240f23884dcd3253a56fd1e (patch) | |
tree | f035cdbd31489c5cdfb0e20fb81a5874390d55a9 /lib | |
parent | 80ef02b13ff6f19d98b71ad048046e20fa75db16 (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.js | 17 |
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(); } |