Skip to content
Prev Previous commit
Next Next commit
fixup! fixup! esm: fix loader hooks accepting too many arguments
consolidate assignment & set arg0 default
  • Loading branch information
JakobJingleheimer committed Aug 3, 2022
commit b3d1461a28e441328295a243a0f5bf3363f63b66
6 changes: 2 additions & 4 deletions lib/internal/modules/esm/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ function nextHookFactory(chain, meta, { validateArgs, validateOutput }) {
}

return ObjectDefineProperty(
async (arg0, context) => {
async (arg0 = undefined, context) => {
// Update only when hook is invoked to avoid fingering the wrong filePath
meta.hookErrIdentifier = `${hookFilePath} '${hookName}'`;

Expand All @@ -162,12 +162,10 @@ function nextHookFactory(chain, meta, { validateArgs, validateOutput }) {
const argsToApply = [arg0];

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

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

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