Closed prantlf closed 2 weeks ago
Thank you for taking time to contribute!
I will need a bit more time to thoroughly review the changes, apologies for the delay.
The very least I can say is that the decision to drop Node.js v6 should not be in the scope of this PR. This is something better be done in a separate PR and dropping anything below v10.16 would allow us to simplify color detection by a lot. Most likely a breaking change, so we gotta check if the largest user would be okay with it moving forward cc @ai
Another thing I'd like to point out is that yoctocolors
is not a serious package to keep alongside others. At the very least, it's not complete. See how the code snippets from complex benchmark work:
Let's remove yoctocolors from benchmarks.
dropping anything below v10.16 would allow us to simplify color detection by a lot. Most likely a breaking change, so we gotta check if the largest user would be okay with it moving forward cc @ai
Browserslist supports Node.js 6 and releasing new major is very painful for the project.
But I think I can just avoid requiring picocolors
on old Node.js versions in Browserslist. Anyway it is too old version.
Another thing I'd like to point out is that yoctocolors is not a serious package to keep alongside others. At the very least, it's not complete.
It is now: https://github.com/sindresorhus/yoctocolors/releases/tag/v2.0.1
Fixes #45.
Changes
The latest version of
chalk
does not support CJS, but it is possible to bundle it in the CJS format. It is worth testing the latest available version.yoctocolors
does not support CJS, but it is possible to bundle it in the CJS format. This library aspires to be the new tiniest one. It supportsFORCE_COLOR
andNO_COLOR
too. It is worth comparing it topicocolors
.Split
chalk
tochalk4
andchalk5
using NPM module aliases. Also upgrade development dependencies. Keep the same major version ofclean-publish
not to break the legacy Node.js tests.Use
esbuild
to create CJS bundles ofchalk5
andyoctocolors
. Addchalk5
andyoctocolors
to every benchmark. Rename the formerchalk
tests tochalk4
.Results
The
simple.js
benchmark shows 5% decrease of performance inchalk
5 againstchalk
4.yoctocolors
beatpicocolors
by 284%.The
complex.js
benchmark shows 3% decrease of performance inchalk
5 againstchalk
4.yoctocolors
beatpicocolors
by 61%.The
loading.js
benchmark shows 44% decrease of performance inchalk
5 againstchalk
4.yoctocolors
is 75% slower thanpicocolors
. I tried replacing the color detection inyoctocolors
with the code frompicocolors
and the loading time went down to 0.588 ms, 52% slower thanpicocolors
.The
size.js
benchmark shows 57% size reduction forchalk
5 againstchalk
4.yoctocolors
is practically the same aspicocolors
. This benchmark isn't reliable, because the size of the actually used code may be much smaller, as the comparison of the single-file librariesyoctocolors
andpicocolors
shows.