copper-leaf / ballast

Opinionated Application State Management framework for Kotlin Multiplatform
https://copper-leaf.github.io/ballast/
BSD 3-Clause "New" or "Revised" License
147 stars 10 forks source link

Support WASM target #54

Closed cjbrooks12 closed 4 months ago

cjbrooks12 commented 1 year ago

Create a version of Ballast that supports WASM targets. It will likely need to wait until all of its libraries also support WASM (coroutines, serialization, UUID, etc.) or only develop this on another branch and only release the modules which don't have any external dependencies other than Coroutines.

charlee-dev commented 8 months ago

Yeah, this one would be nice. I wanted to try WASM in my biggish project and noticed that ballast I blocking me... Will see how much effort adding the wasm will take. 🤞

charlee-dev commented 8 months ago

question by applying applyDefaultHierarchyTemplate() Gradle generates sourceSets based on targets we applied. This lets me make this change:

Old

kotlin {    
    val subprojectInfo = ConventionConfig.subprojectInfo(project)

    sourceSets {
        if (subprojectInfo.kotlinJs) {
            val jsTest by getting {
                 dependencies { }
            }
        }

        // more sourceSets
     }
}

New

kotlin {
    applyDefaultHierarchyTemplate()

    val subprojectInfo = ConventionConfig.subprojectInfo(project)

    sourceSets {
        if (subprojectInfo.kotlinJs) {
            jsTest.dependencies { }
        }

        // more sourceSets
     }
}

But having jsTest.dependencies { } is not needed at all, because applyDefaultHierarchyTemplate() will create a placeholder for it.

So the question is, Do you prefer to keep those empty or clean them up? I would prefer the cleanup. Less code less to maintain and less bugs.

cjbrooks12 commented 8 months ago

I'd prefer to keep them there. It has helped me identify issues in the past with typos in the sourcesets or wrong configurations, so I use it as a bit of a check to make sure things are set up correctly.

cjbrooks12 commented 8 months ago

Yeah, this one would be nice. I wanted to try WASM in my biggish project and noticed that ballast I blocking me... Will see how much effort adding the wasm will take. 🤞

I, myself, have been blocked by Kotest with WASM support. There's a few other libraries that might also need to be updated (or replaced) before Ballast can be updated, but I hadn't even gotten that far into looking into it. I initially started working to get WASM included in the next Ballast release, but when I realized there's still a bit of work to be done and some dependencies/plugins that may need workarounds or to be disabled, I decided to hold off and release Ballast 4.1 with the Scheduler first, and then come back to it shortly afterward.

rjaros commented 4 months ago

Kotest 5.9.0 with Wasm support was just released.

cjbrooks12 commented 4 months ago

Yes, I was so excited to see that drop yesterday! I've already started getting Ballast updated with it, planning to do a lot of work on it over the weekend, and hopefully I can get WASM support released very soon.

cjbrooks12 commented 4 months ago

Good news, initial results are very promising. ballast-core compiles to wasmJs and all tests are passing with no code modifications. I've yet to try including it in a Compose WASM app, but from the ease of these initial updates, I'm hopeful that I will be able to get this published very soon.

The wasmWasi target cannot be supported yet because kotlinx.coroutines doesn't yet support it either: https://github.com/Kotlin/kotlinx.coroutines/pull/4064.

cjbrooks12 commented 4 months ago

Released in v4.2.0