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

Dynamic import of shikiji adds 1.2Mb to gzipped bundle #183

Open
dpeek opened this issue Mar 12, 2024 · 1 comment
Open

Dynamic import of shikiji adds 1.2Mb to gzipped bundle #183

dpeek opened this issue Mar 12, 2024 · 1 comment

Comments

@dpeek
Copy link

dpeek commented Mar 12, 2024

Hi there! I'm using jsx-email in a serverless context (Cloudflare Workers) and noticed my bundle size jumped quite a bit after adding jsx-email. After some investigation it seems that the Code component importing shikiji is the main culprit, adding almost 8MB of uncompressed (1.2Mb gzipped) javascript to the bundle.

This isn't a blocker as I'm still below the worker size limit (although above what they recommend). Still, it seems like it would be nice to allow users to opt-out of this dependency (it's unlikely we'll need code highlighting in our emails!)

I've tried importing components individually, but I guess since renderer references them all it's impossible for them to be tree-shaken? Perhaps you could change the API so that users can pass in a highlighting function to the renderer?

@shellscape
Copy link
Owner

Thanks for the issue. This is a known problem that we're working on, and also impacts #82. For the moment, the fix is to simply exclude shijiki (in the next major that'll be shiki) in your bundler config.

since renderer references them all

I don't believe that's the issue, but we're def working to improve tree shaking.

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