fix(install): remove stale root node_modules symlink on deno remove#35137
Merged
Conversation
… as transitive dep
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.
In the pnpm-style local node_modules layout, only direct dependencies get a
symlink at the root of node_modules. However, when a direct dependency was
removed but remained in the resolution as a transitive dependency of another
package, "deno remove" left its root symlink behind, leaking it as a phantom
dependency. A fresh "deno install" after deleting node_modules correctly did
not link it at the root, confirming the leftover entry was a stale artifact.
This happened for two reasons: the cleanup pass kept any root symlink whose
target package was still anywhere in the resolution (instead of only packages
expected at the root), and the change-detection hash only covered package ids,
so removing an import that survived as a transitive dependency did not change
the hash and the cleanup never ran. The cleanup now keeps only the packages
expected at the root (resolved package.json and import map dependencies plus
the snapshot's top level packages) and the hash includes that set, matching
what pnpm does.
Fixes #35083