fix: make why --exclude-peers skip peer dependency edges#12763
Draft
DrBearZay wants to merge 1 commit into
Draft
fix: make why --exclude-peers skip peer dependency edges#12763DrBearZay wants to merge 1 commit into
DrBearZay wants to merge 1 commit into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
bde2f6f to
87cbfd6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
pnpm why --exclude-peersso reverse dependency trees exclude peer dependencyedges.
pnpm whynow builds a reverse dependency tree. The reverse graph was notcarrying whether an edge came from a peer dependency, and the CLI handler was not
passing
excludePeerDependenciesthrough to the dependents tree builder. As aresult,
pnpm why --prod --exclude-peerscould still show a package that wasonly present as a resolved peer.
Changes
excludePeerDependenciesfrom thewhycommand towhyForPackagesandbuildDependentsTree.Repro
Public repro repository: https://github.com/DrBearZay/pnpm-why-exclude-peers-repro
Minimal repository contents:
{ "name": "pnpm-why-exclude-peers-repro", "version": "1.0.0", "private": true, "packageManager": "pnpm@11.9.0", "dependencies": { "@electron-toolkit/utils": "4.0.0" }, "devDependencies": { "electron": "39.7.0" } }@electron-toolkit/utils@4.0.0declareselectronas a peer dependency. Theroot project provides
electron@39.7.0only fromdevDependencies.The lockfile records that peer-resolved package instance like this:
Since
electronis only reached as a resolved peer from a production dependency,--exclude-peersshould remove it from the result.Actual output
pnpm@11.9.0 list --exclude-peersagrees withpnpm@10.9.0and printsnothing. Only
pnpm@11.9.0 why --exclude-peersreportselectron, so theregression appears to be in the reverse-tree
whypath.Verification
corepack pnpm@11.9.0 --filter @pnpm/deps.inspection.tree-builder compile corepack pnpm@11.9.0 --filter @pnpm/deps.inspection.list compile corepack pnpm@11.9.0 --filter @pnpm/deps.inspection.commands compile corepack pnpm@11.9.0 --filter @pnpm/deps.inspection.tree-builder test -- buildDependentsTree.test.ts node /private/tmp/verify-pnpm-why-peer.mjs