I’m new to Kotlin/JS Interoperability and got stuc...
# compose-web
y
I’m new to Kotlin/JS Interoperability and got stuck with this error:
"Calls to 'js(code)' must be a single expression inside a top-level function body or a property initializer"
My code tries to load a WebWorker with
js()
inside a Koin module, but it’s not allowed. Here’s the problem:
Copy code
actual val platformModule = module {
    single {
        val driver = WebWorkerDriver(
            Worker(
                js("""new URL("@cashapp/sqldelight-sqljs-worker/sqljs.worker.js", import.meta.url)""") // ❌ Error here
            )
        )
        LlmsDatabaseWrapper(driver, LlmsDatabase(driver))
    }
}
how could I fix this issue?
1
r
Create an additional helper function:
Copy code
fun someName() = js("...........")
and call
someName()
instead of
js()
in your code.
3
🙂 2
1
a
what Robert said. this is a question for #C0B8L3U69 , not compose web (you'll get more eyes there)
r
Or #CDFP59223 (less eyes but more competent 🙂)
a
#C0B8L3U69 -> for kotlin/js #CDFP59223 -> wasm mentioning the above cause webassembly can look disconnected to wasm
y
Thank you guys for the help. I'll post the question in Javascript channel