-
Notifications
You must be signed in to change notification settings - Fork 117
Use installed mermaid package #71
Comments
This workaround worked for me: #59 |
My workaround is making an executable file at
{
"dependencies": {
"mermaid": "^8.4.4",
"puppeteer": "^2.0.0"
}
}
#!/usr/bin/env node
const puppeteer = require("puppeteer");
const fs = require("fs");
const input = fs.readFileSync(process.argv[2], "utf8");
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.addScriptTag({ path: "node_modules/mermaid/dist/mermaid.min.js" });
const result = await page.evaluate(
async ({ input }) => {
const element = document.createElement("div");
element.id = "root";
document.body.appendChild(element);
return await new Promise(resolve =>
mermaid.mermaidAPI.render("root", input, resolve)
);
},
{ input }
);
console.log(result);
await browser.close();
})(); chmod +x bin/mmd Usagebin/mmd UML.mmd > UML.svg |
Development has moved to the https://github.com/mermaid-js/mermaid-cli repo, please re-open your issue there if it's still relevant.
FYI, since Mermaid v10.0.0 this isn't very easy to do. Now that Mermaid is ESM only, you need If you do want to use your own version of mermaid, you can do something like |
Instead of copying in a static version of mermaid is it not possible to move mermaid to a normal (non-dev) dependency and have the JS code pull in the package version? Or perhaps better yet make it a peer dependency and then the installer can pick the version they want?
The text was updated successfully, but these errors were encountered: