Hi :slightly_smiling_face: We har KMP library tar...
# webassembly
o
Hi 🙂 We har KMP library targeting JS and Java. Is it possible to utilise kotlin webassembly for certain parts in the JS target? We have a quite large code base and want to test web assembly for our most complex (time consuming, etc) functions. För instance: JS -> complexFunction calls a web assembly function Java -> complexFunction calls a "normal" java function. If you understand how I mean 🙂
a
c
I don't thinnk expect/actual helps here. The goal of expect/actual is to use different code on different platforms. But, from what I understand, OP is trying to use the same code. What I would do is move all the complex code into its own module:
Copy code
main-code/ ← js, JVM
complex-core/  ← js, WASM, JVM
The complex module would be compiled for the JVM, JS and WASM. Then, when creating a JVM app, you import the complex module as a normal dependency. However, when creating the JS website, you import the complex module's WASM output as an additional import, like you would import an NPM library. As a bonus, you can also compile the complex code to JS as a fallback in case the user's browser doesn't support WASM
o
That sounds awesome 🙂 Thanks