I've found quite a few places with people asking t...
# multiplatform
i
I've found quite a few places with people asking this question but can't find an answer. With a JS project depending on a KMP project, it seems the resources in KMP JS are not available in the JS project. Example use case, trying to have a single index.html shared between two platform specific js projects seems to require defining a common resource sourceset as the shared common KMP project does not seem to expose the platform resources. Am I missing something?
b
Kjs does not support embedded resources yet (even though the are packaged in klib). Best workaround is to publish your assets as npm package and add them to kjs module as npm dependency. kvision-assets npm package is a good example of that.
i
Hmm that's really unfortunate but thank you for the answer.
b
Trust me, you're not the first nor the last person to get annoyed by this 😄 Although if you have time to burn, you could process klibs in some gradle task and extract all those resources to your module's
processedResources
i
I already have a bruce force work around copying directories around with gradle tasks, I was just circling back to this today to see if I missed something and I still couldn't get it working without falling back to some common resource directory. All good, still early days and all that.
b
My suggestion above would only be useful if you don't have everything in a monorepo and rely on published artefacts. Anyways, glad to hear you have it working.
i
Right, and I am in a monorepo but I understand what you meant. The other nice to have would be a built in proxy server for CORS but again just wrote my own work arounds for that 😛
b
Workarounds is the name of the game with KMP I'm affraid 😄
c
Since it's all already in the archive, it would be so easy to create a Gradle plugin to handle all of this 😕 I don't have the knowhow to do it sadly
m
Had this same issue a bit ago. Ended up just publishing all the assets to
npmjs
and then consumed them in my other project(s). Some things to checkout: • npm-publish • publish locally via Verdaccio (great for snapshots)