This is a question that vexed me for quite some time so I want to offer an update this thread for anyone coming across this later.
There are now two good options for using Mermaid.JS within TW5:
"Complete" Mermaid.js library installation into TW5: As noted above, this is the full library, but has been updated as of October 2021 and published with a demo wiki to make installation a breeze.
Demo wiki: https://efurlanm.github.io/mermaid-tw5
Lightweight TiddlyWiki5 plugin that wraps Mermaid Live Editor: I just published this as a very lightweight (18kb) “wrapper” of the Mermaid Live service which handles all the rendering. All the power of Mermaid with streamlined code management and virtually no TW bloat.
YouTube: https://www.youtube.com/watch?v=e78RRDp-NZg
GitHub repo: https://github.com/jasonmhoule/tw5-mermaid
Demo wiki: https://jasonmhoule.github.io/tw5-mermaid/