Hi, I'm using KMP to build the new version of https://github.com/unit-mesh/auto-dev . Now I had a qu...
p
Hi, I'm using KMP to build the new version of https://github.com/unit-mesh/auto-dev . Now I had a question about use WASM in Kotlin. I try to use @JSModule but no working: JsException: Exception was thrown while running JavaScript code I don't know how to debug so changes to @JSFun
Copy code
/**
 * Not working
 */
@JsModule("web-tree-sitter")
external object ParserModule : JsAny {
    fun init(): Promise<JsAny>
}

/**
 * Final version
 */
@JsFun("async () => { const ts = await import('web-tree-sitter'); await ts.default.init(); return ts.default; }")
external fun initTreeSitter(): Promise<TreeSitterModule>
I want to now for Web version, is its will cause performance issue to use JSFun? Or maybe have better way?
t
cc @bashor
🙏 1
b
With Kotlin 2.2.20+ you should get more actionable exception
I guess it should be something like
Copy code
@JsModule("web-tree-sitter")
external object WebTreeSitter {
    @JsName("default")
    object ParserModule : JsAny {
        fun init(): Promise<JsAny>
    }
}
p
Thanks. Since my project Kotlin version is 2.2.0, i will try it in a new project to test this.