fix(@angular/cli): recursively collect nested workspace dependencies in npm#33038
Closed
clydin wants to merge 1 commit intoangular:mainfrom
Closed
fix(@angular/cli): recursively collect nested workspace dependencies in npm#33038clydin wants to merge 1 commit intoangular:mainfrom
clydin wants to merge 1 commit intoangular:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the parseNpmLikeDependencies function to support nested dependencies through a breadth-first traversal and adds unit tests for workspace scenarios. Feedback was provided to optimize performance by avoiding O(N^2) operations with shift() and to ensure that shallower dependency versions are preserved rather than overwritten by nested ones.
…in npm When running the update command in an npm workspace repository from within a workspace subdirectory, the CLI currently fails to detect hoisted dependencies. This occurs because npm list structures its workspace dependency output as nested items inside their respective top-level workspace entry, rather than as top-level items. The current parser was only reading the top-level items and consequently missed nested workspace dependencies. This change updates the dependency parser to perform a breadth-first traversal of the JSON tree output of the package list command. By iteratively traversing the nested dependencies, the CLI can successfully resolve all installed packages within an npm workspaces monorepo.
1401ec7 to
8532c3b
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.
When running the update command in an npm workspace repository from within a workspace subdirectory, the CLI currently fails to detect hoisted dependencies. This occurs because npm list structures its workspace dependency output as nested items inside their respective top-level workspace entry, rather than as top-level items. The current parser was only reading the top-level items and consequently missed nested workspace dependencies.
This change updates the dependency parser to perform a breadth-first traversal of the JSON tree output of the package list command. By iteratively traversing the nested dependencies, the CLI can successfully resolve all installed packages within an npm workspaces monorepo.