sunnat629
03/02/2024, 9:30 PMsunnat629
03/02/2024, 10:27 PMshared
module
@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
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
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
?