Simon Heimler
02/17/2020, 9:00 AMjs("node").compilations["main"]
artifact?
Thank you for your time and effort you're putting into this!
The relevant part of our build.gradle.kts
js("node") {
nodejs {
}
compilations.all {
compileKotlinTask.kotlinOptions {
metaInfo = true
sourceMap = true
moduleKind = "commonjs"
sourceMapEmbedSources = null
}
}
}
[...]
js("node").compilations["main"].defaultSourceSet {
dependencies {
implementation(kotlin("stdlib-js"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutinesVersion")
implementation("io.ktor:ktor-client-js:$ktorVersion")
implementation("io.ktor:ktor-client-serialization-js:$ktorVersion")
implementation("io.ktor:ktor-client-json-js:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:$serializationVersion")
implementation("io.ktor:ktor-client-auth-js:$ktorVersion")
implementation(npm("uuid", "3.3.3"))
}
}
Eivind Nilsbakken
02/17/2020, 12:23 PMpackage.json
that points at your glue code, both located in src/jsMain/resources
.
Once that's done, you can just unzip build/libs/somepackage-js-someversion.jar
in your build pipeline, fetch the actual version with gradle properties | grep ^version | cut -d" " -f2
and set that with ``npm --no-git-tag-version someversion` and publish to your npm registry of choice, as you normally would.Eivind Nilsbakken
02/17/2020, 12:29 PMimport { com } from 'your-module'
const what_i_actually_want = com.example.your-module;
Simon Heimler
02/17/2020, 4:21 PMEivind Nilsbakken
02/17/2020, 8:32 PMThe nodejs code in the .jar file does miss a package.json in my build, which makes it not self-contained. Did I miss something?No, you're right about that. I thought it did, but it doesn't, so you actually have to add that yourself either way.
Simon Heimler
02/18/2020, 7:32 AM