Skip to content

Commit

Permalink
Add WasmJS support + fix test compilation for both JS and Wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
JSMonk committed May 3, 2024
1 parent 3a99eb0 commit 44563fe
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ build/
.idea/
*.iml
.gradle
local.properties
projects/local.properties
classes/
.DS_Store
/build
Expand Down
4 changes: 4 additions & 0 deletions projects/compose/koin-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ kotlin {
browser()
}

wasmJs {
browser()
}

iosX64()
iosArm64()
iosSimulatorArm64()
Expand Down
38 changes: 38 additions & 0 deletions projects/core/koin-core-coroutines/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand All @@ -13,6 +14,26 @@ kotlin {
nodejs()
browser()
binaries.executable()

// To run tests
compilations.all {
kotlinOptions {
freeCompilerArgs += listOf("-XXLanguage:+JsAllowInvalidCharsIdentifiersEscaping")
}
}
}

wasmJs {
nodejs()
browser()
binaries.executable()

// To run tests
compilations.all {
kotlinOptions {
freeCompilerArgs += listOf("-XXLanguage:+JsAllowInvalidCharsIdentifiersEscaping")
}
}
}

iosX64()
Expand Down Expand Up @@ -40,6 +61,18 @@ kotlin {
implementation(libs.kotlin.test)
implementation(libs.test.coroutines)
}

val jsAndWasmMain by creating {
dependsOn(commonMain.get())
}

val jsMain by getting {
dependsOn(jsAndWasmMain)
}

val wasmJsMain by getting {
dependsOn(jsAndWasmMain)
}
}
}

Expand All @@ -49,4 +82,9 @@ tasks.withType<KotlinCompile>().all {
}
}

rootProject.the<NodeJsRootExtension>().apply {
nodeVersion = "21.0.0-v8-canary202309143a48826a08"
nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary"
}

apply(from = file("../../gradle/publish.gradle.kts"))
41 changes: 41 additions & 0 deletions projects/core/koin-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand All @@ -13,6 +14,26 @@ kotlin {
nodejs()
browser()
binaries.executable()

// To run tests
compilations.all {
kotlinOptions {
freeCompilerArgs += listOf("-XXLanguage:+JsAllowInvalidCharsIdentifiersEscaping")
}
}
}

wasmJs {
nodejs()
browser()
binaries.executable()

// To run tests
compilations.all {
kotlinOptions {
freeCompilerArgs += listOf("-XXLanguage:+JsAllowInvalidCharsIdentifiersEscaping")
}
}
}

iosX64()
Expand All @@ -31,6 +52,8 @@ kotlin {
linuxX64()
linuxArm64()

applyDefaultHierarchyTemplate()

sourceSets {
commonMain.dependencies {
api(libs.extras.stately)
Expand All @@ -40,6 +63,18 @@ kotlin {
implementation(libs.kotlin.test)
implementation(libs.test.coroutines)
}

val jsAndWasmMain by creating {
dependsOn(commonMain.get())
}

val jsMain by getting {
dependsOn(jsAndWasmMain)
}

val wasmJsMain by getting {
dependsOn(jsAndWasmMain)
}
}
}

Expand All @@ -49,4 +84,10 @@ tasks.withType<KotlinCompile>().all {
}
}


rootProject.the<NodeJsRootExtension>().apply {
nodeVersion = "21.0.0-v8-canary202309143a48826a08"
nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary"
}

apply(from = file("../../gradle/publish.gradle.kts"))
26 changes: 26 additions & 0 deletions projects/core/koin-test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand All @@ -13,6 +14,26 @@ kotlin {
nodejs()
browser()
binaries.executable()

// To run tests
compilations.all {
kotlinOptions {
freeCompilerArgs += listOf("-XXLanguage:+JsAllowInvalidCharsIdentifiersEscaping")
}
}
}

wasmJs {
nodejs()
browser()
binaries.executable()

// To run tests
compilations.all {
kotlinOptions {
freeCompilerArgs += listOf("-XXLanguage:+JsAllowInvalidCharsIdentifiersEscaping")
}
}
}

iosX64()
Expand Down Expand Up @@ -52,4 +73,9 @@ tasks.withType<KotlinCompile>().all {
}
}

rootProject.the<NodeJsRootExtension>().apply {
nodeVersion = "21.0.0-v8-canary202309143a48826a08"
nodeDownloadBaseUrl = "https://nodejs.org/download/v8-canary"
}

apply(from = file("../../gradle/publish.gradle.kts"))
6 changes: 3 additions & 3 deletions projects/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# /!\ Koin in gradle.properties /!\

# Core
kotlin = "1.9.22"
kotlin = "1.9.23"
binaryValidator = "0.13.2"
publish = "2.0.0-rc-1"
coroutines = "1.7.3" # "1.8.0-RC2" for wasm
coroutines = "1.8.0" # "1.8.0-RC2" for wasm
dokka = "1.9.10"
# Android
agp = "7.4.1"
Expand All @@ -19,7 +19,7 @@ androidx-workmanager = "2.8.1"
androidx-navigation = "2.7.5"
# Compose
# /!\ Compose compiler in gradle.properties /!\
composeJB = "1.5.12"
composeJB = "1.6.2"
composeJetpackRuntime = "1.5.4"
composeJetpackViewmodel = "2.6.2"
# Test
Expand Down

0 comments on commit 44563fe

Please sign in to comment.