Skip to content

fix(deps): remove mermaid as hard runtime dependency#502

Open
sleitor wants to merge 2 commits intovercel:mainfrom
sleitor:fix-501
Open

fix(deps): remove mermaid as hard runtime dependency#502
sleitor wants to merge 2 commits intovercel:mainfrom
sleitor:fix-501

Conversation

@sleitor
Copy link
Copy Markdown
Contributor

@sleitor sleitor commented Apr 10, 2026

Problem

Fixes #501

mermaid is listed in dependencies of the core streamdown package, but it is never actually imported at runtime — only import type { MermaidConfig } appears in source files. The actual mermaid runtime is exclusively owned by the optional @streamdown/mermaid plugin package.

This forces ~75 MB of mermaid into every install of streamdown, even for users who have no interest in diagram rendering.

Fix

  1. Remove mermaid from dependencies in packages/streamdown/package.json.

  2. Replace import type { MermaidConfig } from 'mermaid' in three files with a local structural type:

    // biome-ignore lint/suspicious/noExplicitAny: structural pass-through for mermaid config
    export type MermaidConfig = Record<string, any>;

    Since the config is only ever passed through to the plugin (never inspected in core), this is fully compatible. Users who want exhaustive type-safety can still import type { MermaidConfig } from 'mermaid' — TypeScript's structural typing ensures it remains assignable.

  3. Add changeset (patch bump for streamdown).

Verification

  • pnpm build ✅ — dist/index.d.ts no longer contains from 'mermaid'
  • pnpm test ✅ — 982/982 tests pass
  • pnpm biome check

mermaid was in dependencies but is only used as an import type in the
core package. All runtime usage lives in @streamdown/mermaid plugin.

Replace import type { MermaidConfig } from 'mermaid' with a local
structural type so no type-level coupling remains in the dist bundle.

Fixes vercel#501
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 10, 2026

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

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@vercel vercel Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestion:

Two source files still import MermaidConfig from the removed "mermaid" package, which will break dts generation and published type declarations.

Fix on Vercel

…kage

Fix download-button.tsx, fullscreen-button.tsx, and mermaid.test.tsx
which still imported MermaidConfig directly from the 'mermaid' package.
All three now use the local structural type from lib/plugin-types.ts.

Addresses VADE review feedback on vercel#502.
@sleitor
Copy link
Copy Markdown
Contributor Author

sleitor commented Apr 10, 2026

Good catch from VADE! Fixed in 56e02a1download-button.tsx, fullscreen-button.tsx, and mermaid.test.tsx now all import MermaidConfig from the local ../plugin-types (or ../lib/plugin-types for the test). No more coupling to the mermaid package in any of the source files.

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.

mermaid remains a hard dependency in 2.5.0, contradicting the plugin docs (adds ~75 MB to every install)

1 participant