https://kotlinlang.org logo
Title
u

uli

09/29/2021, 9:03 AM
Hi all, I have a compose multi platform project (android, desktop, browser, iOS). In my shared module, if I declare the JS target as
js(BOTH)
things work fine and my
js(IR)
based frontend modules can consume the shared artefacts just fine. If I declare the JS target as
js(IR)
in the shared module I get the following exception:
> Task :shared:compileKotlinJs
exception: java.lang.IllegalStateException: Cannot find the Composer class in the classpath
	at androidx.compose.compiler.plugins.kotlin.lower.AbstractComposeLowering.<init>(AbstractComposeLowering.kt:195)
o

Oleksandr Karpovich [JB]

09/29/2021, 9:22 AM
Hi @uli I think adding ``implementation(compose.runtime)`` to jsMain should help
u

uli

09/29/2021, 9:26 AM
Wow. Thanks. Why is that needed. I.e. why is it not needed for js(BOTH)? Known issue?
o

Oleksandr Karpovich [JB]

09/29/2021, 9:45 AM
I'm wondering why there were no errors/warning/anything when you had js(BOTH) Did your app compile normally for js when you had js(BOTH)? compose plugin is supposed to work for js only when it's JS(IR). It can't work with js(legacy), which is also included in JS(BOTH)
and compose.runtime is needed because compose compiler plugin uses declarations from runtime module, so it needs them to be in the classpath
u

uli

09/29/2021, 9:53 AM
so maybe the compose plugin gets disabled for BOTH. I do not use compose for js in the shared part so I would not notice.
Yes, now with compose dependencies added to JS, The build complains when switching to js(BOTH):
Could not determine the dependencies of task ':shared:jsLegacyPackageJson'.
> Could not resolve all dependencies for configuration ':shared:jsLegacyNpm'.
   > Could not resolve org.jetbrains.compose.runtime:runtime:1.0.0-alpha4-build362.
Still unclear if the plugin was disabled for JS by switching to BOTH. I guess so.