https://kotlinlang.org logo
#webassembly
Title
# webassembly
a

andylamax

12/09/2023, 9:37 AM
is it even sensible to have a configuration like this
Copy code
kotlin {
   wasmJs{
      nodeJs()
   }
}
r

Robert Jaros

12/09/2023, 9:55 AM
Of course it is. You can run your K/Wasm application in nodeJS just like K/JS application. You just need to configure nodeJS canary to be able to run application or tests from gradle. https://github.com/rjaros/kilua/blob/main/kilua/build.gradle.kts#L76-L83
a

andylamax

12/09/2023, 9:57 AM
I see. Are there any benefits for choosing
Copy code
kotlin {
   wasmJs {         // this
      nodeJs()
   }

   wasmWasi {      // over this??
      nodeJs()
   }
}
r

Robert Jaros

12/09/2023, 9:58 AM
wasi is completely different runtime and needs dedicated libraries. Currently there are almost none (e.g. no coroutines).
wasmJS on node uses JS runtime, you can use JS interop and most important libraries are available
a

andylamax

12/09/2023, 10:00 AM
I think koitlinx-serialization (version 1.6.2) already added a wasi target
So, mostly then, we we choose the former due to lack of third party libraries (at the moment)
r

Robert Jaros

12/09/2023, 10:01 AM
You are right
It probably depends what you want to implement. WasmJS on node allows you to use the large part of JS ecosystem.
a

andylamax

12/09/2023, 10:04 AM
Thank you a lot
I still have a side question though. if wasi is a completely different runtime, then what does it mean to have it be declared like this
Copy code
wasmWasi {
      nodeJs()
   }
r

Robert Jaros

12/09/2023, 10:05 AM
No idea 🙂
😀 1
a

andylamax

12/09/2023, 10:05 AM
As in, you run wasi (a completely different runtime) inside/from node(a completely different runtime)??
Seems so confusing at the moment
r

Robert Jaros

12/09/2023, 10:07 AM
I would assume it's something connected with https://nodejs.org/api/wasi.html
a

andylamax

12/09/2023, 10:07 AM
Thanks for the link. Let me go through it
Well, you are probably right. And if that's the case, I find it so hard (and inconvenient) for the kotlin team to maintain different wasi runtimes through the KGP?? Coz we do have runtimes like (https://github.com/wasmerio/wasmer-java), and I believe there are many more But that should not make the kotlin team add it in the KGP like so, should it??
Copy code
wasmWasi {
  wasmerJava() // ??? possible, but why??
}
r

Robert Jaros

12/09/2023, 10:16 AM
Why not? I would be happy to choose one or many supported runtimes with simple DSL.
a

andylamax

12/09/2023, 10:17 AM
I dunno, Coz there are going to be a gazillion of those?
r

Robert Jaros

12/09/2023, 10:20 AM
There is already a gazillion of supported browsers inside the
useKarma { }
DSL and I find it really nice 🙂
a

andylamax

12/09/2023, 10:20 AM
hahahaha, very true. I find it really nice myself
s

Svyatoslav Kuzmich [JB]

12/09/2023, 3:26 PM
Currently we already have a maintained Node.js support from Kotlin/JS KGP (we needed at least one to run tests without browsers). And now we reuse it for both wasmJs and wasmWasi 🙂 Hopefully, WASI as a standard, would allow you test your code in one runtime, and deploy it to the other.
a

andylamax

12/09/2023, 10:41 PM
Makes sense
4 Views