fix(pm): avoid reusing anchor-only hoists for workspaces#2819
fix(pm): avoid reusing anchor-only hoists for workspaces#2819
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the dependency resolution logic in DependencyGraph to ensure that node_modules directories are only considered if they are physically reachable from the requester's path, preventing incorrect reuse of hoisted dependencies in workspace scenarios. The changes include a new reachability check and updated recursion logic in find_in_parent_chain. Feedback suggests optimizing the reachability check by passing the requester's path through the recursion to avoid redundant node lookups.
There was a problem hiding this comment.
Pull request overview
This PR adjusts dependency reuse/hoisting decisions in ruborist’s dependency graph to ensure previously-installed packages are only reused when their node_modules/ locations are actually reachable from the requesting package’s on-disk path (matching Node’s upward module resolution behavior), and adds regressions around nested-vs-hoisted preference and sibling workspace isolation.
Changes:
- Start
find_compatible_nodesearch from the requester node (preferring nested installs before hoisted parents). - Gate reuse checks to only consider ancestor
node_modules/locations that are path-reachable from the requester. - Add regression tests for nested preference and sibling-workspace hoist isolation.
|
Addressed the inline review comments:
Revalidated with:
|
f8f5044 to
1b7a778
Compare
|
@killagu 需要补充一下原始 issue 里的 e2e case |
1b7a778 to
eb67777
Compare
|
原始 issue 在这,pr 里应该保持关联 |
Summary
Validation
Reproduction