Is it currently possible / supported to compile a ...
# webassembly
a
Is it currently possible / supported to compile a library as a wasm module, similar to how kotlin native compiles to a shared library? The Kotlin/Wasm docs seem to focus on executables and I haven't managed to adapt those examples to my library use case. For context, my use case is the following: I created a library in kotlin multiplatform, compiled it as a native shared library, created an idiomatic Python wrapper around the shared library's low-level functions, and published it to pip. One drawback I'd like to get rid of is the necessity to build and publish multiple artifacts, one per platform, because shared libraries are platform dependent. The easiest solution (as far as I can see) is to compile my library to wasm, which is platform independent, and ship that instead of a native shared library.
k
I had to make a gradle plugin for my wasm library in order to ensure the artifacts were always available for reference. There isn't a great story there for consuming shared native resources on wasm. https://github.com/crowded-libs/kotlin-lmdb/
a
That sounds like it's possible to generate a WebAssembly module for your library, even though consuming it is cumbersome, right?
Is
lmdb.wasm
built from kotlin or does it come from somewhere else?
In case anyone knows their way around kotlin + webassembly and would like to help out, here's even more context.
I found a way: you can compile to
wasmJs
, throw away the generated js code and reuse the wasm.
But it doesn't support classes, unfortunately