Repository navigation
feat: pass currentPkg to custom resolvers - #10440
Conversation
There was a problem hiding this comment.
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
currentPkgandpeekedManifestoptions to resolver interfaces to provide resolution context - Refactored
checkCustomResolverForceResolveto 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.
| // 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) |
There was a problem hiding this comment.
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.
de8bf4d to
bcbd65e
Compare
|
you should rebase your pr |
bcbd65e to
301e42f
Compare
301e42f to
c19b52a
Compare
c19b52a to
d839544
Compare
- Add currentPkg (with name/version) to custom resolver ResolveOptions - Pass currentPkg through to custom resolvers in default-resolver - Simplify checkCustomResolverForceResolve to use parseDepPath
d839544 to
66154b5
Compare
|
I will merge but I will release the next v11 version only after solving #10409 |
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
checkCustomResolverForceResolveiterates over the lockfile, not the package manifests, so that the custom resolvers for subdependencies have the option to force full resolution.