Open bentsherman opened 1 week ago
I think it would help if we bundle mermaid into the package of the extension itself in the webpack config:
plugins: [
new CopyWebpackPlugin({
patterns: [
{
from: 'node_modules/mermaid/dist/mermaid.esm.min.js',
to: 'resources/mermaid.js'
}
]
})
]
Then we can refer to mermaid as the bundled "copy" instead of the one from the CDN. I can give it a go if you want @bentsherman
Sounds good, feel free to give it a try!
The VS Code extension uses a webview to render DAG previews, and the webview HTML simply embeds the mermaid-js library, which means the library is downloaded when the webview is created:
This means it requires an internet connection. So it would be nice to embed the mermaid-js library into the extension somehow so that it works offline.
I thought we might be able to import it as a server-side dependency, but it turns out that mermaid-js relies on the browser context (!) to render the SVG code. So it seems like we have to do it in the browser (or the mermaid CLI, which just spins up a headless browser...)
Instead, maybe it's possible to reference some kind of "resource" path here instead of an http url:
https://github.com/nextflow-io/vscode-language-nextflow/blob/b98a5ac48744e7fca572a3ff3a3010e96363bcce/src/main/ts/extension.ts#L117
Need to investigate whether that's possible with vs code extensions