feat: switch from picocolors to ansis #474
Merged
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.
Hello @antfu,
I'm the author of ansis, a smaller and faster drop-in replacement for Chalk.
I know, Chalk@4 was already used, which was very large and had 2 dependencies.
So Chalk was replaced with Picocolors, here is the commit from Dec 28, 2021.
But these changes have "degraded" the code readability:
Nested calls leads to "Parenthesis Hell" and it works 2x slower than chained syntax for the example above.
With Ansis, we can return to the original "chalk-like" clean and more readable syntax, while still being as small as a Picocolors:
Unpacked package size
Ansis is almost as small as Picocolors:
chalk@5
: 44.2 kBpicocolors
- 6.4 kBаnsis
- 6.8 kBThe difference with
picocolors
is0.4 kB
, but Ansis has the functionality of Chalk.Picocolors doesn't handle important edge cases, so it is the smallest.
Today, the two smallest and fastest libraries are
picocolors
andansis
.Both are recommended by the
e18e
community.Popularity
picocolors
~60m+ weekly downloads.ansis
~1.3m weekly downloads with steady growth. This is enough to be considered popular, though yet not as much as Picocolors.Who already uses Ansis
unjs/webpackbar, NestJS, Sequelize, Salesforce CLI, Oclif, Facebook/stylex, Grafana
Test
The cmd

npm run test:build
outputs: