Skip to content

Enable WasmJs target #822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

Tetraquark
Copy link
Contributor

This is a continuation of the pool request: #724. Issue: #582

The main goal of this pull request: enabling the WasmJs target. What has been done:

  1. Kotlin version has been updated to 2.1.21, along with updates to several dependency versions
  2. Added wasmJs support in resources and resources-generator
  3. Added a wasmJs sample in compose-resources-gallery

luca992 and others added 12 commits May 26, 2024 22:07
In wasmJs generated code have to handle:

Calls to 'js(code)' should be a single expression inside a top-level function body or a property initializer in Kotlin/Wasm.
# Conflicts:
#	gradle/libs.versions.toml
#	gradle/moko.versions.toml
#	resources-build-logic/src/main/kotlin/multiplatform-library-convention.gradle.kts
#	resources-compose/build.gradle.kts
#	resources/build.gradle.kts
#	samples/compose-resources-gallery/gradle.properties
@Alex009 Alex009 linked an issue Jun 10, 2025 that may be closed by this pull request
@Tetraquark Tetraquark changed the title WIP: Enable WasmJs target Enable WasmJs target Jun 10, 2025
@@ -1,5 +1,5 @@
[versions]
resourcesVersion = "0.24.5"
resourcesVersion = "0.24.6"
Copy link
Member

Choose a reason for hiding this comment

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

we have new feature (wasm support) and updated requirements (kotlin 2.1), so we should set 0.25.0 version

// For https://youtrack.jetbrains.com/issue/KT-61573
targets.configureEach {
compilations.configureEach {
compileTaskProvider.get().compilerOptions {
Copy link
Member

Choose a reason for hiding this comment

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

instead of eager resolve task use lazy configuration please.
compileTaskProvider.configure {
..
}

): Font? {
val bytes: ByteArray? by produceByteArray(url = fileUrl)

return remember(fileUrl, bytes?.size ?: 0) {
Copy link
Member

Choose a reason for hiding this comment

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

i think better use key bytes, weight, style (it's all outside dependencies).
is fileUrl + bytes.size better in perfomance than using bytes?

import dev.icerock.gradle.utils.flatName
import java.io.File

internal class WasmJsFontResourceGenerator(
Copy link
Member

Choose a reason for hiding this comment

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

is it some differences between wasm and js generators? looks like they identical. maybe we will just use single implementation for both targets?

@@ -42,7 +42,7 @@ import platform.darwin.UInt8Var
import kotlin.native.internal.ObjCErrorException

actual class FontResource(
val fontName: String,
val fontName: String = "",
Copy link
Member

Choose a reason for hiding this comment

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

why we need this?

@@ -29,6 +29,9 @@ dependencyResolutionManagement {
mavenLocal()
}
versionCatalogs {
create("libs") {
from(files("../../gradle/libs.versions.toml"))
Copy link
Member

Choose a reason for hiding this comment

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

samples not use same versions as library to check potential conflicts, please revert this

@@ -9,6 +9,9 @@ dependencyResolutionManagement {
mavenLocal()
}
versionCatalogs {
create("libs") {
from(files("../../gradle/libs.versions.toml"))
Copy link
Member

Choose a reason for hiding this comment

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

samples not use same versions as library to check potential conflicts, please revert this

@@ -30,6 +31,9 @@ dependencyResolutionManagement {
}

versionCatalogs {
create("libs") {
from(files("../../gradle/libs.versions.toml"))
Copy link
Member

Choose a reason for hiding this comment

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

samples not use same versions as library to check potential conflicts, please revert this

@@ -9,6 +9,9 @@ dependencyResolutionManagement {
mavenLocal()
}
versionCatalogs {
create("libs") {
from(files("../../gradle/libs.versions.toml"))
Copy link
Member

Choose a reason for hiding this comment

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

samples not use same versions as library to check potential conflicts, please revert this

@@ -9,6 +9,9 @@ dependencyResolutionManagement {
mavenLocal()
}
versionCatalogs {
create("libs") {
from(files("../../gradle/libs.versions.toml"))
Copy link
Member

Choose a reason for hiding this comment

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

samples not use same versions as library to check potential conflicts, please revert this

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.

No support for wasm on multiplatform
3 participants