https://kotlinlang.org logo
#library-development
Title
# library-development
a

andylamax

08/05/2020, 9:20 PM
I have found something so wiered and it goes as follows. I have a multiplatform lib called
theme-core
which at the moment, targets
js
jvm
and
android
. I also have a pure js library
theme-react
which depends on
theme core
.
theme-react
being a purely
js
lib. It has it's sources located at
src/main/kotlin
while
theme-core
sources for targeting js are at
src/jsMain/kotlin
I am trying to use
theme-react
and ultimately
theme-core
as a dependency to a pure js react ui library called
enteprise-react
. as always sources are located at
src/main/kotlin
Idea is able to resolve
theme-react
sources but can't resolve
theme-core
sources. After being bugged by this for a while, I tried changing my
build.gradle.kts
like so
Copy code
sourceSets {
    val jsMain by creating {
        dependencies {
            api(project(":theme-core"))
            api(project(":theme-react"))
        }
    }

    val main by getting {
        dependsOn(jsMain)
        dependencies {
            api(kotlin("stdlib-js"))
            api("org.jetbrains.kotlinx:kotlinx-react:${versions.kotlinjs.react}")
            api("org.jetbrains:kotlin-styled:${versions.kotlinjs.styled}")
            api("org.jetbrains:kotlin-css-js:${versions.kotlinjs.css}")
        }
    }
}
so now
enterprise-react
has two sourceSets.
jsMain
and
main
. If I put my sources in
jsMain
all pure js libraries (including
kotlin-react
and
kotlin-styled
) aren't resolved by IDEA. If I put my sources in
main
IDEA failes to resolve all dependencies build from the sources of the subprojects at
jsMain
(i.e.
theme-core
) and all other mpp supprojects. I tried seperating my sources, no luck. as there is a moment I need resources from both
theme-core
and
kotlin-react
. Has anyone experienced this issue at all? any workaround suggestions please . . . Thank you in advance
a

altavir

08/06/2020, 7:03 AM
I am not sure about your project, but it works fine in my case: https://github.com/mipt-npm/dataforge-vis