kotlinwebassembly

How to compile Kotlin into WebAssembly in command line?


I would like to compile a few Kotlin classes and enums into WebAssembly in command line. It worked several years ago with kotlinc-native but the wasm32 target was removed. I try to use this example: kotlinc-js -output lib.js -Xir-produce-js -Xwasm -libraries kotlin-stdlib-wasm-2.0.20.klib input.kt but the lib directory has no file named kotlin-stdlib-wasm-2.0.20.klib in Kotlin 2.0.20. How can I simply compile Kotlin into WebAssembly without using Intellij IDEA (and Gradle)?


Solution

  • Follow these steps:

    N.B: I don't need IntelliJ IDEA but I haven't found a solution working without Gradle.