How tied to the browser is mermaid.js can I compile it to wasm? #4789
taylorh140
started this conversation in
General
Replies: 1 comment
-
Unfortunately, Mermaid not only requires a DOM, but it also requires a layout engine, which currently, only browser engines support. There's some discussion of approaches that might work in #3650, but it will most likely take quite a lot of work, so I wouldn't count on it anytime soon, unfortunately. But, contributions are welcome! If you want to use Mermaid in a server-side tool, the only current way to do it is to use something like puppeteer or playwright to run a browser headlessly. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was looking to see if I could make a wasm plugin that contained mermaid.js, but the layout looks pretty complicated and many javascript engines don't have a DOM. When I tried to get it to run on something other than a browser it seems to be missing a lot of components.
"console", "document" ...etc. i suppose it's to be expected.
The goal is to transform mermaid.js to asm file which i can then use in a local plugin.
I also notice that there is a very large number of async and await elements. I guess it would be nice to discuss how i would go about this? or if it seems impractical at the moment.
my first attempt was to use emscripten + duktape + mermaid.js to encapsulate all the functionality. duktape didn't support backticks for string delimiters.
Then I attempted with rust + boa + mermaid.js
It was then I learned that it consists of a lot of separate files that are all loaded dynamically. It would be nice if I could get it in a single file.
(optimize last)
I thought it would be good to ask here since you guys know JavaScript and mermaid.js better than I do. It might be possible that a particular subset of the files and functions is more suited to this transformation. Also there may be projects already dedicate to this end (I don't know of any)
Beta Was this translation helpful? Give feedback.
All reactions