We're using KMP (Android, iOS, tvos and js-IR) for...
# multiplatform
r
We're using KMP (Android, iOS, tvos and js-IR) for internal SDKs. It's working fine in all platforms except JS. In JS as well, the SDKs are working fine in standalone, however when 2 KMP SDKs are integrated together in the web app we're getting the below error.
Copy code
TypeError: ioDispatcher(.. .plus_rgw9wi_ ks is not a function
Code:
Copy code
fun ioDispatcher() = Dispatchers.Default
//---------------------------
val job = Job()
val scope = CoroutineScope(ioDispatcher() + job)
We believe it's because while transpiling the Kotlin compiler is renaming the methods and they're different for the SDKs and one SDK is trying to resolve it from another. Without making a monorepo and co-building both the SDKs, is there any other way to share a common kotlin-js dependency or avoid the above error? CC @Sebastian Aigner @Arnav Gupta
s
I haven't seen this specific error, but @anton.bannykh, maybe you're aware of something here? 🤔
r
Best solution would be if we can bundle the kotlin-js and Coroutines dependencies separately, as we're using KMP for multiple SDKs, having a common dependency would solve the problem as well as will reduce the size of individual SDKs
a
We believe it's because while transpiling the Kotlin compiler is renaming the methods and they're different for the SDKs and one SDK is trying to resolve it from another.
Most probably that's the cause.
Without making a monorepo and co-building both the SDKs, is there any other way to share a common kotlin-js dependency or avoid the above error?
As you've mentioned, we would suggest to build all the
.js
code together at once so that all the names match. Otherwise it's kinda tricky. What you could do is mark the common library API with
@JsExport
. This way you'll force the compiler to use the non-mangled names, which will of course be stable.
r
We used
@JSExport
for all functions and classes that's supposed to be called from js directly, should we do that for the functions we call from jsMain as well?
a
If you want to reuse this module across different project - then this could be the way. Unfortunately we don't have an official support for that yet.
r
Got it, thanks for the support. Should I raise a youtrack request for this support or Kotlin team completely abandoned Kotlin/JS?
a
Sure)
r
Thanks so much 🙏 Really appreciate the prompt response and the help
👌🏼 1
a
I can confirm I did encouter this exact problem. i had to compile them together (under a single umbrella module) to work around this issue