@@ -15,6 +15,7 @@ import org.gradle.kotlin.dsl.withType
1515import org.gradle.kotlin.dsl.getByType
1616import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
1717import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
18+ import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalWasmDsl
1819import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
1920
2021private fun BaseExtension.setupAndroid () {
@@ -69,6 +70,7 @@ fun Project.setupModuleForAndroidxCompose(
6970fun Project.setupModuleForComposeMultiplatform (
7071 withKotlinExplicitMode : Boolean = true,
7172 fullyMultiplatform : Boolean = false,
73+ enableWasm : Boolean = true,
7274 iosPrefixName : String = "ios" // only used in ios sample
7375) {
7476 plugins.withType< org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper > {
@@ -92,6 +94,10 @@ fun Project.setupModuleForComposeMultiplatform(
9294 js(IR ) {
9395 browser()
9496 }
97+ if (enableWasm) {
98+ @OptIn(ExperimentalWasmDsl ::class )
99+ wasmJs { browser() }
100+ }
95101 macosX64()
96102 macosArm64()
97103 ios(iosPrefixName)
@@ -126,6 +132,13 @@ fun Project.setupModuleForComposeMultiplatform(
126132 }
127133
128134 if (fullyMultiplatform) {
135+ val commonWebMain by creating {
136+ dependsOn(commonMain)
137+ }
138+
139+ val jsMain by getting
140+ jsMain.dependsOn(commonWebMain)
141+
129142 val nativeMain by creating {
130143 dependsOn(commonMain)
131144 }
@@ -145,6 +158,11 @@ fun Project.setupModuleForComposeMultiplatform(
145158 val iosSimulatorArm64Main = getByName(iosPrefixName + " SimulatorArm64Main" ).apply {
146159 dependsOn(iosMain)
147160 }
161+
162+ if (enableWasm) {
163+ val wasmJsMain by getting
164+ wasmJsMain.dependsOn(commonWebMain)
165+ }
148166 }
149167 }
150168 }
0 commit comments