compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

resources demo js workaround

Open dima-avdeev-jb opened this issue 2 years ago • 5 comments

dima-avdeev-jb avatar Jan 09 '23 18:01 dima-avdeev-jb

I asked about the issue with resources in different modules in k/js. It's a known thing, but no official solution available yet. This workaround is a valid thing to do. I took it for Compose k/wasm experiments. So it's okay to merge in my opinion.

eymar avatar Feb 24 '23 15:02 eymar

@eymar For now, JS resources work fine if JS app "executable" is specified in shared module. So, maybe this PR is redundant.

./gradlew :resources:demo:shared:jsBrowserDevelopmentRun - works fine.

dima-avdeev-jb avatar Feb 24 '23 16:02 dima-avdeev-jb

That's right. This workaround will be needed if we have many modules with different resources and all of them need to be included in the final distribution. So if we keep the "executable" JS in the same module where we keep the resources, then it's fine and workaround is not needed indeed.

eymar avatar Feb 24 '23 16:02 eymar

@eymar I think we can postpone current PR after Kotlin Conf.

dima-avdeev-jb avatar Feb 24 '23 16:02 dima-avdeev-jb

Yeah, not urgent.

Just some notes for the time we decided to get back to it: demo/jsMain/resources contains the copy of resources, so it would work even without a workaround in this PR.

So I changed it a bit in my branch to make it work:

val copyResources = tasks.create("copyJsResourcesWorkaround", Copy::class.java) {
    from(project(":resources:demo:shared").file("src/commonMain/resources"))
    into("build/processedResources/js/main")
}

afterEvaluate {
    project.tasks.getByName("jsProcessResources").finalizedBy(copyResources)
}

eymar avatar Feb 24 '23 16:02 eymar