Kotlin / kotlinx-atomicfu

The idiomatic way to use atomic operations in Kotlin
Other
885 stars 57 forks source link

Add support for Kotlin/Wasm #278

Closed sdeleuze closed 10 months ago

sdeleuze commented 1 year ago

We begin to need Kotlin/Wasm support in kotlinx-atomicfu for supporting Wasm in the ecosystem. There is a concrete need in https://github.com/bendgk/effekt that is currently being ported to multiplatform.

When using version 0.20.0, we get Unsupported transformation platform 'wasm' and the special version 0.18.5-wasm0 deployed in https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental/ expected to work with wasm does not seems to be usable on this project (conflict with Gradle or other related errors).

The release of Kotlin 1.8.20 is going to increase Wasm reach to would be nice to get it supported upstream.

eygraber commented 1 year ago

I have several Compose Multiplatform projects that I'd like to add wasm support to, but I cannot because I'm blocked by atomicfu.

qwwdfsad commented 1 year ago

We are planning to add WASM to our regular releases post-1.9.0. For now, it's available in Maven repository https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental under experimental coordinates

bashor commented 10 months ago

Related PR #334

mvicsokolova commented 10 months ago

Since 0.23.0 release kotlinx-atomicfu supports both wasmJs and wasmWasi targets 🎉.

bashor commented 10 months ago

Kudos to @mvicsokolova & @igoriakovlev! 👏

chris-hatton commented 3 weeks ago

Thanks for the work to bring this to WASM; noting that I currently see a warning when compiling:

A compileOnly dependency is used in targets: Kotlin/Native, Kotlin/Wasm.
Dependencies:
    - org.jetbrains.kotlinx:atomicfu:0.25.0 (source sets: webMain)

Using compileOnly dependencies in these targets is not currently supported, because compileOnly dependencies must be present during the compilation of projects that depend on this project.

To ensure consistent compilation behaviour, compileOnly dependencies should be exposed as api dependencies.

Example:

    kotlin {
        sourceSets {
            nativeMain {
                dependencies {
                    compileOnly("org.example:lib:1.2.3")
                    // additionally add the compileOnly dependency as an api dependency:
                    api("org.example:lib:1.2.3")
                }
            }
        }
    }

This warning can be suppressed in gradle.properties:

    kotlin.suppressGradlePluginWarnings=IncorrectCompileOnlyDependencyWarning

...I don't use compileOnly, I only applied the plugin, so I guess this is added by the plugin. Explicitly adding api("org.jetbrains.kotlinx:atomicfu:0.25.0") to commonMain makes the warning go away, but not sure of the desired state here.