Hi all, How do I call a Kotlin-Function from JavaS...
# javascript
a
Hi all, How do I call a Kotlin-Function from JavaScript when the
@JsExport
-annotated function is located in a different module? Within the same module, I would use
js("myModule.myFuntion();")
which works fine but calling
js("myOtherModule.myOtherFunction();")
fails since JavaScript fails to resolve
myOtherModule
Is there a Gradle configuration or anything else I can do to access
myOtherModule
from JS when running
myModule
?
g
Why calling a @JsExport method with
js(String)
if you can call it directly from Kotlin? (I mean you're loosing strong typing, rename tools may not detect calls from strings, you may generate method for nothing if not use from js, you're not declaring explicitly your dependencies, ...)
a
Hi @Grégory Lureau, thanks for your answer! Due to our company project setup, I need to make the
js(String)
call from Kotlin and cannot make a direct call 😞
g
I suppose you can open the generated js file of the other module and check what/how it's exported. (I don't want to say it's a weird setup... but I think it is.)
a
I totally agree that the setup is questionable but unfortunately, I'm not the one to change it. The compiler packs all the stuff in one js file, so in my opinion, the
@JsExport
functions from myOtherModule should be available as if they where in the compiled module myModule which fails as well