I have a multiplatform project A that uses my own ...
# multiplatform
m
I have a multiplatform project A that uses my own multiplatform library B (i.e. A depends on B in the common source set). I get an unusual error when attempting to build my project and I can't figure out what's causing it exactly: https://pastebin.com/4vKFMLN9 If I remove dependency B from the project, then it builds without issue. I appreciate any help!
c
Is it possible that Project A includes a JS target, but the Library B does not? Or alternatively, Project A uses JS with IR, while Library B’s JS target is not using IR?
p
Does B by itself is able to compile? If so, it must be related to what Casey mentioned
m
Thanks! Yeah Library B can compile. Also both projects have
kotlin.js.compiler=ir
in the gradle.properties and have JS targets
p
You have to include the target even if empty I guess, in project B
m
The packages in my repository include the JS, JVM and common also
c
how is the target declared in
build.gradle
? If a specific JS target is declared in the Gradle file, it will take precedence over the gradle.properties
m
I see. I'm using Kotlin 1.8.10 and the targets in both projects are declared without a compiler:
Copy code
js("browser") {
    useCommonJs()
    browser()
    binaries.library()
}
I just realized that Project A does specify
binaries.library()
when it should be executable
If I change that I get a new error:
Copy code
Could not determine the dependencies of task ':multiplatform:assembleBrowserPackage'.
> Cannot query the value of this provider because it has no value available.
c
It might also be failing because you gave the JS target a name (
js("browser")
). I’m not certain about this one, but maybe try making sure neither the library nor you application specify a target name, or else that they use the same target name
m
The name value just defaults to
js
. I'll give that a try regardless although now I'm just getting that latest error
p
Is saying doesn't find the dependencies of task ...Browser..., which makes me wonder about the 'browser' name
c
If it helps, here’s the typical setup I use for my JS projects, which has never given me any problems.
Copy code
// in the library module
plugins {
    kotlin("multiplatform")
}

kotlin {
    explicitApi()

    js(BOTH) {
        browser {}
    }
}
Copy code
// in the application module
plugins {
    kotlin("multiplatform")
}

kotlin {
     js(IR) {
        browser {}
        binaries.executable()
    }
}
Yeah, I suspect naming your library’s JS target is the problem. If you know you need different JS implementations for browser vs node, I’d suggest using two different modules rather than having different JS targets, because of this naming issue. Just keeping things simple is probably a better way to go
m
I appreciate it. yeah even though that task is listed in the Gradle tab as available execute. I think it's some dependency that it can't find a value not being set or something
The naming extends pretty deep into the configuration so it's not super easy to change back haha I will give it a try
Okay that was easier than I thought. I get the same error:
Copy code
Could not determine the dependencies of task ':multiplatform:assembleJsPackage'.
> Cannot query the value of this provider because it has no value available.
Regardless thanks guys for helping me out I appreciate it!