Skip to content

refactor(@angular/cli): use Node.js styleText for color helpers - #33814

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:perf/use-styletext-color-helpers
Open

refactor(@angular/cli): use Node.js styleText for color helpers#33814
clydin wants to merge 1 commit into
angular:mainfrom
clydin:perf/use-styletext-color-helpers

Conversation

@clydin

@clydin clydin commented Aug 7, 2026

Copy link
Copy Markdown
Member

Replaces listr2 re-exports in the CLI color helper with Node.js built-in styleText utilities from node:util.

Previously, importing colors from utilities/color.ts eagerly pulled in listr2 along with its transitive dependencies (wrap-ansi, string-width, get-east-asian-width), introducing synchronous ESM module evaluation and ANSI formatting overhead during early CLI startup.

Replaces listr2 re-exports in the CLI color helper with Node.js built-in `styleText` utilities from `node:util`.

Previously, importing colors from `utilities/color.ts` eagerly pulled in `listr2` along with its transitive dependencies (`wrap-ansi`, `string-width`, `get-east-asian-width`), introducing synchronous ESM module evaluation and ANSI formatting overhead during early CLI startup.
@clydin clydin added the target: minor This PR is targeted for the next minor release label Aug 7, 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 replaces the dependency on listr2 for terminal coloring in packages/angular/cli/src/utilities/color.ts with a custom implementation using Node's native styleText from node:util. However, using styleText directly introduces compatibility issues with older Node.js versions supported by Angular CLI and fails to respect color support detection in non-TTY environments. It is recommended to implement a fallback mechanism and wrap the formatting calls to conditionally apply colors based on terminal support.

Comment thread packages/angular/cli/src/utilities/color.ts
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 7, 2026
@clydin
clydin requested a review from alan-agius4 August 7, 2026 20:26
FileSystemSchematicDescription,
NodeWorkflow,
} from '@angular-devkit/schematics/tools';
import { color as colors, figures } from 'listr2';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For constancy shouldn't this be using the internal color util?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/cli 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