@@ -5,6 +5,29 @@ import path from 'node:path';
55export const docs = defineDocs ( {
66 dir : path . resolve ( process . cwd ( ) , '../../content/docs' ) ,
77 docs : {
8+ /**
9+ * Load each page's compiled body on demand instead of statically importing
10+ * all of them into every server entrypoint.
11+ *
12+ * Without this, `fumadocs-mdx:collections/server` eagerly imports all 397
13+ * `.mdx` files, so every route that touches `source` — the docs page, but
14+ * also `/llms.txt`, `/llms-full.txt`, `/llms.mdx/*`, `/og/*`, `/api/search`
15+ * and `/sitemap.xml` — pulls the entire corpus into its own chunk. The
16+ * bundler then inlined the whole set five times over into one worker:
17+ * 2.50 MiB of authored MDX became a 100.93 MiB `handler.mjs`, and
18+ * Cloudflare rejects any Worker over 64 MiB uncompressed (`code: 10027`).
19+ *
20+ * The multiplier, not the corpus, was the problem: measured on the same
21+ * tree, one probe sentence from a single English page appeared 15 times in
22+ * the bundle before this flag and 6 times after, taking `handler.mjs` from
23+ * 100.93 MiB to 48.47 MiB.
24+ *
25+ * The cost is that `page.data.body` and `page.data.toc` become
26+ * `page.data.load()`. Frontmatter stays eager, so `title`, `description`,
27+ * `seoTitle` and `full` are unaffected, and `getText('processed')` — what
28+ * the llms.txt routes call — is still a method on the entry.
29+ */
30+ async : true ,
831 schema : pageSchema . extend ( {
932 /**
1033 * Optional SEO title: what the `<title>` tag should say, when that is not
0 commit comments