https://kotlinlang.org logo
Title
m

Mark Vogel

02/24/2023, 8:12 PM
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

Casey Brooks

02/24/2023, 8:16 PM
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

Pablichjenkov

02/24/2023, 8:21 PM
Does B by itself is able to compile? If so, it must be related to what Casey mentioned
m

Mark Vogel

02/24/2023, 8:21 PM
Thanks! Yeah Library B can compile. Also both projects have
kotlin.js.compiler=ir
in the gradle.properties and have JS targets
p

Pablichjenkov

02/24/2023, 8:21 PM
You have to include the target even if empty I guess, in project B
m

Mark Vogel

02/24/2023, 8:22 PM
The packages in my repository include the JS, JVM and common also
c

Casey Brooks

02/24/2023, 8:22 PM
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

Mark Vogel

02/24/2023, 8:24 PM
I see. I'm using Kotlin 1.8.10 and the targets in both projects are declared without a compiler:
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:
Could not determine the dependencies of task ':multiplatform:assembleBrowserPackage'.
> Cannot query the value of this provider because it has no value available.
c

Casey Brooks

02/24/2023, 8:26 PM
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

Mark Vogel

02/24/2023, 8:28 PM
The name value just defaults to
js
. I'll give that a try regardless although now I'm just getting that latest error
p

Pablichjenkov

02/24/2023, 8:30 PM
Is saying doesn't find the dependencies of task ...Browser..., which makes me wonder about the 'browser' name
c

Casey Brooks

02/24/2023, 8:32 PM
If it helps, here’s the typical setup I use for my JS projects, which has never given me any problems.
// in the library module
plugins {
    kotlin("multiplatform")
}

kotlin {
    explicitApi()

    js(BOTH) {
        browser {}
    }
}
// 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

Mark Vogel

02/24/2023, 8:34 PM
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:
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!