Skip to content

Commit

Permalink
Fix skiko.js unpacking for k/js target
Browse files Browse the repository at this point in the history
K/JS and K/Wasm have differences in the packaging logic, and therefore we need to account for it when unpacking Skiko files.

Fixes CMP-5649
  • Loading branch information
eymar committed Jul 22, 2024
1 parent 78940c1 commit 10e6df9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ResolvedDependency
import org.gradle.api.artifacts.UnresolvedDependency
import org.gradle.api.artifacts.component.ModuleComponentIdentifier
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.provider.Provider
import org.gradle.language.jvm.tasks.ProcessResources
import org.jetbrains.compose.ComposeBuildConfig
import org.jetbrains.compose.ComposeExtension
import org.jetbrains.compose.internal.utils.detachedComposeDependency
Expand Down Expand Up @@ -77,8 +79,16 @@ internal fun configureWebApplication(
}

project.tasks.withType(IncrementalSyncTask::class.java) {
if (it.name.contains("wasmJs", ignoreCase = true)) {
it.dependsOn(unpackRuntime)
it.from.from(unpackedRuntimeDir)
}
}

project.tasks.named("jsProcessResources", ProcessResources::class.java) {
it.from(unpackedRuntimeDir)
it.dependsOn(unpackRuntime)
it.from.from(unpackedRuntimeDir)
it.exclude("META-INF")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class GradlePluginTest : GradlePluginTestBase() {
check.taskSuccessful(":compileKotlinJs")
check.taskSuccessful(":compileKotlinWasmJs")
check.taskSuccessful(":wasmJsBrowserDistribution")
check.taskSuccessful(":jsBrowserDistribution")

file("./build/dist/wasmJs/productionExecutable").apply {
checkExists()
Expand All @@ -61,6 +62,14 @@ class GradlePluginTest : GradlePluginTestBase() {
// one file is the app wasm file and another one is skiko wasm file with a mangled name
assertEquals(2, distributionFiles.filter { it.endsWith(".wasm") }.size)
}

file("./build/dist/js/productionExecutable").apply {
checkExists()
assertTrue(isDirectory)
val distributionFiles = listFiles()!!.map { it.name }.toList()
assertTrue(distributionFiles.contains("skiko.wasm"))
assertTrue(distributionFiles.contains("skiko.js"))
}
}
}

Expand Down

0 comments on commit 10e6df9

Please sign in to comment.