Any suggestions on the right way to wrap mermaid? ...
# javascript
r
Any suggestions on the right way to wrap mermaid? https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/mermaid.ts#L393 / https://mermaid.js.org/config/usage.html#using-mermaid-run I have:
Copy code
@JsModule("mermaid")
@JsNonModule
@JsName("mermaid")
external object Mermaid {
    fun run()
}
The first time I call Mermaid.run() it works, but any subsequent call after dynamically adding a diagram to the document fails with "Uncaught TypeError: mermaid.run is not a function"
t
JS
Copy code
export default mermaid;
Kotlin
Copy code
@file:JsModule("mermaid")

@JsName("default")
external object Mermaid {
    fun run()
}
r
Ah, makes sense - thanks. (I had to add @file:JsNonModule also to make it happy, but it works.)
t
You can use
es
or
comoonjs
module kind to avoid redundant
@JsNonModule
es
+
useEsClasses
= less bundle size