Yassine Abou
06/09/2025, 3:07 AM"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:
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?Robert Jaros
06/09/2025, 4:32 AMfun someName() = js("...........")
and call someName()
instead of js()
in your code.Alex Styl
06/09/2025, 9:33 AMRobert Jaros
06/09/2025, 9:41 AMAlex Styl
06/09/2025, 9:45 AMYassine Abou
06/09/2025, 2:59 PM