Skip to content

Commit c274f45

Browse files
Merge pull request #268 from objectstack-ai/claude/pm-dispatch-objectos-cw8i2u
Revert "fix(docs): load MDX bodies on demand so the Worker fits Cloudflare's 64 MiB limit"
2 parents acf7021 + 06b80d1 commit c274f45

2 files changed

Lines changed: 2 additions & 29 deletions

File tree

‎apps/docs/app/[lang]/docs/[[...slug]]/page.tsx‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,7 @@ export default async function Page(props: {
240240
const page = source.getPage(params.slug ?? [], params.lang);
241241
if (!page) notFound();
242242

243-
// `async: true` on the docs collection makes the compiled body and toc
244-
// load on demand instead of being statically imported, so they are awaited
245-
// here. Frontmatter (`title`, `description`, `full`) stays eager.
246-
const loaded = await page.data.load();
247-
const MDX = loaded.body;
243+
const MDX = page.data.body;
248244

249245
// Resolved once and handed to both controls, so they cannot drift apart and
250246
// so a third control added below inherits the locale-independent URL instead
@@ -287,7 +283,7 @@ export default async function Page(props: {
287283
dangerouslySetInnerHTML={{ __html: jsonLdHtml(item) }}
288284
/>
289285
))}
290-
<DocsPage toc={loaded.toc} full={page.data.full}>
286+
<DocsPage toc={page.data.toc} full={page.data.full}>
291287
<DocsTitle>{page.data.title}</DocsTitle>
292288
<DocsDescription className="mb-0">{page.data.description}</DocsDescription>
293289
<div className="flex flex-row gap-2 items-center border-b pb-6">

‎apps/docs/source.config.ts‎

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,6 @@ import path from 'node:path';
55
export 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,
318
schema: pageSchema.extend({
329
/**
3310
* Optional SEO title: what the `<title>` tag should say, when that is not

0 commit comments

Comments
 (0)