When update kotlinx-browser from 0.3 to 0.4 and mo...
# javascript
p
When update kotlinx-browser from 0.3 to 0.4 and move this dependency to common (webMain) sourceSet got on load JS script error:
Copy code
IrLinkageError: Function 'addEventListener' can not be called: No function found for symbol 'org.w3c.dom/Window.addEventListener|addEventListener(kotlin.String;kotlin.Function1
?;){}[0]'
Using Kotlin 2.2.20-Beta2 What should i check to solve it?
e
Have you tried running a build without build cache?
p
Trying with clean, disabled Gradle build cache, cache and parallel. No luck.
e
kotlinx-browser is using
webMain
tho as its common source set. Is that what you meant when referring to "common sourceSet"?
p
Yes.
e
Ok, then it might be a bug of some sort. Do you have a snippet to share? I'll try to reproduce.
p
I'll try to extract it and make reproducer later then. Thanks!
✔️ 1
e
Could you try adding
kotlin.js.stdlib.dom.api.included=false
to your
gradle.properties
file?
p
Added but no luck.
e
And is
window
being imported via
Copy code
import kotlinx.browser.window
?
I've just tried a similar setup and it compiles fine.
p
Yes. Importing kotlinx.browser.window.
May be there is smth with transitive dependencies. I have core Gradle module where i declare api(kotlinx-browser) and other modules depend on it. Within this day i'll try to check this hypothesis.
It happens when using with Compose inside ComposeViewport. I guess that something with Compose dependencies for JS stdlib that is not compatible with kotlinx-browser. Here is repro project: https://github.com/hondogo/kotlin-issue-reproducer/tree/kotlinx-browser-04 @Artem Kobzar
a
@Oleksandr Karpovich [JB] ^^
Compose 1.9.x and all previous versions were built against the kotlin/js stdlib. So it expects to link a method with this signature -
addEventListener(kotlin.String;kotlin.Function1<org.w3c.dom.events.Event,kotlin.Unit>?;<dynamic>)
. Note there is a
dynamic
in it. But in kotlinx-browser 0.4 (which is supposed to cover all w3c API) there is no such a method with
dynamic
There is a different set of methods, but no dynamic. Compose 1.9.0 can't be compiled with kotlinx-browser 0.4 because it requires kotlin 2.2.20-Beta. Compose 1.9.0 will be built using Kotlin 2.1.21 Discussed with Zalim last friday. cc: @bashor