georgi
09/20/2022, 7:24 AMimplementation
currently the same as api
on KotlinJS using the IR compiler?
Documentation says standard gradle dependency declarations are supported.
Example: I have 3 modules with the following dependency graph: appJs
-> modulea
-> moduleb
, where I use implementation
for linking between the modules. So modulea
declares implementation(project(":moduleb"))
. However, I can still access code within mobuleb
from appJs
which means that it's being leaked.build.gradle.kts
files for reference in the thread.appJs
plugins {
kotlin("js") version "1.7.20-RC"
}
kotlin {
js(IR) {
binaries.executable()
nodejs()
}
sourceSets {
val main by getting {
dependencies {
implementation(project(":modulea"))
}
}
}
}
dependencies {
testImplementation(kotlin("test"))
}
plugins {
kotlin("js") version "1.7.20-RC"
}
kotlin {
js(IR) {
nodejs()
}
sourceSets {
val main by getting {
dependencies {
implementation(project(":moduleb"))
}
}
}
}
dependencies {
testImplementation(kotlin("test"))
}
moduleb
plugins {
kotlin("js") version "1.7.20-RC"
}
kotlin {
js(IR) {
nodejs()
}
}
dependencies {
testImplementation(kotlin("test"))
}
project(:modulea)
dependency is a special form of an execution dependency, where we're essentially saying that we want to depend on the output of modulea
which in turn depends on the output of moduleb
. Therefore all compiled classes will be added both to the runtime
and compiletime
classpath of appJs
, which makes sense.
I will try to add an external dependency as implementation
to moduleb
and see if it's leaking. I expect it shouldn't...The situation around Kotlin/Native is a bit different than around the JVM world. Kotlin/Native doesn't supportorcompileOnly
dependencies.runtimeOnly
It is required to pass all transitive dependencies in order to compile code even if it doesn't use symbols from some of them. This is known limitation of Kotlin/Native compiler. Theoretically the example above should be able to compile and Kotlin/Native team will be working on supporting cases like this at some point of time.(Thought I'd share in case anyone stumbles across this in the future)