Hey peeps! I’m currently using a Kotlin Multiplatf...
# javascript
s
Hey peeps! I’m currently using a Kotlin Multiplatform project to export some backend logic to a JS application. We’ve recently started using
Instant
from the kotlinx-datetime package inside that project and now the exported JS package requires "@js-joda/core" to be present in order to function (even though the class using the Instant is not annotated with
@JSExport
). Is anyone aware of a way to make the integration work without needing to add the @js-joda/core library to the JS project? 🤔 Update: Looks like there should be some way to configure the dependency "org.jetbrains.kotlinxkotlinx datetime0.2.1" to not be used for the JS target. But even after reading the docs it’s not very clear to me how to achieve that.
i
kotlinx.datetime.Instant
is implemented in Kotlin/JS using the API from the
js-joda
npm package, so it's required in order for
Instant
class to function.
s
Hey Ilya, thanks for your response! I’m aware that js-joda is required to make Instant work in the JS world – the thing is just that the Kotlin class that uses Instant is not even being used in the JS package. So I’d have hoped that there’s a way to configure the project to only use kotlinx-datetime for JVM, Android and Swift and not for JS.
i
If no kotlinx-datetime API is used in your JS source set at all (and common source set that is compiled as a part of JS), I believe you can add this dependency explicitly to all sourcesets except JS and common.