When I follow the guide Create a multiplatform library I manage to get Jar to be used in Kotlin/JVM side, but the npm module doesn't look good - it is generatesd with physical paths to dependenices to several kotlin packages:
{
"name": "metalib",
"version": "1.0.0",
"main": "kotlin/metalib.js",
"devDependencies": {
"dukat": "0.5.8-rc.3"
},
"dependencies": {
"kotlin": "file:C:\\Users\\ ... \\build\\js\\packages_imported\\kotlin\\1.4.31",
"kotlin-test-js-runner": "file:C:\\Users\\ ... \\build\\js\\packages_imported\\kotlin-test-js-runner\\1.4.31",
"kotlin-test": "file:C:\\Users\\ ... \\build\\js\\packages_imported\\kotlin-test\\1.4.31"
},
"peerDependencies": {},
"optionalDependencies": {},
"bundledDependencies": []
}
Where ... is full path to Multiplatform project.
I tried to build the library with npm pack and install into webapp, but app tries to look for the deps on these paths.
Is there a way to build clean, standalone (or at least with dependenices resolvable by npmjs.com) module with KotlinJS/Multiplatform?
UPD:
build.gradle.kts content
plugins {
kotlin("multiplatform") version "1.4.31"
}
group = "com.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "1.8"
}
testRuns["test"].executionTask.configure {
useJUnit()
}
}
js(LEGACY) {
browser {
testTask {
useKarma {
useChromeHeadless()
webpackConfig.cssSupport.enabled = true
}
}
}
}
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
}
}
val jsMain by getting
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
val nativeMain by getting
val nativeTest by getting
}
}