JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.05k stars 1.17k forks source link

How can i use jsMain in KMP?When can we update the KMP template fuse the web-template? #1271

Closed GoldTest closed 2 years ago

GoldTest commented 2 years ago

When i add these in the common module build.gradle file ,idea cannot identify the project file android() jvm("desktop") js(IR) { browser() binaries.executable() }

I removed the js(IR) config,and build a project named web,dependent on the common project. When i run the jsBrowserRun or jsBrowserWebpack got these error,but can use the func in the common project. `Could not determine the dependencies of task ':web:jsBrowserProductionWebpack'.

Could not resolve all task dependencies for configuration ':web:jsCompileClasspath'. Could not resolve project :common. Required by: project :web No matching variant of project :common was found. The consumer was configured to find a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js', attribute 'org.jetbrains.kotlin.js.compiler' with value 'ir' but:

  • Variant 'debugApiElements' capability BlackDesert:common:unspecified declares an API of a component:
  • Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
  • Other compatible attribute:
  • Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
  • Variant 'debugRuntimeElements' capability BlackDesert:common:unspecified declares a runtime of a component:
  • Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
  • Other compatible attribute:
  • Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
  • Variant 'desktopApiElements' capability BlackDesert:common:unspecified declares an API of a component:
  • Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
  • Other compatible attribute:
  • Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
  • Variant 'desktopDefault' capability BlackDesert:common:unspecified:
  • Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
  • Other compatible attributes:
  • Doesn't say anything about its usage (required a usage of 'kotlin-api')
  • Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
  • Variant 'desktopRuntimeElements' capability BlackDesert:common:unspecified declares a runtime of a component:
  • Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
  • Other compatible attribute:
  • Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
  • Variant 'metadataApiElements' capability BlackDesert:common:unspecified declares a usage of 'kotlin-api' of a component:
  • Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
  • Other compatible attribute:
  • Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
  • Variant 'metadataDefault' capability BlackDesert:common:unspecified:
  • Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
  • Other compatible attributes:
  • Doesn't say anything about its usage (required a usage of 'kotlin-api')
  • Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
  • Variant 'releaseApiElements' capability BlackDesert:common:unspecified declares an API of a component:
  • Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
  • Other compatible attribute:
  • Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir')
  • Variant 'releaseRuntimeElements' capability BlackDesert:common:unspecified declares a runtime of a component:
  • Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'js'
  • Other compatible attribute:
  • Doesn't say anything about org.jetbrains.kotlin.js.compiler (required 'ir') `
romainbsl commented 2 years ago

I am having the same issue trying to publish a KMP library targeting Compose for Desktop / Android / Web. But adding Web target (js(IR) { ...} does not compile. @GoldTest Did you find anything ?

akurasov commented 2 years ago

Guys, do you have a reproducer somewhere?

romainbsl commented 2 years ago

Hi, I just pushed a branch here https://github.com/Kodein-Framework/Kodein-DI/tree/compose-web-reproducer running ./gradlew :framework:compose:kodein-di-framework-compose:jsJar fails. I just added the following target, so maybe I am wrong:

        js(IR) {
            browser()
        }
romainbsl commented 2 years ago

@akurasov even a simpler one https://github.com/romainbsl/compose-kmp-web-reproducer

just run ./gradlew build

romainbsl commented 2 years ago

Removing foundation from the common part resolved the issue for me. I do not need it in my common anyway.

akurasov commented 2 years ago

Same issue as #1320

okushnikov commented 1 month ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.