Commit e242d76
fix(cf): lazy-load MarkdownChat to shrink worker bundle further
MarkdownChat statically imports remark-math, remark-gfm, remark-directive,
rehype-katex, rehype-highlight, plus side-effect CSS for katex and
highlight.js, and renders MermaidBlock/FunctionPlot. Even though the
component is "use client", static-importing it from ChatPanel.tsx,
screens/Library.tsx, and screens/Study.tsx pulled the whole markdown
stack into the OpenNext server handler.
Switch all three call sites to `dynamic(() => import(...), { ssr: false })`
so MarkdownChat becomes a separate client chunk.
Local cf:build verification:
- handler.mjs uncompressed: 9,933 KiB → 5,041 KiB
- handler.mjs gzipped: 2,577 KiB → 1,331 KiB (well under 3 MiB)
- mermaid/katex/highlight.js refs in handler.mjs: 79 → 0
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 8ae9fe8 commit e242d76
3 files changed
Lines changed: 27 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
6 | 16 | | |
7 | 17 | | |
8 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
10 | 17 | | |
11 | 18 | | |
12 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
11 | 18 | | |
12 | 19 | | |
13 | 20 | | |
| |||
0 commit comments