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

lazily import parsers #2763

Closed
danielroe opened this issue Aug 24, 2024 · 0 comments · Fixed by #2780
Closed

lazily import parsers #2763

danielroe opened this issue Aug 24, 2024 · 0 comments · Fixed by #2780
Assignees

Comments

@danielroe
Copy link
Member

currently the way the code is written means that shiki + other parsing dependencies are imported alongside the event handler definition, and rollup eagerly imports them at the top level of the nuxt server, generating imports like:

import 'shiki/core';
import '@shikijs/transformers';
import 'unified';
import 'mdast-util-to-string';
import 'micromark';
import 'unist-util-stringify-position';
import 'micromark-util-character';
import 'micromark-util-chunked';
import 'micromark-util-resolve-all';
import 'micromark-util-sanitize-uri';
import 'slugify';
import 'remark-parse';
import 'remark-rehype';
import 'remark-mdc';
import 'remark-emoji';
import 'remark-gfm';
import 'rehype-external-links';
import 'rehype-sort-attribute-values';
import 'rehype-sort-attributes';
import 'rehype-raw';
import 'detab';
import 'hast-util-to-string';
import 'github-slugger';

That means these files are imported even when a non-content related endpoint is hit.

If we can move code to use dynamic (cached) imports we can significantly improve the performance for non-content endpoints.

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

Successfully merging a pull request may close this issue.

2 participants