perf(@angular/cli): cache root manifest and resolve restricted package exports in ng add#32717
perf(@angular/cli): cache root manifest and resolve restricted package exports in ng add#32717clydin wants to merge 1 commit intoangular:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces two valuable improvements to the ng add command. First, it caches the root project's package.json, which effectively reduces redundant file reads and parsing, leading to better performance. Second, it enhances the package resolution logic to robustly locate a package's package.json even when it's not directly exported, by implementing a fallback strategy that traverses up from the package's main entry point.
My review has identified a couple of minor areas for improvement: an unused import and an empty catch block that could benefit from logging for better debuggability. Apart from these points, the changes are well-implemented and address the stated goals of performance and robustness.
ebf81d6 to
11bc2e6
Compare
…e exports in ng add This change enhances the `ng add` command's performance by caching the root project manifest (`package.json`) to avoid redundant disk reads and JSON parsing during peer dependency conflict checks. Additionally, it improves the robustness of `package.json` resolution for installed packages. Previously, resolving `package.json` could fail if a third-party package used the Node.js `"exports"` field without explicitly exporting its `package.json`. The CLI now correctly handles this by falling back to resolving the package's entry point and traversing upwards to find the manifest.
11bc2e6 to
695ec87
Compare
This change enhances the
ng addcommand's performance by caching the root project manifest (package.json) to avoid redundant disk reads and JSON parsing during peer dependency conflict checks.Additionally, it improves the robustness of
package.jsonresolution for installed packages. Previously, resolvingpackage.jsoncould fail if a third-party package used the Node.js"exports"field without explicitly exporting itspackage.json. The CLI now correctly handles this by falling back to resolving the package's entry point and traversing upwards to find the manifest.