Michael Paus
05/10/2025, 9:15 AM@kotlin.wasm.WasmImport("rust_library", "fibonacci")
external fun calculateFibonacci(n: Int): Int
But at build time I only get
Module not found: Error: Can't resolve 'rust_library' in '/Users/mpaus/Projects/tmp/EmmentalerDemo/build/js/packages/composeApp/kotlin'
although this folder actually contains the Wasm file.
The Wasm file itself is correct because it works nicely in Chasm, Chickory and GraalVMWasm.Michael Paus
05/10/2025, 9:48 AM@kotlin.wasm.WasmImport("./rust_library.wasm", "fibonacci")
external fun calculateFibonacci(n: Int): Int
So, the module here is actually a relative file path and not only the module name.
Calling this function like this
val fib = calculateFibonacci(10)
println("fib(10) = $fib (should be 55)")
actually produces
fib(10) = 55 (should be 55)
in the browser console 🎉.
Now let’s see whether I can also get less trivial code to work.