Skip to content

perf(@angular/cli): skip eager yargs help message formatting during command execution - #34087

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:yargs-help-cache-opt
Open

perf(@angular/cli): skip eager yargs help message formatting during command execution#34087
clydin wants to merge 1 commit into
angular:mainfrom
clydin:yargs-help-cache-opt

Conversation

@clydin

@clydin clydin commented Sep 11, 2026

Copy link
Copy Markdown
Member

Whenever a subcommand is invoked, Yargs eagerly formats and caches the complete command help message via its internal cacheHelpMessage() method. This involves assembling layout tables with cliui, wrapping text with wrap-ansi, and evaluating Unicode string widths with string-width, even when the command succeeds and help output is never requested.

Because the Angular CLI explicitly configures showHelpOnFail(false) and handles errors via a custom failure handler, this cached help message is never consumed in either the success or failure paths. Overriding cacheHelpMessage to a no-op when neither --help nor --json-help is requested eliminates roughly 15ms to 20ms of synchronous formatting overhead from the CLI startup path.

…ommand execution

Whenever a subcommand is invoked, Yargs eagerly formats and caches the complete command help message via its internal cacheHelpMessage() method. This involves assembling layout tables with cliui, wrapping text with wrap-ansi, and evaluating Unicode string widths with string-width, even when the command succeeds and help output is never requested.

Because the Angular CLI explicitly configures showHelpOnFail(false) and handles errors via a custom failure handler, this cached help message is never consumed in either the success or failure paths. Overriding cacheHelpMessage to a no-op when neither --help nor --json-help is requested eliminates roughly 15ms to 20ms of synchronous formatting overhead from the CLI startup path.
@clydin clydin added the target: minor This PR is targeted for the next minor release label Sep 11, 2026
@angular-robot angular-robot Bot added area: performance Issues related to performance area: @angular/cli labels Sep 11, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request optimizes startup performance in the Angular CLI by disabling eager help message caching in yargs when help is not requested. The reviewer suggests adding defensive checks (optional chaining) when accessing yargs internal methods to prevent potential runtime crashes if the third-party library updates.

Comment thread packages/angular/cli/src/command-builder/command-runner.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: @angular/cli area: performance Issues related to performance target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant