feat!: make @mermaid-js/mermaid-cli an optional peer dependency - #298
Merged
Conversation
keonik
force-pushed
the
feat/293-optional-mermaid-cli
branch
from
August 19, 2026 19:22
c489076 to
ade7141
Compare
mmdc is only ever invoked as an external binary, and text output returns before it is ever reached, so every user was installing the CLI, mermaid and a headless Chromium whether or not they could use them. Alongside that: - add .mmd output (bare mermaid, no code fence) - fail with an actionable message naming the package to install - resolve the CLI before building the puppeteer config, so a missing CLI is not buried under the arm64 `which chromium` probe - stop `find ../.. -name mmdc` from crashing where find is unavailable BREAKING CHANGE: users rendering .svg/.png/.pdf must install @mermaid-js/mermaid-cli themselves. Closes #293 Closes #176
keonik
force-pushed
the
feat/293-optional-mermaid-cli
branch
from
August 20, 2026 02:20
ade7141 to
c4d95e6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #293
Closes #176
majorchangeset.What
mmdcis only ever invoked as an external binary (node_modules/.bin/mmdc), never imported. And for.mdoutputgeneratereturns long before anything touches it. So every user was installing the CLI — plusmermaid(~76 MB) and a headless Chromium via itspuppeteerpeer — whether or not they could ever use it.It moves to an optional peer:
Thanks @RPDeshaies and @mo-ayala for the original Docker-image write-up on #176 — this is the fix for that.
Migration
Rendering
.svg/.png/.pdf— the default output is./prisma/ERD.svg, so this is most people:Rendering
.md/.mmd: nothing to do, and you can now drop both packages.The README install block, the output-extension table, and a "Upgrading to 3.x" section all say this.
Also in here
Small things that only make sense alongside the above:
.mmdoutput — writes bare mermaid with no code fence. Remove puppeteer dependency when outputting mermaid markdown #176 asked for.md/.mmd; only.mdexisted.An actionable error. Previously a missing CLI gave
Expected mermaid CLI at <path> or undefined but this package was not found.Now:CLI resolved before the puppeteer config is built. That config exists only to be passed to
mmdc, so building it first meant a missing CLI got buried under the arm64which chromiumprobe dumping aCommand failed: which chromiumstack trace first. Verified before/after in an isolated directory.find ../.. -name mmdcno longer crashes. It was an unguardedexecSync, so on Windows (nofind) or a missing parent it threw a spawn error instead of falling through to "not found" — plausibly part of Installation bug: reify:poppeteer-core: timing... #183. Now a failed search is just a miss.Testing
__tests__/textOutput.test.ts—.mdfencing,.mmdbare output, and a guard that@mermaid-js/mermaid-clistays out ofdependenciesand stays marked optional, so this doesn't silently regress.@mermaid-js/mermaid-climoved todevDependencies, so CI and local runs still render real SVGs.node_modulesto confirm the message and the ordering fix.