Open Burtan opened 1 year ago
Hi @Burtan. We are looking into JS support, but there are quite a few technical challenges associated with it, like building the core database for WebAssembly and making sure the threading model will still work. So we don't really have any sort of timeline for it yet.
I'm curious if this is more feasible now with the Kotlin/WASM target. Would it be as simple as adding the following target to build.gradle.kts
files?
wasm {
browser()
}
@gxhenderson Once it is working, yes, that should be enough. Unfortunately, it is a bit more complicated behind the scenes, so that will not work yet.
@cmelchior what do you mean by not working? As in there is something within Realm that needs to be updated or that the Kotlin/WASM target is in alpha and has some bug that affects Realm? If it's the former, I might be interested in contributing to get this working as I have decided to invest pretty heavily in Realm for my side project 😁
The core of realm is not written in kotlin. This project just contains the bindings.
@gxhenderson There are two limitations:
1) WASM is a lot more restricted than "normal" native code since it is running inside the browser sandbox. That has large implications on which APIs we have available in C++ and required us to modify parts of https://github.com/realm/realm-core. We have started this work, but there is still more to do. You can see the initial PR here: https://github.com/realm/realm-core/pull/6263
2) With Realm Core compiling against WASM, it should, in theory, be possible to enable the JS target, but there is a fair amount of expect/actual
implementations in Realm Kotlin that only support Native, JVM and Android, those would have to be extended with JS support. After that we might run into architectural issues. The current codebase is heavily designed as multi-threaded and I suspect some of these designs would have to be re-worked for JS support.
While we appreciate the offer to help, I'm not sure the current state of this project is suitable for external collaboration, but I'll let you know when that changes.
Thanks for this extra context and all the work the team is putting into supporting this! Excited to see how this goes.
im using realm for andoird/iOS and desktop but not web. I'm trying to run web without realm but I keep on receiving errors because realm doesn't work with js(IR) { browser() } but im not using realm for web. also I can't remove js(IR) { browser() } because web needs it
val jsMain by getting { dependsOn(commonMain) dependencies { implementation(compose.html.core) implementation("io.realm.kotlin:library-base:$realmVersion") { exclude(group = "io.realm.kotlin", module = "library-base") } implementation("io.realm.kotlin:library-sync:$realmVersion") { exclude(group = "io.realm.kotlin", module = "library-sync") } } } this won't work
Hey, any chance to get Kotlin JS support? Would be nice in combination with jetbrains compose web. Thanks for considering!