I'm trying out the new 1.3.50-eap-5 Kotlin/JS grad...
# javascript
j
I'm trying out the new 1.3.50-eap-5 Kotlin/JS gradle plugin. I get the following error:
Copy code
Could not determine the dependencies of task ':sw-ui-kt:packageJson'.
> project ':sw-client' is not configured for JS usage
Where
sw-client
is a Kotlin multiplatform subproject, and
sw-ui-kt
is a Kotlin/JS subproject depending on `sw-client`:
Copy code
kotlin {
    target {
        browser()
    }
    sourceSets {
        main {
            dependencies {
                implementation(kotlin("stdlib-js"))
                implementation(project(":sw-client"))
//...
Is it normal not to be able to depend on a multiplatform project from a JS one? Is there a way to declare the local dependency to the JS part of the multiplatform project?
a
Redlad few messages above. Browser or node Target must be set for all modules in a build
j
Could you please provide a link to said messages?
a
Sorry, wrong one
j
Ah ok 🙂
I think I found it, though
a
Yeah, this one as well. Marked as won't fix. Good news is that problem exists only inside one project. You can use external modules without browser marking.
j
Yes but my use case is, I guess, quite common for a Kotlin multi-module project: a server in Kotlin/JVM, a client in Kotlin/MPP (to test the server and use in the UI), a UI in Kotlin/JS
So local dependency seems necessary, and I'm still unsure how/where to declare the browser/nodejs targets in MPP, as I had read somewhere that you need to declare
js()
as a target for MPP
a
Yep. My case as well. Had to add browser everywhere
j
Copy code
kotlin {
    jvm()
    js() // <= should I change this?
    sourceSets {
        // all source sets (common, jvm, js) and deps
    }
a
Js{browser()}
j
Oh, so simple... I tried with just
browser()
without success. Will try that, thanks a lot.
Seems to work great, I basically replaced
js()
by
js { browser() }
in all transitive (but local) Kotlin/MPP dependencies of my kotlin/js UI subproject
Ok I had forgotten but now I got it: it's
target
from Kotlin/JS that needs to be replaced by
js
in MPP, but the
browser()
part can stay the same.