Skip to content

Commit

Permalink
Use stable Ktor for non-wasm targets
Browse files Browse the repository at this point in the history
Prefer using stable Ktor, because the alpha causes an error with vanilla
JavaScript only in production (though is fine in debug).
  • Loading branch information
ahmedre committed May 12, 2024
1 parent a54fcc1 commit 2a956dd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
21 changes: 14 additions & 7 deletions catalog/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ kotlin {
implementation(compose.foundation)
implementation(compose.material3)
implementation(libs.kotlinx.serialization.json)

implementation(libs.ktor.client.core)
implementation(libs.ktor.serialization.json)
implementation(libs.ktor.client.contentNegotiation)
Expand Down Expand Up @@ -97,8 +98,7 @@ kotlin {
}
}

val webMain by creating {
dependsOn(commonMain)
val jsMain by getting {
resources.srcDirs("src/commonRes", "../sdui/src/commonRes")
dependencies {
implementation(projects.design)
Expand All @@ -107,12 +107,19 @@ kotlin {
}
}

val jsMain by getting {
dependsOn(webMain)
}

val wasmJsMain by getting {
dependsOn(webMain)
dependsOn(commonMain)
resources.srcDirs("src/commonRes", "../sdui/src/commonRes")
dependencies {
implementation(projects.design)
implementation(compose.ui)

val wasmKtor = "3.0.0-wasm1"
implementation("io.ktor:ktor-client-core:$wasmKtor")
implementation("io.ktor:ktor-serialization-kotlinx-json:$wasmKtor")
implementation("io.ktor:ktor-client-content-negotiation:$wasmKtor")
implementation("io.ktor:ktor-client-logging:$wasmKtor")
}
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions design/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ kotlin {

js(IR) { browser() }
@OptIn(ExperimentalWasmDsl::class)
wasmJs() { browser() }
wasmJs { browser() }

androidTarget {
compilations.all {
Expand Down Expand Up @@ -73,19 +73,23 @@ kotlin {
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
implementation(compose.components.resources)
implementation(libs.coil.network.ktor)
implementation(libs.ktor.client.core)
}
}

val jsMain by getting {
dependsOn(webMain)
dependencies {
implementation(libs.ktor.client.js)
implementation(libs.ktor.client.core)
}
}

val wasmJsMain by getting {
dependsOn(webMain)
dependencies {
val wasmKtor = "3.0.0-wasm1"
implementation("io.ktor:ktor-client-core:$wasmKtor")
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ coroutines = "1.8.1"
foundation = "1.6.7"
kotlin = "1.9.23"
kotlinx-serialization = "1.6.3"
ktor = "3.0.0-wasm1"
ktor = "2.3.8"
compose-compiler = "1.5.13"
compose-jb = "1.6.1"
spotless = "6.14.0"
Expand Down Expand Up @@ -49,4 +49,4 @@ kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
jetbrain-compose = { id = "org.jetbrains.compose", version.ref = "compose-jb" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }

0 comments on commit 2a956dd

Please sign in to comment.