https://kotlinlang.org logo
#compose-web
Title
# compose-web
a

Alberto

12/13/2023, 2:30 PM
Hi, I have created a KMP library which I would like to use on a Compose Multiplatform Web project, using wasamJSMain target. I have the following gradle configuration for JS export from the library.
Copy code
js(IR) {
        useEsModules()
        browser()
        binaries.library()
        generateTypeScriptDefinitions()
    }
Im publishing the library to my local maven, but when trying to use it I get these errors
Copy code
Could not resolve com.xxx.xxx:core:0.0.1.5.
  Required by:
      project :composeWeb
   > No matching variant of com.biosphere.mobile:core:0.0.1.5 was found. The consumer was configured to find a library for use during 'kotlin-api', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm', attribute 'org.jetbrains.kotlin.wasm.target' with value 'js' but:
       - Variant 'debugApiElements-published' capability com.xxx.xxx:core:0.0.1.5 declares a library for use during compile-time:
           - 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 'wasm'
           - Other compatible attributes:
               - Doesn't say anything about its target Java environment (preferred optimized for non-jvm)
               - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js')
How can I use it on the wasamJSMain project?
m

Michael Paus

12/13/2023, 3:00 PM
First of all it is “wasm” and not “wasam”.
a

aishwaryabhishek3

12/13/2023, 3:15 PM
I have similar issues with using multiplatform libraries , I am assuming the libraries author has not targetting the library to be used with wasm
a

Alberto

12/13/2023, 3:28 PM
Thanks Michael, yes typo on my side when writing but correctly setup in the project. After some trial-error Im pretty sure this is because wasm target is not declared in the library (this lib has no UI), instead I have jsMain to be able to export .js compilations. I will be trying to include this target in the library and see where that goes
8 Views