perf(@angular/cli): avoid eager module loading during global bootstrap - #33811
Merged
Merged
Conversation
There was a problem hiding this comment.
Code Review
This pull request optimizes startup performance in the Angular CLI initialization by refactoring the static imports of colors and isWarningEnabled into dynamic imports that are only loaded when a version mismatch warning is triggered. The review feedback highlights a potential issue where an error during these dynamic imports or the warning check could cause the outer try-catch block to silently fall back to the global CLI instead of using the local CLI. It is recommended to wrap this non-critical warning logic in its own try-catch block to prevent such failures from affecting the CLI execution flow.
Avoid importing `isWarningEnabled` and `colors` statically in `init.ts`. Eagerly importing `config.ts` causes `@angular-devkit/core` and its transitive dependencies (`rxjs`, `ajv`, `jsonc-parser`, and schema registries) to be evaluated synchronously in the global CLI context before resolving the project local CLI. By lazily importing `config.ts` and `color.ts` only when `isGlobalGreater` is true and a version mismatch warning needs to be issued, cold CLI invocations avoid evaluating these packages globally during bootstrap.
clydin
force-pushed
the
perf/lazy-load-bootstrap-warning
branch
from
August 7, 2026 17:46
432302f to
debafb5
Compare
alan-agius4
approved these changes
Aug 7, 2026
Collaborator
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.
Avoid importing
isWarningEnabledandcolorsstatically ininit.ts. Eagerly importingconfig.tscauses@angular-devkit/coreand its transitive dependencies (rxjs,ajv,jsonc-parser, and schema registries) to be evaluated synchronously in the global CLI context before resolving the project local CLI.By lazily importing
config.tsandcolor.tsonly whenisGlobalGreateris true and a version mismatch warning needs to be issued, cold CLI invocations avoid evaluating these packages globally during bootstrap.