Skip to content

feat: add streamdown/core entry without rehype-raw - #663

Open
sleitor wants to merge 1 commit into
vercel:mainfrom
sleitor:feat/optional-rehype-raw
Open

sleitor wants to merge 1 commit into
vercel:mainfrom
sleitor:feat/optional-rehype-raw

Conversation

@sleitor

@sleitor sleitor commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a streamdown/core entry whose default rehype plugins omit rehype-raw, so rehype-raw and parse5 are not bundled. The default streamdown entry is unchanged (raw HTML stays on).

Type of Change

  • New feature (non-breaking change which adds functionality)

Related Issues

Closes #660

Changes Made

  • lib/markdown.ts no longer imports rehype-raw. Detection goes through a small registry (lib/raw-registry.ts), with a plugin.name === "rehypeRaw" fallback for user-supplied plugins. remarkEscapeHtml behaviour is unchanged and the processor cache key is untouched.
  • lib/default-raw.ts is now the only module importing rehype-raw; it registers the plugin. index.tsx uses it for defaultRehypePlugins.raw and the allowedTags path.
  • tsup.config.ts builds a second entry, core, with an esbuild plugin that swaps default-raw for a stub (lib/default-raw.core.ts).
  • package.json: new ./core export. Docs: note in configuration page.

Bundle size (esbuild --bundle --minify, react/shiki external, importing Streamdown):

entry size parse5
streamdown 530,705 B yes
streamdown/core 336,317 B no

Caveat: with streamdown/core, a user-supplied rehype-raw is detected by function name (rehypeRaw), which a minifier could rename; in that case HTML would be escaped.

Testing

  • All existing tests pass
  • Added new tests for the changes

New __tests__/raw-html-detection.test.tsx: default renders raw HTML; custom plugins without raw still escape; user-supplied rehypeRaw (with and without options) is detected.

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have created a changeset (pnpm changeset)

Changeset

  • I have created a changeset for these changes

@vercel

vercel Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@sleitor is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant