Skip to content
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

Switch to mri and yoctocolors for better performance? #253

Closed
so1ve opened this issue Apr 20, 2023 · 9 comments
Closed

Switch to mri and yoctocolors for better performance? #253

so1ve opened this issue Apr 20, 2023 · 9 comments

Comments

@so1ve
Copy link
Member

so1ve commented Apr 20, 2023

I can contribute to this:)

@haoqunjiang
Copy link
Member

@so1ve
Copy link
Member Author

so1ve commented Apr 21, 2023

Actually yoctocolors supports environment variables. They are handled in tty.WriteStream.prototype.hasColors (a built-in node module)!

@so1ve
Copy link
Member Author

so1ve commented Apr 21, 2023

And for now we can switch to mri for smaller size because util.parseArgs is still unstable.

@haoqunjiang
Copy link
Member

Actually yoctocolors supports environment variables. They are handled in tty.WriteStream.prototype.hasColors (a built-in node module)!

Thanks for the info! Good to know that. Then I'm not against switching to yoctocolors.

However, I just did some research and found that picocolors is both smaller and more popular than yoctocolors. Maybe that's a better alternative?

https://packagephobia.com/result?p=picocolors
https://packagephobia.com/result?p=yoctocolors
https://npmtrends.com/picocolors-vs-yoctocolors

@haoqunjiang
Copy link
Member

And for now we can switch to mri for smaller size because util.parseArgs is still unstable.

It is stable in Node.js 20, and the API isn't much different from what has been implemented in v16 and v18.

Considering we will switch to it eventually, I don't feel like migrating to mri for the marginal improvement in package sizes. Reviewing PRs also takes time.

@so1ve
Copy link
Member Author

so1ve commented Apr 25, 2023

Actually yoctocolors supports environment variables. They are handled in tty.WriteStream.prototype.hasColors (a built-in node module)!

Thanks for the info! Good to know that. Then I'm not against switching to yoctocolors.

However, I just did some research and found that picocolors is both smaller and more popular than yoctocolors. Maybe that's a better alternative?

https://packagephobia.com/result?p=picocolors https://packagephobia.com/result?p=yoctocolors https://npmtrends.com/picocolors-vs-yoctocolors

Maybe…? However yoctocolors seems to have better performance. Benchmark later :)

@haoqunjiang
Copy link
Member

Why does performance matter in the use case of create-vue? There are only a few calls to the color functions; the difference might be only a few μs.

@so1ve
Copy link
Member Author

so1ve commented Apr 26, 2023

Why does performance matter in the use case of create-vue? There are only a few calls to the color functions; the difference might be only a few μs.

Makes sense. Let's switch to picocolors!

haoqunjiang added a commit that referenced this issue Oct 11, 2024
The size of `outfile.cjs` before the change:
143037 bytes

Ater the change:
141514 bytes

Saved 1523 bytes.

I didn't choose `picocolors` despite it being more popular because
it doesn't support tree-shaking and actually increases the bundle size
a bit.

I didn't choose `yoctocolors` because the resulting bundle is also a bit
larger than the one produced by `kleur/colors`.

Addressed the issue raised in #253
@haoqunjiang
Copy link
Member

I eventually switched to kleur/colors in 0395555
Because turns out it produces the smallest bundle for our usage…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants