Let say I want to build a Wasm library with Kotlin...
# webassembly
s
Let say I want to build a Wasm library with Kotlin/Wasm
1.7.20-Beta
that "exports"
fun add(a: Int, b: Int): Int = a + b
. I don't care about JavaScript here, I just want to specify that the generated Wasm should be shipped with this function and everything else removed (tree shaking). I have no
main()
in my project. How should I specify that in my code and/or how my build configuration
kotlin { wasm { binaries.library() } }
should be customized? Is
@JsExport
the way to go for now?
s
binaries.executable()
and
@JsExport
would be the way to go for now.
Note that JsExport of some non-primitive types currently requires autogenerated JS glue to function.
s
Ok thanks, in term of design I would be curious if you may target a
binaries.library()
+
@WasmExport
for that use case or if you have something else in mind. Other languages usually uses keyword instead of
@JsExport
/
@WasmExport
but maybe there is not enough use cases on other platforms to justify such keyword in Kotlin ...
109 Views