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

Is there a way to minimize usage or properly tree-shake emojilib dependency? #187

Open
stefanobartoletti opened this issue Apr 24, 2024 · 0 comments

Comments

@stefanobartoletti
Copy link
Contributor

stefanobartoletti commented Apr 24, 2024

I'm in the process of optimizing a Nuxt website, and I noticed that there is a quite large part of the bundle that is made up of the emojilib package.

A quick analysis of my pnpm-lock.yaml is telling me that this dependency is loaded from

@nuxtjs/mdc>remark-emoji>node-emoji>emojilib

Screenshot_20240424_110341

As you can see from the breakdown (this is the output of nuxi analyze), the emojis.json chunk is quite large, ~205/35gzip kb.

Is there a way to minimize its usage? I would say that not every project that needs Markdown also needs emojis, especially not the full library, especially since it has such relevant import cost.

Is there a way to properly tree-shake it, whitelist it, or any other way to reduce its size and avoid such heavy and mostly unused bundle? I also find it puzzling to see this running client-side.

Another possible solution would be to make remark-emoji an optional dependency, since, from what I see by reading its docs https://github.com/rhysd/remark-emoji, this package is used to transform emojis from this notation :rocket: to the proper emoji 🚀 (which is not handled by this library, but by an emoji font).

So in cases where the content editor directly uses emojis and not the :: notation, the whole package is basically not even used.

Thanks for this great module anyway, this is just a minor but useful optimization 💚

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

1 participant