Commit e1679c0
perf(web): re-enable Turbopack dev — drop dead MDX JS plugin chain (#1780)
`next dev --turbopack` is 10–50× faster than the Webpack default for
HMR + per-route first-compile. PR #1667 disabled it because the inline
remark `containerDirective` plugin in `next.config.ts` was a closure
that Turbopack's worker pool cannot serialize. Empirically the entire
JS plugin chain has the same problem — even after the inline closure
is hoisted to its own module, `next dev --turbopack` still aborts with
Error: loader /node_modules/@next/mdx/mdx-js-loader.js for match
"#next-mdx" does not have serializable options.
The trade-off here is unusual: this plugin chain is **dead code at
compile time**. There are zero `.mdx` pages in `web/src/**` (verified
via `find` + `grep`). All runtime markdown rendering happens through
`web/src/components/markdown.tsx`, which keeps its own React-side
`react-markdown` pipeline (gfm, highlight, directives, frontmatter,
headerId) — that path is untouched.
So: drop the JS plugin chain from `createMDXPlugin`. The `withNextMDX`
wrapper is kept (so `mdx-components.tsx` stays wired) and
`pageExtensions` keeps `'mdx'` (so the route resolver still recognises
the extension). When `.mdx` pages are actually introduced, the
recommended path is `experimental.mdxRs: true` (Rust-based, Turbopack-
compatible) — see updated comment in `next.config.ts` for context.
Re-enable the flag in `web/package.json:dev`. Local verification:
`./node_modules/.bin/next dev --turbopack` reaches "Ready" in 1.5 s
with zero loader-serialization errors; `yarn tsc --noEmit` reports
zero errors.
§K.12 invariant cross-check
============================
Largely n/a (frontend dev tooling). Direct hit:
- #12 (grep-zero LightRAG) — `rg -i lightrag web/src/` returns zero
hits both before and after.
4-pattern pre-check matrix
==========================
- Pattern 1 v1 (`.mdx` page consumers): `find web/src -name '*.mdx'`
returns zero. `rg "from '[^']*\\.mdx'" web/src` returns zero.
Confirms the JS plugin chain has no live consumers.
- Pattern 1 v2 (runtime markdown plugin chain): unchanged in
`components/markdown.tsx`. Removing JS plugins from `next.config.ts`
does not affect document rendering — react-markdown imports its own
copy of remarkGfm / rehypeHighlight / etc. directly.
- Pattern 2 (response-shape change list): n/a, this PR does not touch
any backend or generated schema.
- Pattern 3 (additive helpers): n/a, dev-tooling only.
simple-stable directive 4-guardrail
===================================
- #1 不无限扩范围 — 2 files / +16 / -55. Did not extract plugins to
modules (would be future-only dead code given zero `.mdx` files);
did not switch to `experimental.mdxRs` (kept current MDX setup
empty-but-present so future adopters re-add plugins explicitly).
- #2 尽快上线 — earayu2 directive: edit code → instant reload, no
added manual burden. Turbopack ready in 1.5 s, HMR kicks in
automatically; `dev` script still runs `yarn install && yarn
i18n:sync` so engineers who pull dependency updates do not need
any extra command.
- #3 简单稳定 — fewer plugins is fewer moving parts. The runtime
markdown path keeps the production-tested chain.
- #4 私有化部署免维护 — operator-invisible; production builds
unaffected (zero `.mdx` files means `next build` output is identical
before/after).
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent e7eef9a commit e1679c0
2 files changed
Lines changed: 16 additions & 55 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | 4 | | |
17 | 5 | | |
18 | 6 | | |
| |||
57 | 45 | | |
58 | 46 | | |
59 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | | - | |
63 | 65 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | 66 | | |
106 | 67 | | |
107 | 68 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
0 commit comments