mermaid-js / mermaid-cli

Command line tool for the Mermaid library
MIT License
2.53k stars 243 forks source link

fix: use mermaid IFFE instead of bundling mermaid #685

Closed aloisklink closed 6 months ago

aloisklink commented 7 months ago

:bookmark_tabs: Summary

Add support for Mermaid v10.9.0 and KaTeX, by importing the mermaid IFFE, instead of bundling it.

Since https://github.com/mermaid-js/mermaid-cli/commit/9e168fbf62b3f659330c712034c1063c3e0b9847, we're bundling mermaid using vite. The main reason was that back then, Mermaid was only offering an ESM version of some libraries, but puppeteer doesn't support importing ESM from file:// URLs, due to CORS errors.

Unfortunately, the large size of KaTeX in Mermaid v10.9.0 seems to be somehow breaking mermaid-cli on slow computers.

However, Mermaid v10.2.0 added back the IFFE bundle, so we can now use that instead, in a <script src='file://'>, and we therefore don't need to bundle it.

This seems to fix the issue. It also means that we can move mermaid from devDependencies to a dependencies, allowing users to update their mermaid version independently from mermaid-cli!

Resolves https://github.com/mermaid-js/mermaid-cli/issues/680 Closes https://github.com/mermaid-js/mermaid-cli/pull/663

:straight_ruler: Design Decisions

Describe the way your implementation works or what design decisions you made if applicable.

:clipboard: Tasks

Make sure you

MindaugasLaganeckas commented 6 months ago

Thank you :)

aloisklink commented 6 months ago

Sorry it took so long :) I've been pretty busy (and was ill for a while too) recently, and I didn't realize the fix would be so simple!

@MindaugasLaganeckas, can you make a v10.9.0 release? I still don't know the release process :laughing:

Mermaid v11 is apparently going to be the next Mermaid release, so I'll hopefully also start working on some breaking changes, like finally upgrading Puppeteer and dropping Node.JS v14 and v16 support.

MindaugasLaganeckas commented 6 months ago

I will document the release procedure :) Thank you :)