Files
pnpm/pnpm11/fetching
Trevor Burnham a897ef728d feat(pacquet): support custom fetchers from pnpmfile (#12846)
Support custom fetchers from pnpmfiles in pacquet, with delegate-envelope parity in the TypeScript CLI (related to pnpm/pnpm#11685)

Pacquet already supported custom resolvers via its Node.js worker IPC but
lacked the fetcher counterpart. This extends the same protocol pattern:

- Define a CustomFetcher trait and get_custom_fetchers() on PnpmfileHooks
- Add fetchers/fetcher target dispatch to the worker's NDJSON protocol
  and JS runner, mirroring the existing resolver path; the hook is
  invoked with the TS-parity args fetch(cafs, resolution, opts, fetchers)
  (cafs/fetchers are null over IPC)
- Implement NodeJsCustomFetcher bridging the trait to the worker
- Create CustomFetcherPicker for consulting fetchers in declared order
- Consult custom fetchers before the built-in dispatch on both the
  frozen-lockfile and fresh-lockfile install paths; hook-load failures
  abort the install (PNPMFILE_FAIL)
- Support delegation: { delegate: <resolution> } rewrites the resolution
  for the standard tarball/git path; non-delegate responses and
  custom-typed delegates fail the install
- lockfile: add LockfileResolution::Custom preserving custom-typed
  resolution objects verbatim, so custom resolvers/fetchers can round-trip
  them; unclaimed custom-typed resolutions fail with the TS-parity
  UNSUPPORTED_RESOLUTION_TYPE error
- TypeScript: pickFetcher now accepts the { delegate: <resolution> }
  envelope from custom fetchers (the portable delegation form), and
  hooks.types exports CustomFetcherDelegation

Full CAS fetch in pacquet (where a fetcher produces file content directly
rather than delegating) requires a streaming protocol extension
(separate follow-up).
2026-07-10 16:06:09 +02:00
..