From caab77380ab31bb3df6c5387457a10eb063b02a5 Mon Sep 17 00:00:00 2001 From: Artem Kobzar Date: Fri, 5 Jan 2024 10:35:15 +0100 Subject: [PATCH 1/2] Add wasmJs target into the application --- build.gradle.kts | 12 ++++++++++-- src/wasmJsMain/kotlin/Main.kt | 5 +++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 src/wasmJsMain/kotlin/Main.kt diff --git a/build.gradle.kts b/build.gradle.kts index e3ca622..4960115 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,9 +8,9 @@ val kotlinWrappersVersion = "1.0.0-pre.621" val kmongoVersion = "4.5.0" plugins { - kotlin("multiplatform") version "1.9.10" + kotlin("multiplatform") version "1.9.22" application //to run JVM part - kotlin("plugin.serialization") version "1.9.10" + kotlin("plugin.serialization") version "1.9.22" } group = "org.example" @@ -29,6 +29,12 @@ kotlin { binaries.executable() } } + wasmJs { + browser { + binaries.executable() + } + } + sourceSets { val commonMain by getting { dependencies { @@ -68,6 +74,8 @@ kotlin { implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom") } } + + val wasmJsMain by getting } } diff --git a/src/wasmJsMain/kotlin/Main.kt b/src/wasmJsMain/kotlin/Main.kt new file mode 100644 index 0000000..e42f2b5 --- /dev/null +++ b/src/wasmJsMain/kotlin/Main.kt @@ -0,0 +1,5 @@ +import kotlinx.browser.document + +fun main() { + document.getElementById("root")?.innerHTML = "Hello, Kotlin/Wasm!" +} From 22d3045c473bf9e88c9f546507393fc1e05c2bad Mon Sep 17 00:00:00 2001 From: Artem Kobzar Date: Fri, 5 Jan 2024 18:25:12 +0100 Subject: [PATCH 2/2] Make wasm browser task work again --- build.gradle.kts | 12 ++++++------ src/commonMain/resources/index.html | 13 +++++++++++++ src/commonMain/resources/static/index.html | 11 ----------- 3 files changed, 19 insertions(+), 17 deletions(-) create mode 100644 src/commonMain/resources/index.html delete mode 100644 src/commonMain/resources/static/index.html diff --git a/build.gradle.kts b/build.gradle.kts index 4960115..496c190 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,16 +1,15 @@ import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack -val kotlinVersion = "1.9.10" -val serializationVersion = "1.6.0" -val ktorVersion = "2.3.3" +val serializationVersion = "1.6.2" +val ktorVersion = "3.0.0-wasm2" val logbackVersion = "1.2.11" -val kotlinWrappersVersion = "1.0.0-pre.621" +val kotlinWrappersVersion = "1.0.0-pre.561" val kmongoVersion = "4.5.0" plugins { - kotlin("multiplatform") version "1.9.22" + kotlin("multiplatform") version "1.9.21" application //to run JVM part - kotlin("plugin.serialization") version "1.9.22" + kotlin("plugin.serialization") version "1.9.21" } group = "org.example" @@ -18,6 +17,7 @@ version = "1.0-SNAPSHOT" repositories { mavenCentral() + maven("https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental") } kotlin { diff --git a/src/commonMain/resources/index.html b/src/commonMain/resources/index.html new file mode 100644 index 0000000..b793b91 --- /dev/null +++ b/src/commonMain/resources/index.html @@ -0,0 +1,13 @@ + + + + + Full Stack Shopping List + + +
+ + + + + diff --git a/src/commonMain/resources/static/index.html b/src/commonMain/resources/static/index.html deleted file mode 100644 index 85dca3c..0000000 --- a/src/commonMain/resources/static/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - Full Stack Shopping List - - -
- - - \ No newline at end of file