Hi guys, I am new in Kotlin/JS and I don't have t...
# multiplatform
s
Hi guys, I am new in Kotlin/JS and I don't have that much of idea regarding JS. Currently, I am trying to work with Kotlin Multiplatform (1.9.22) and I was trying to work something Kotlin/JS also. {My main plan is to use the converted JS file from an existing js file. So, if someone can give me a simple example, it would be great. I read the documentation but maybe I did something wrong.} (Codes are moved to thread) So, can you anyone help me where I did wrong or any feedback? Also is there any sample code to check? Best Regards...
I have a Kotlin class in
shared
module
Copy code
@OptIn(ExperimentalJsExport::class)
@JsExport
class MathOp {
    fun add(a: Int, b: Int): Int = a + b
    fun sub(a: Int, b: Int): Int = a - b
}
build gradle shared module
Copy code
js(IR) {
        moduleName = "shared"
        browser {
            webpackTask {
            }
            testTask {
                useKarma {
                    useSafari()
                    useFirefox()
                    useChrome()
                    useChromeCanary()
                    useChromeHeadless()
                    webpackConfig.cssSupport { enabled.set(true) }
                }
            }
        }
        binaries.executable()
    }
in
jsMain>kotlin>App.js
is working
Copy code
fun main() {
...
val timelineElement = document.getElementById("timeline")
    timelineElement?.textContent = result
...
}
I want to use the converted function in
jsMain>resources>main.js
and execute in
index.html
. But somehow I can connect my
shared.js
?