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

Please provide a "server-only" mode to avoid excessive client-site bundle size #248

Open
stefanobartoletti opened this issue Aug 21, 2024 · 1 comment

Comments

@stefanobartoletti
Copy link
Contributor

stefanobartoletti commented Aug 21, 2024

Just like the title says, please provide a server-only mode that will not include all dependencies in the client-side bundles.

The use-case scenario is like that:

  • The context is a SSG Nuxt site, with content fetched from a headless CMS
  • MD content is fetched from the CMS, nuxt/mdc is used to process it and transform to a valid HTML.
  • Once source markdown content has been processed, nuxt/mdc is no longer used.

Currently, a lot of heavy dependencies are still included in the final client bundles, like shiki and all its code syntax definitions and sub-deps, emojilib (see #187), and possibly other.

Some client-size bundle analysis by running nuxi analyze without MDC dependencies:

Screenshot_20240821_053635

And with MDC included:

Screenshot_20240821_053339

As you can see, the final global size is more than doubled, and all that code is never used again after the fetch & transform from the CMS (also note that this specific project is already quite heavy as it packs some animation and 3D libraries, in a more standard project the ratio between MDC code and other would be even more unbalanced)

There is an old comment where a possible addition of server-only and client-only modes was mentioned (#135 (comment) ), is this still a planned feature?

@stefanobartoletti
Copy link
Contributor Author

stefanobartoletti commented Sep 13, 2024

After updating to version v0.9.0, this problem has been mitigated, I think by implementing some dynamic import from #253

Screenshot_20240913_062515

As you can see, now the bundle is significantly lighter than before.

@farnabaz I'm not sure if the changes incorporated from this PR can also be applied to the remaining dependencies (probably not), but maybe this is a first step into making this package of a decent size for production environments.

Thanks for your work!

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