How do I define several modules in a single gradle project?

I’ve created a Kotlin react wrapper for the ring-ui library,
ring-ui is composed of many submodules, each component has a wrapper for kotlin/js. At the moment a single JS module is created as output of the gradle build which exports all wrappers and requires all ring-ui. This results in a huge JS file size in a web project when using the wrappers.

Is it possible to force compileKotlin2Js to generate distinct JS files which only export one wrapper module at a time? (e.g. ringui-kotlin-alert.js and ringui-kotlin-button.js instead of a single ringui-kotlina-all.js which defines both)

I guess that I could achieve this by generating a lot of build.gradle files, but that would be a nightmare to handle.


If I remember correctly this is not possible at least not yet. There was a post about this already here with an answer from the jetbrains team.
As far as I am aware the only option to reduce the js output size right now is still only the dce-tool. Well and sure you can create multiple gradle modules, but that would indeed be not really optimal.

Thanks @Wasabi375 for the feedback.
I’m using GitHub - JetBrains/create-react-kotlin-app: Create React apps using Kotlin with no build configuration which is supposed to already do the dce. I assume that it’s able to remove the unneeded kotln wrapper code from my module file which imports all ring-ui components and defines all wrappers. It’s probably not able to find out that a native JS component isn’t used anymore and thus doesn’t remove the unneeded imports of ring-ui components.

I’ll get back to this later on when I’m nearer to deployment of production code and hope that the Kotlin js compile plugin has better support for this scenario then.