fix(arborist): fix peerOptional dependency resolution in buildIdealTree#8981
fix(arborist): fix peerOptional dependency resolution in buildIdealTree#8981Saibamen wants to merge 9 commits intonpm:latestfrom
peerOptional dependency resolution in buildIdealTree#8981Conversation
buildIdealTree problem detection
|
FYI: Right now, this PR fixes only
I will try to fix this too. |
…ptional When a dependency is placed (OK) and creates an invalid peerOptional edge with an already-processed node, re-queue that node for re-resolution. This handles the case where the peerOptional holder is processed before the dep exists in the tree (due to alphabetical processing order), and the dep is later placed by another path with a version that doesn't satisfy the peer spec. Also adds npm install tests for issue npm#8726 covering both the existing-lockfile and fresh-install (no lockfile) scenarios. Refs: npm#8726 Co-authored-by: Cursor <cursoragent@cursor.com>
|
Now |
buildIdealTree problem detectionbuildIdealTree
buildIdealTreepeerOptional dependency resolution in buildIdealTree
There was a problem hiding this comment.
Could you unwrap the multi-line comments so each sentence/paragraph is on a single line? We avoid hard-wrapping prose in comments for accessibility as it doesn't play well with screen readers (we've been slowly converting the codebase to that anyway, it is still pretty prevalent)
|
@Saibamen looks like it needs 2 more lines of code coverage from tests as well |
Linking doesn't work in PR title - you need to have it inside PR description (first comment). |
|
yup I mistyped - I meant "body" rather than "title", and for you to do a "Fixes #xyz" for each issue 🙂 |
…from the !edge.valid peerOptional check. This branch was unreachable because add: [...] changes peerOptional edges to regular dependency edges before they're added to #explicitRequests, so a peerOptional edge can never be both explicitly requested and still typed as peerOptional. The simplified condition edge.type !== 'peerOptional' || this.options.save !== false still correctly handles all reachable cases.
…=false This test verifies that invalid peerOptional edges are not treated as problems when the save option is set to false, mimicking the behavior of `npm ci`. It ensures that the dependency tree is built correctly without raising issues for optional peer dependencies that do not meet the specified version requirements.
|
@owlstronaut Please run GH Actions again - I have 100% CC on my local git repo |
|
hope this bc break will be fixed in the next release |
Fixes #8726, fixes #6787
Tested on Windows & NodeJS v24.12.0 with
package.jsonfrom #8726 (comment):{ "name": "testcase", "version": "1.0.0", "devDependencies": { "addons-linter": "6.13.0", "htmlhint": "1.1.4" } }