I’m trying to understand how I’m supposed to setup...
# javascript
r
I’m trying to understand how I’m supposed to setup my build file. If I want to make a browser app in Kotlin/JS, I need to use
browser {}
. If I want to write a NodeJS server in Kotlin/JS, I use
nodejs {}
. But what do you use for “pure” libraries? What if I want to remake something like Moment.js from scratch? Or a simple algorithm implementation? It can be used both in the browser or in a nodejs server, it’s “just pure js”. How do you configure a project like that? Do you target one or the other, or both? Does it make a difference?
in the meanwhile, you can
Copy code
kotlin {
    js {
        nodejs()
        browser()
it makes a difference as to which APIs (e.g. on
window
) the Kotlin compiler treats as available, but they're currently compiled the same
r
It just feels like it isn’t intended for libraries at all. I would like to make a JS library, publish it to npm and have it have a transitive dependency to the kotlin stdlib, etc. Then a browser frontend or nodejs backend written in kotlin, JS or typescript could have an npm dependency on my lib and just use it. You should be able to make browser libs, nodejs libs and common “pure js” libs