content
content copied to clipboard
lazily import parsers
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.