This is a question that vexed me for quite some time, so for anyone coming across this later I want to update this thread to note that there are now two good options for using Mermaid.JS within TW5:
Lightweight TiddlyWiki5 plugin that wraps Mermaid Live Editor:
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/
"Complete" Mermaid.js library installation into TW5:
Demo wiki: https://efurlanm.github.io/mermaid-tw5