Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`rehype-raw` (and parse5) is always bundled, even when raw HTML is not used

Aperta
#660 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@sleitor ci sta già lavorando.

Dal 9/10/2026.

  • #663 di @sleitor — aperta

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

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, and raw is part of the default rehypePlugins array.
  • packages/streamdown/lib/markdown.ts — hasRehypeRaw() compares each plugin against the imported rehypeRaw by identity to decide whether to add remarkEscapeHtml (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)
  1. Replace the identity check with something that does not need the rehype-raw reference — e.g. a marker on the plugin (defaultRehypePlugins.raw being a small tagged wrapper defined next to the import), or an explicit option such as html: "render" | "escape".
  2. Then make the default the only place that pulls rehype-raw in, e.g. a lighter entry (streamdown/core or similar) whose defaults omit raw, or a streamdown/raw subpath 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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vercel/streamdown

Tutte le issue di vercel/streamdown

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.