Skip to content
Prev Previous commit
Next Next commit
fixup! fixup! fixup! fixup! esm: fix loader hooks accepting too many …
…arguments

ReflectApply → direct invocation w separate args
  • Loading branch information
JakobJingleheimer committed Aug 3, 2022
commit 2254fb8b6909c5a3a7473494503bc8538d376f31
8 changes: 1 addition & 7 deletions lib/internal/modules/esm/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const {
ObjectDefineProperty,
ObjectSetPrototypeOf,
PromiseAll,
ReflectApply,
RegExpPrototypeExec,
SafeArrayIterator,
SafeWeakMap,
Expand Down Expand Up @@ -159,16 +158,11 @@ function nextHookFactory(chain, meta, { validateArgs, validateOutput }) {
// Set when next<HookName> is actually called, not just generated.
if (generatedHookIndex === 0) { meta.chainFinished = true; }

const argsToApply = [arg0];

if (context) { // `context` has already been validated, so no fancy check needed.
ObjectAssign(meta.context, context);
}
Comment thread
JakobJingleheimer marked this conversation as resolved.

argsToApply[1] = meta.context;
argsToApply[2] = nextNextHook;

const output = await ReflectApply(hook, undefined, argsToApply);
const output = await hook(arg0, context, nextNextHook);
Comment thread
aduh95 marked this conversation as resolved.
Outdated

validateOutput(outputErrIdentifier, output);

Expand Down