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

JS preset not working #935

Closed dragossusi closed 3 years ago

dragossusi commented 3 years ago

What I'm trying to do

I have a gradle module called ui which has the code for the screen for android/desktop/web. I am also using Kodein for DI. I can't get the web to work, if I comment these lines, everything works.

Version

const val kotlin = "1.5.21"
const val compose = "0.5.0-build262"

Config

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

    val jsMain by getting {
        dependencies {
            api(compose.web.core)
        }
    }

Error

No matching variant of org.jetbrains.compose.foundation:foundation:0.5.0-build262 was found. The consumer was configured to find a usage of 'kotlin-runtime' 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:

akurasov commented 3 years ago

Hi! Is your project available at GitHub or somewhere?

dragossusi commented 3 years ago

Hello, it is private, but I can add you to it, let me push the changes.

dragossusi commented 3 years ago

I have sent you an invite

eymar commented 3 years ago

Hi @dragossusi do you use org.jetbrains.compose.foundation:foundation in the common source set?

foundation and some other modules are not ported to be used in kotlin/js.

here is a list of dependencies that can be used with js:

compose.web.core
compose.web.widgets
compose.runtime
akurasov commented 3 years ago

I also see that you are using Serialization plugin together with Compose plugin and they are not compatible at the moment. Workaround is to use them in separate modules.

dragossusi commented 3 years ago

Hi @dragossusi do you use org.jetbrains.compose.foundation:foundation in the common source set?

foundation and some other modules are not ported to be used in kotlin/js.

here is a list of dependencies that can be used with js:

compose.web.core
compose.web.widgets
compose.runtime

I am using these:

            api(compose.runtime)
            api(compose.foundation)
            api(compose.material)
            api(compose.ui)
eymar commented 3 years ago

I see. It's not possible to use foundation, material, ui in kotlin/js. I think you need to move these dependencies to jvmMain source set so android and desktop depend on it. And in kotlin/js you will need to implement ui using compose.web.core and/or compose.web.widgets.

dragossusi commented 3 years ago

@eymar would it be easy to do this myself(contributing to this repository)?

akurasov commented 3 years ago

@dragossusi what exactly do you want to contribute here?

dragossusi commented 3 years ago

@akurasov Porting foundation, material and ui to kotlin/js

eymar commented 3 years ago

@dragossusi You might find this thread interesting - https://kotlinlang.slack.com/archives/C01F2HV7868/p1627583669021500 Porting those to kotlin/js won't be easy, although it should be doable.

material, foundation and ui are not in compose-jb repo. They're in androidx project or its fork here - https://github.com/JetBrains/androidx

akurasov commented 3 years ago

@dragossusi do you have any other questions regarding this topic?

dragossusi commented 3 years ago

@akurasov no, we can close this issue

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.