-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor!: replace ansi-colors with smaller and faster ansis #5274
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey thanks for sending this in @webdiscus!
- Addresses an existing open issue: fixes #000
- That issue was marked as status: accepting prs
In the future, could you please file issues before sending nontrivial PRs? Per our contributing guidelines we prefer discussing changes before implementing. It can be hard to know whether an approach is the right one to spend development time on, and it's awkward telling someone to redo lots of work.
This PR is a good example of that: it's not clear to me why you'd want ansis
(300k weekly downloads) over picocolors
(31m weekly downloads).
I'll note that per https://github.com/webdiscus/ansis?tab=readme-ov-file#-unpacked-size, picocolors
is both a smaller size and faster when applying single styles. But both of those are such negligibly small differences that I doubt they matter for Mocha's usage.
👋 Ping @webdiscus - do you have thoughts on |
Hello @JoshuaKGoldberg, I'm sorry, I thought you had already decided to close this PR. I'm the author of the ansis. My goal is to help in choice the most suitable replacement for older, larger libraries. SizeAnsis is almost as small as Picocolors: The difference is PerformanceCaution All libraries are more than fast enough. The benchmark results only to show the effectiveness of micro-optimizations in the code, which does not impact on real-world usage. Picocolors doesn't handle important edge cases, so it is the fastest and smallest.
Which One Should You Use?Here is the checklist:
Yes, you are right, in these concrete use cases, in Mocha, Picocolors is enough.
During the New Year period, NPM had a drop in statistics, as it does now :-/ What is your final decision?If you choose Picocolor, I respect it. 👍🏻 |
Agreed, they're all fast enough that it doesn't matter for Mocha's use case.
😁 I appreciate and respect that you're paying attention to this, but personally disagree with the ✅ / ❌ framing of the opinion. That's a stylistic preference I don't share. I actually prefer a single named export like Anyway, this is getting to be a longer discussion and we generally use issues for that. I'm going to go ahead and file a new issue. Thanks for starting the discussion!
In the future I'd recommend going through the contributing guidelines and filing an issue first. As a fellow open source maintainer I feel bad drafting or closing a PR that had good + earnest work put into it like this one. |
PR Checklist
status: accepting prs
Overview
This PR replaces the outdated ansi-colors (last update 3 years ago) package with smaller and faster ansis.
Benefits of
ansis
ESM
andCommonJS
Bun
andDeno
runtimesTypeScript
ansi-colors
API, plus supports named import:import { red, yellow } from 'ansis'
10 kB
(ansi-colors
26 kB), see Compare the size of most popular packagesansi-colors
, see BenchmarksTrueColor → 256 colors → 16 colors → no colors
NO_COLOR
FORCE_COLOR
and flags--no-color
--color
Packages that already use
ansis
Test
This PR does not require unit/integration tests.
But you can do the
manual test
.Install the fork
Test changed files
Cmd:
In console output will be displayed color text:
Cmd:
In console output will be displayed b&w text:
Cmd:
In console output will be displayed red text: