perf(@angular/cli): lazily initialize package manager in command context#32854
Open
alan-agius4 wants to merge 1 commit intoangular:mainfrom
Open
perf(@angular/cli): lazily initialize package manager in command context#32854alan-agius4 wants to merge 1 commit intoangular:mainfrom
alan-agius4 wants to merge 1 commit intoangular:mainfrom
Conversation
2d01580 to
94b9bb5
Compare
There was a problem hiding this comment.
Code Review
This pull request refactors the CommandContext to treat the packageManager as a Promise, allowing for lazy initialization. This change requires updating multiple command modules to asynchronously resolve the package manager before use. Furthermore, the SmartDefaultProvider interface and the CoreSchemaRegistry have been updated to support asynchronous providers. Review feedback focuses on improving code readability and performance by avoiding redundant await calls on the packageManager promise in AddCommandModule and gatherVersionInfo.
94b9bb5 to
1073ddc
Compare
This change refactors the `CommandContext` to defer the initialization of the `packageManager` instance until it is first accessed. This optimization avoids unnecessary configuration discovery and disk I/O for commands that do not require the package manager, such as `ng help`, and certain shell completions. As part of this refactoring: - The `packageManager` property in `CommandContext` is now a `Promise<PackageManager>`. - Internal command modules and utility functions have been updated to `await` the package manager's lazy initialization. - In `@angular-devkit/core`, `CoreSchemaRegistry` was updated to rename `_sourceMap` to `_sourceProvider` and optimize the resolution of smart defaults by awaiting values during the `_set` operation.
1073ddc to
920e161
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.
This change refactors the
CommandContextto defer the initialization of thepackageManagerinstance until it is first accessed. This optimization avoids unnecessary configuration discovery and disk I/O for commands that do not require the package manager, such asng help, and certain shell completions.As part of this refactoring:
packageManagerproperty inCommandContextis now aPromise<PackageManager>.awaitthe package manager's lazy initialization.@angular-devkit/core,CoreSchemaRegistrywas updated to rename_sourceMapto_sourceProviderand optimize the resolution of smart defaults by awaiting values during the_setoperation.