feat: allow loading preResolution, importPackage, and fetchers from local pnpmfile (#9450)

This commit is contained in:
Zoltan Kochan
2025-04-23 12:11:08 +02:00
committed by GitHub
parent 7a2d7a18ed
commit e5c58f093f
2 changed files with 9 additions and 3 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/pnpmfile": minor
"pnpm": minor
---
Allow loading the `preResolution`, `importPackage`, and `fetchers` hooks from local pnpmfile.

View File

@@ -72,15 +72,15 @@ export function requireHooks (
// `importPackage`, `preResolution` and `fetchers` can only be defined via a global pnpmfile
cookedHooks.importPackage = globalHooks.importPackage
cookedHooks.importPackage = hooks.importPackage ?? globalHooks.importPackage
const preResolutionHook = globalHooks.preResolution
const preResolutionHook = hooks.preResolution ?? globalHooks.preResolution
cookedHooks.preResolution = preResolutionHook
? (ctx: PreResolutionHookContext) => preResolutionHook(ctx, createPreResolutionHookLogger(prefix))
: undefined
cookedHooks.fetchers = globalHooks.fetchers
cookedHooks.fetchers = hooks.fetchers ?? globalHooks.fetchers
if (hooks.updateConfig != null) {
const updateConfig = hooks.updateConfig
cookedHooks.updateConfig = (config) => {