Skip to content

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

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:yargs-help-cache-opt
Sep 16, 2026
Merged

alan-agius4 merged 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
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Sep 16, 2026
@alan-agius4
alan-agius4 merged commit 6e7f809 into angular:main Sep 16, 2026
43 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

@clydin
clydin deleted the yargs-help-cache-opt branch September 16, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker 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.

2 participants