Skip to content

feat: pass currentPkg to custom resolvers - #10440

Merged
zkochan merged 1 commit into
pnpm:mainfrom
TrevorBurnham:resolver-refactor
Jan 12, 2026
Merged

zkochan merged 1 commit into
pnpm:mainfrom
TrevorBurnham:resolver-refactor

Conversation

@TrevorBurnham

@TrevorBurnham TrevorBurnham commented Jan 10, 2026 •

Copy link
Copy Markdown
Contributor

Previous discussion: #10342

This PR builds on the approach in #10439 of moving the skip resolution logic from the package requester into the resolvers themselves. The main difference is that checkCustomResolverForceResolve iterates over the lockfile, not the package manifests, so that the custom resolvers for subdependencies have the option to force full resolution.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the resolution logic to give resolvers autonomy over whether to skip resolution, moving this decision from the package requester into the individual resolvers. The key architectural change is that resolvers are now always called and receive currentPkg (existing lockfile info) and peekedManifest (cached manifest from store) as context, allowing them to decide whether to perform full resolution or return cached results.

Changes:

  • Moved skip-resolution logic from package-requester into individual resolvers (npm, local, git)
  • Added currentPkg and peekedManifest options to resolver interfaces to provide resolution context
  • Refactored checkCustomResolverForceResolve to iterate over lockfile packages instead of manifest dependencies, enabling custom resolvers for transitive dependencies

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
resolving/resolver-base/src/index.ts Added currentPkg and peekedManifest fields to ResolveOptions interface
resolving/npm-resolver/src/index.ts Added fast-path optimization using peekedManifest and currentPkg to skip metadata fetch
resolving/local-resolver/src/index.ts Added skip-resolution logic for file tarballs (integrity check) and directories
resolving/git-resolver/src/index.ts Added skip-resolution logic for git and tarball resolutions when not updating
resolving/default-resolver/src/index.ts Passed currentPkg to custom resolvers and git resolver
pkg-manager/package-requester/src/packageRequester.ts Removed skip-resolution logic, now always calls resolver with currentPkg and peekedManifest
pkg-manager/package-requester/test/index.ts Updated test expectations to reflect that resolver is always called
pkg-manager/core/src/install/checkCustomResolverForceResolve.ts Changed to iterate lockfile packages instead of manifest dependencies
pkg-manager/core/src/install/index.ts Simplified function call to checkCustomResolverForceResolve
pkg-manager/core/test/install/checkCustomResolverForceResolve.test.ts Updated tests to reflect new lockfile-based iteration approach
pkg-manager/core/test/install/customResolvers.ts Simplified integration tests for custom resolvers
pkg-manager/core/test/utils/testDefaults.ts Added hooks parameter to test defaults
resolving/default-resolver/test/customResolver.ts Added test for currentPkg being passed to custom resolvers
hooks/types/src/index.ts Added currentPkg field to ResolveOptions interface for custom resolvers
pnpm/src/main.ts Added optimization to skip workspace filtering for run/exec commands, plus formatting
fs/find-packages/src/index.ts Formatting change (added blank line)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hooks/types/src/index.ts Resolved
Comment thread resolving/npm-resolver/src/index.ts Resolved
// eslint-disable-next-line no-await-in-loop
const canResolve = await checkCustomResolverCanResolve(customResolver, wantedDependency)
for (const depPath of Object.keys(wantedLockfile.packages)) {
const { name: alias } = parseDepPath(depPath)

Copilot AI Jan 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect use of parseDepPath function. The parseDepPath function returns { id, peerDepGraphHash }, not { name }. This line attempts to destructure name from the result, which will always be undefined. You should use parse(depPath) instead, which returns { name, version, ... }. This is a critical bug that would cause the function to skip all packages since alias will always be undefined.

Copilot uses AI. Check for mistakes.
@TrevorBurnham
TrevorBurnham force-pushed the resolver-refactor branch 2 times, most recently from de8bf4d to bcbd65e Compare January 10, 2026 22:52
@zkochan

zkochan commented Jan 12, 2026

Copy link
Copy Markdown
Member

you should rebase your pr

Comment thread resolving/npm-resolver/src/index.ts Resolved
Comment thread resolving/resolver-base/src/index.ts Resolved
@TrevorBurnham TrevorBurnham changed the title refactor: let resolvers decide whether to skip resolution feat: pass currentPkg to custom resolvers Jan 12, 2026
Comment thread pnpm/src/main.ts Resolved
Comment thread pnpm/src/main.ts Resolved
Comment thread fs/find-packages/src/index.ts Resolved
- Add currentPkg (with name/version) to custom resolver ResolveOptions
- Pass currentPkg through to custom resolvers in default-resolver
- Simplify checkCustomResolverForceResolve to use parseDepPath

@zkochan zkochan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zkochan

zkochan commented Jan 12, 2026

Copy link
Copy Markdown
Member

I will merge but I will release the next v11 version only after solving #10409

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants