Hey Kotlin+WASM experts, I want to compile a Kotl...
# webassembly
k
Hey Kotlin+WASM experts, I want to compile a Kotlin library which will use SQLite to store and retrieve data. I want compilation target to be WASM. SQLite binaries are available as wasm files, how do I add that to my project? This library will be called from JS in browser. Any pointers on how do I process are much appreciated.
t
IIUC you're looking to compile a Kotlin library which has a Kotlin API for access SQLite (in C++ implementation). Is the SQLite source already compiled or do you need to compile that to wasm as well?
We partnered with the SQLite team to add an officially supported wasm target so that you can use SQLite directly from a JS API - see instructions here https://developer.chrome.com/blog/sqlite-wasm-in-the-browser-backed-by-the-origin-private-file-system/ Would be curious if this meets your need or if you need it to be a Kotlin interface 🙂
k
Hey @Thomas Nattestad thanks for the reply. I am using SQLite+OPFS in JS/TS already. But I was wondering how do I add that as a dependency so that SQLite api is accessible in Kotlin code.
Copy code
val wasmMain by getting {
    dependsOn(commonMain)
    dependencies {
        implementation("<what goes here>")
    }
}
I want to bundle the resulting code again as wasm and ship it to browser to be consumed by JS.