-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plan for WASM/JS? #211
Comments
Definitely. Would be great to get it added. I haven't looked much into it or how much heavy lifting it will be but it is definitely worth trying to get working. |
Surprisingly there isn't much that needs to be changed. You would need to change jsMain to wasmMain: It also supports webpack for test runs: kotlin {
@OptIn(org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl::class)
wasm {
compilations.all {
kotlinOptions {
freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}
}
binaries.executable()
browser {
commonWebpackConfig {
devServer = (devServer ?: org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig.DevServer()).copy(
open = mapOf(
"app" to mapOf(
"name" to "microsoft-edge", // "edge"
"arguments" to listOf("--js-flags=--experimental-wasm-gc")
)
),
)
}
}
}
sourceSets {
val wasmMain by getting
}
}
and you can call JS interop e.g. webgl just as you do with JS right now. import org.khronos.webgl.ArrayBufferView
import org.khronos.webgl.WebGLObject
import org.khronos.webgl.WebGLRenderingContext
external class WebGLVertexArrayObject : WebGLObject
external class WebGLTransformFeedback : WebGLObject
external class WebGLActiveInfo |
Awesome! Thanks for the example. I'll give it a whirl at some point hopefully in the coming days. |
Is there any update on moving from Kotlin/JS to Kotlin/WASM so far? |
Hello, The changes are in progress and should hopefully have it done within the next few days when I get a bit more time. I've linked the in-progress pull request to this issue. |
1.8.20-Beta introduces the new WASM backend. I've been playing around with it lately and it provides some great compilation speeds and
provides easier interoperability with JS, faster application startup compared to Kotlin/JS and JavaScript and Improved application runtime performance compared to Kotlin/JS and JavaScript
Of course it will possibly be released in Kotlin 2.0, but would there be any consideration to move towards using it?
The text was updated successfully, but these errors were encountered: