Bence Boros
10/11/2023, 9:05 AMcommon
code in there.
Js app only has jsMain
and js
target only with IR compiler, es modules, just the usual recommended basic JS setup.
The problem is for some reason I can't see any of the shared code from this JS module even though I'm depending on them..
Here's my JS build.gradle ->
plugins {
kotlin("multiplatform")
id("com.google.devtools.ksp")
}
dependencies {
add("ksp", libs.koin.ksp)
}
kotlin {
sourceSets.configureEach {
kotlin.srcDir("$buildDir/generated/ksp/$name/kotlin/")
}
}
kotlin {
js(IR) {
binaries.executable()
useEsModules()
nodejs()
generateTypeScriptDefinitions()
}
sourceSets {
val commonMain by getting {
dependencies {
// core
implementation(projects.core.common)
.... other common-kind modules
// features
implementation(projects.feature.login)
.... other feature modules
implementation(libs.decompose.core)
implementation(libs.kotlinx.datetime)
implementation(libs.koin.core)
implementation(libs.koin.annotations)
implementation(libs.coroutines.core)
}
}
val jsMain by getting {
dependsOn(commonMain)
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-js")
implementation(libs.coroutines.js)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jsTest by getting {
dependsOn(commonTest)
dependencies {
implementation(kotlin("test"))
}
}
}
}
I don't even know if it's any good though. I get all kind of testing related errors even though I have these testing configs in there.
Like I said I can't see common
code from the js
module which would be crucial for us. I can reach any code from the android target though. Doesn't matter if it's in the common
jvm
or common
target if it has the right dependson
config.
Why is it different in JS? How can I solve that?
FYI: If I use
kotlin("js")
plugin instead of multiplatform
and have src/main
structure instead of src/jsMain
it magically works!
The second part of my question:
Is it even feasable to have a single entry point for the JS app and they'll get all the dependencies from here? or what's the best practice if we'd like to write our web the traditional way and relying on the shared code? Thanks in advance guys!turansky
10/11/2023, 6:47 PMkotlin
extension). Is it expected?Bence Boros
10/12/2023, 10:56 AMturansky
10/12/2023, 11:58 AMdependsOn(commonMain)
and dependsOn(commonTest)
are redundantturansky
10/12/2023, 12:00 PMjsMain
I see implementation(libs.coroutines.js)
dependency
Other dependencies you want to receive from common?Artem Kobzar
10/12/2023, 12:45 PMArtem Kobzar
10/12/2023, 12:46 PMArtem Kobzar
10/12/2023, 12:46 PMBence Boros
10/13/2023, 10:00 AMArtem Kobzar
10/13/2023, 1:21 PMArtem Kobzar
10/13/2023, 1:22 PMArtem Kobzar
10/13/2023, 1:22 PMBence Boros
10/13/2023, 2:01 PM