Skip to content

Exclude Skiko files from JS DOM distribution via Gradle-native jsProcessResources exclude#120

Open
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-skiko-files-in-distribution
Open

Exclude Skiko files from JS DOM distribution via Gradle-native jsProcessResources exclude#120
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-skiko-files-in-distribution

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 22, 2026

The JS DOM distribution (jsBrowserDistribution) contains unnecessary Skiko files (skiko.mjs, skiko.wasm, skikod8.mjs). The JS target uses DOM-based Compose HTML and has no use for Skiko.

Root cause: The Compose Gradle Plugin's configureWebApplication() defaults to configuring Skiko for all KotlinJsIrTarget targets. For wasmJs (where wasmTargetType != null), Skiko is bundled by webpack internally. For js (where wasmTargetType == null), Skiko files are copied directly into jsProcessResources and end up in the final distribution.

Fix: Exclude Skiko files from jsProcessResources in the demo app project's build.gradle.kts using a Gradle-native approach:

import org.gradle.language.jvm.tasks.ProcessResources

tasks.named<ProcessResources>("jsProcessResources") {
    exclude("skiko.mjs", "skiko.wasm", "skikod8.mjs")
}

Why not compose.web.targets() or compose.platformTypes? Both APIs in the Compose Gradle Plugin are deprecated in a circular chain: targets() suggests platformTypes, which suggests the Kotlin Compose Compiler Plugin (org.jetbrains.kotlin.plugin.compose). However, the compiler plugin only handles compiler configuration, not Skiko runtime bundling. There is no non-deprecated API for this in Compose Multiplatform 1.10.x. Verified in the plugin source: WebExtension.kt and ComposeExtension.kt.

Note: This configuration is only needed in the app project (not in library modules). A new section has been added to README.md documenting this workaround for library users.

Original prompt

This section details on the original issue you should resolve

<issue_title>"skiko.js" present in the demo JS DOM distribution</issue_title>
<issue_description>https://huanshankeji.github.io/compose-multiplatform-html-unified/js-dom/skiko.js</issue_description>

<agent_instructions>These Skiko files should not exist in the distribution because the code for the JS target dependens on DOM-based Compose HTML. Try to figure out which dependency introduced this. Or did the Compose toolchain introduced this? And how to get rid of them?</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@ShreckYe Checked again using `jsBrowserDistribution` in the `dev` branch with the new dependency versions. This is still an issue. File location: `demo/build/dist/js/productionExecutable/skiko.mjs`. It's just `skiko.mjs` instead of `skiko.js` now. There are also `skiko.wasm` and `skikod8.mjs` in the directory. @ShreckYe These [Skiko](https://github.com/jetbrains/skiko) files should not exist in the distribution because the code for the JS target dependens on DOM-based Compose HTML. Try to figure out which dependency introduced this. Or did the Compose toolchain introduced this? And how to get rid of them?

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…ose.web.targets

Configure compose.web.targets() to only include the wasmJs target.
The JS target uses DOM-based Compose HTML and does not need Skiko.
Previously, the Compose Gradle Plugin's default behavior included all
KotlinJsIrTarget targets, causing Skiko files (skiko.mjs, skiko.wasm,
skikod8.mjs) to be unnecessarily bundled into the JS DOM distribution.

Co-authored-by: ShreckYe <27768951+ShreckYe@users.noreply.github.com>
Agent-Logs-Url: https://github.com/huanshankeji/compose-multiplatform-html-unified/sessions/27cf4d8b-4b13-4208-9a34-c3630da9a474
Copilot AI changed the title [WIP] Fix skiko files present in JS DOM distribution Exclude Skiko files from JS DOM distribution via compose.web.targets Mar 22, 2026
Copilot AI requested a review from ShreckYe March 22, 2026 13:55
Copy link
Copy Markdown
Member

@ShreckYe ShreckYe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed works, but this way is deprecated.

Copy link
Copy Markdown
Member

@ShreckYe ShreckYe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. See I've moved it to the demo project because it's only needed inthe app project as I tested.
  2. You fix uses deprecated APIs. Try to migrate to the latest APIs. Try to find Kotlin's official docs and blogs on this deprecation to fix this problem, and also show me what you found.
  3. Update README.md asking users to configure this instead since it's only needed in the app project.

Comment thread demo/build.gradle.kts Outdated
…Resources exclude

Both compose.web.targets() and compose.platformTypes are deprecated in a circular
chain that leads to the Kotlin Compose Compiler Plugin, which only handles compiler
configuration, not Skiko runtime bundling. There is no non-deprecated API for this
in Compose Multiplatform 1.10.x.

Use a Gradle-native workaround to exclude Skiko files from jsProcessResources instead.
Also add README section documenting the workaround for library users.

Co-authored-by: ShreckYe <27768951+ShreckYe@users.noreply.github.com>
Agent-Logs-Url: https://github.com/huanshankeji/compose-multiplatform-html-unified/sessions/3a68a00f-aeeb-407a-8fe0-6be551c105a9
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 22, 2026

  1. See I've moved it to the demo project because it's only needed inthe app project as I tested.
  2. You fix uses deprecated APIs. Try to migrate to the latest APIs. Try to find Kotlin's official docs ...

Addressed all three points in 54a5c65:

  1. Configuration is in the demo project only.
  2. Replaced the deprecated compose.web.targets() with a Gradle-native tasks.named<ProcessResources>("jsProcessResources") { exclude(...) }. The full deprecation research: targets() → suggests platformTypes → suggests Kotlin Compose Compiler Plugin — but the compiler plugin has no Skiko runtime API. Verified in WebExtension.kt and ComposeExtension.kt. No non-deprecated alternative exists in Compose Multiplatform 1.10.x.
  3. Added a "Excluding Skiko from the JS DOM distribution" section to README.md with the configuration snippet for users.

@sonarqubecloud
Copy link
Copy Markdown

Copilot AI changed the title Exclude Skiko files from JS DOM distribution via compose.web.targets Exclude Skiko files from JS DOM distribution via Gradle-native jsProcessResources exclude Mar 22, 2026
Copilot AI requested a review from ShreckYe March 22, 2026 21:17
@ShreckYe ShreckYe marked this pull request as ready for review March 22, 2026 21:19
@ShreckYe
Copy link
Copy Markdown
Member

ShreckYe commented Mar 23, 2026

This doesn't work (commit 0b39cce):

kotlin {
    composeCompiler {
        targetKotlinPlatforms.set(KotlinPlatformType.entries - KotlinPlatformType.js)
    }
}

@ShreckYe
Copy link
Copy Markdown
Member

Deferred to after checking this in our internal projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"skiko.js" present in the demo JS DOM distribution

2 participants