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)?
Follow these steps:
git clone https://github.com/Kotlin/kotlin-wasm-browser-template.git
gradle/libs.versions.toml
if you want to use another version-Xwasm-generate-wat
into build.gradle.kts as stated heregradle build
build/dist
, you should find a subdirectory named compileSync
containing the resulting WAT fileN.B: I don't need IntelliJ IDEA but I haven't found a solution working without Gradle.