Skip to content

Broken JS target on kotlin 1.8.20 #460

@zacharee

Description

@zacharee

I have an Android + JS Kotlin project implementing moko-resources.

It seems like there's some incompatibility with Kotlin 1.8.20. With versions 0.20.1, 0.21.1, and 0.21.2, I get the following error for all resource files in my web target:

ERROR in ./kotlin/<PROJECT_NAME>-common.js 408:16-49

Module not found: Error: Can't resolve '<FOLDER>/<FILE>' in '<PROJECT_ROOT_DIR>/build/js/packages/<PROJECT_NAME>-web/kotlin'

In my :common build.gradle, I have:

plugins {
    kotlin("multiplatform")
    id("org.jetbrains.compose")
    id("com.android.library")
    id("dev.icerock.mobile.multiplatform-resources")
}

kotlin {
    android()
    js(IR) {
        browser()
        binaries.executable()
        generateTypeScriptDefinitions()
    }

    sourceSets {
        val commonMain by getting {
            dependencies {
                api("dev.icerock.moko:resources:0.21.2")
                ...
                api(compose.runtime)
                api(compose.foundation)
                api(compose.animation)
                @OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
                api(compose.material3)
            }
        }

        val androidMain by getting { ... }
        val jsMain by getting { ... }
    }
}

android { ... }

multiplatformResources {
    multiplatformResourcesPackage = "<PACKAGE>.common"
}

In my :web build.gradle, I have:

plugins {
    kotlin("multiplatform")
    id("org.jetbrains.compose")
    id("dev.icerock.mobile.multiplatform-resources")
}

group = rootProject.extra["group"].toString()
version = rootProject.extra["versionName"].toString()

kotlin {
    js(IR) {
        browser()
        binaries.executable()
        generateTypeScriptDefinitions()
    }

    sourceSets {
        named("jsMain") {
            dependencies {
                implementation(project(":common"))
            }
        }
    }
}

multiplatformResources {
    multiplatformResourcesPackage = "<PACKAGE>.web"
}

compose.experimental {
    web.application {}
}

tasks.withType<ProcessResources> {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
  • Kotlin 1.8.20.
  • JB Compose 1.4.0.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions