`rehype-raw` (and parse5) is always bundled, even when raw HTML is not used
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- electron, react, typescript, vite
- Ambito
- frontend, performance
Direzione di ricerca
Start with the two entry points named in the issue: packages/streamdown/index.tsx and packages/streamdown/lib/markdown.ts; trace how the default plugin list and hasRehypeRaw() determine whether rehype-raw is bundled and how HTML is rendered. Compare production bundle output with and without raw HTML enabled, while preserving the default rendering behavior. Done means the unused dependency can be excluded when raw HTML is not enabled, without changing the default behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
rehype-raw is imported at module top level in two places, so it and its dependency tree (hast-util-raw → parse5) end up in every bundle that imports streamdown, whether or not raw HTML rendering is enabled:
packages/streamdown/index.tsx—defaultRehypePlugins.raw = rehypeRaw, andrawis part of the defaultrehypePluginsarray.packages/streamdown/lib/markdown.ts—hasRehypeRaw()compares each plugin against the importedrehypeRawby identity to decide whether to addremarkEscapeHtml(the behavior from #330 / #331).
Because of the identity check, no bundler can drop it even for apps that pass their own rehypePlugins without raw. In our app (Vite production build of an Electron renderer, [email protected], attributed with source maps), this is about 234 KB of the initial chunk: parse5 ≈ 225 KB, hast-util-raw ≈ 9 KB, all dead code since we intentionally leave raw HTML out and show it as text.
Constraint
raw is on by default, so simply removing the import would change the default rendering of HTML. Whatever the fix is, the default <Streamdown> should presumably keep its current behavior.
Possible directions (maintainers know better)
- Replace the identity check with something that does not need the
rehype-rawreference — e.g. a marker on the plugin (defaultRehypePlugins.rawbeing a small tagged wrapper defined next to the import), or an explicit option such ashtml: "render" | "escape". - Then make the default the only place that pulls
rehype-rawin, e.g. a lighter entry (streamdown/coreor similar) whose defaults omitraw, or astreamdown/rawsubpath that apps opt into.
We'd be happy to test a change against our build.
Environment
- streamdown 2.7.0 (also checked current
main: same imports) - Vite 7 / electron-vite, ESM, production build
- Lingua principale
- TypeScript
- Stelle
- 5.7k
- Fork
- 316
- Merge medio
- 3g 13h
- PR unite (30g)
- 28
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vercel/streamdown
-
remend: unclosed `$$` in a table cell is closed on a new line when an earlier line has mathForse già presa @orinnz l’ha presa 24 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
vercel/streamdown#652 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
vercel/streamdown#699 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 50/100
vercel/streamdown#686 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
The word-fade engine ships with every app, whether or not it animatesForse già presa @xyrolle l’ha presa 10 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 1/100
vercel/streamdown#681 ·
I maintainer di solito rispondono entro 1 giorno
-
Mermaid's UI ships in the main bundle although the chart is lazy-loadedForse già presa @xyrolle l’ha presa 10 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
vercel/streamdown#679 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di vercel/streamdown
Issue simili
-
category::task code priority::normal
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
e0ipso/strikethroo#145 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
cocos/cocos-docs#3333 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
RevenueCat/react-native-purchases#2079 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
RevenueCat/purchases-hybrid-common#2039 ·
I maintainer di solito rispondono entro 1 giorno
-
agent-reported area/react bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno