Use Kotlin Libaries in JS


#1

short understanding question.

Do I have to pay attention to anything when i use Kotlin Libraries in JS (node.js)?

Does it make a difference if I compile on JVM or JS?

such as eg. Exposed https://github.com/JetBrains/Exposed


#2

yes.

Kotlin has a common core and platform-specific modules.
When the code only uses the common core, your save.
When a library also uses the platform-specific modules, or Java, you can’t use it.

Exposed uses java.util and I can’t read anything about javascript, so I think it can’t be udes in JS.

More info on multiplatform projects: https://kotlinlang.org/docs/reference/multiplatform.html.

I don’t think this is true in every case, but when the library doesn’t talk about common or JS, you can assume it’s a Java-library.


#4

+1 to @tieskedh

The library description should explicitly state it targets JavaScript.