Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#660 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@sleitor ya está trabajando en esto.

Desde el 9/10/2026.

  • #663 de @sleitor — abierto

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
electron, react, typescript, vite

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
TypeScript
Estrellas
5.7k
Forks
307
Merge medio
1 d 22 h
PR fusionados (30 d)
22

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de vercel/streamdown

Todos los issues de vercel/streamdown

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.