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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce bundle size of @babel/codeframe #14213

Closed
1 task done
TimvdLippe opened this issue Jan 29, 2022 · 6 comments 路 Fixed by #16359
Closed
1 task done

Reduce bundle size of @babel/codeframe #14213

TimvdLippe opened this issue Jan 29, 2022 · 6 comments 路 Fixed by #16359
Milestone

Comments

@TimvdLippe
Copy link

馃捇

  • Would you like to work on this feature?

What problem are you trying to solve?

Reduce the bundle size of projects that depend on @babel/codeframe

Describe the solution you'd like

We are working on reducing the bundle size of Prettier, tracked in prettier/prettier#12144

In prettier/prettier#12144 (comment) @daKmoR suggested to switch Chalk in @babel/codeframe to colorette, which should reduce the size of the package by 19kB (as Chalk pulls in 20kB and colorette is 1kB)

Can we remove large dependencies from @babel/codeframe and reduce its disk footprint?

Describe alternatives you've considered

Keep Chalk and keep a large bundle

Documentation, Adoption, Migration Strategy

No response

@babel-bot
Copy link
Collaborator

Hey @TimvdLippe! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@nicolo-ribaudo
Copy link
Member

colorette only supports Node.js 10+, and unfortunately Babel 7 still supports Node.js 6.

We can consider it to Babel 8, comparing it to updating chalk from v2 to v5.

@nicolo-ribaudo
Copy link
Member

Uh, apparently we export a whole chalk instance from @babel/highlight (a dependency of @babel/code-frame), making it part of the public API 馃槙

We cannot remove chalk until Babel 8, even if we find a library that supports Node.js 6.

@daKmoR
Copy link

daKmoR commented Jan 30, 2022

right - now that you mention it... I remembered seeing that in code last time I investigated... was the reason I did not even open an issue to discuss it back then, as I figured it will never happen 馃檲.

too bad... 馃槶

@TrySound
Copy link
Contributor

TrySound commented Jan 30, 2022

https://github.com/alexeyraspopov/picocolors has enough node support as already used by browserslist the dependency of babel. There is also a shim for browsers which may simplify bundling.

UPD: Ouch, missed the comment about exported chalk. Anyway migrating to picocolors in v8 would reduce bundle size.

@daKmoR
Copy link

daKmoR commented Jan 30, 2022

anything that is less than let's say 5kB would be an improvement 馃憤

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

Successfully merging a pull request may close this issue.

6 participants