Tóth István Zoltán

08/09/2022, 12:10 PM
I've been poking around Webpack and DCE in Kotlin/JS because I would like to have dynamic module loading. I understand that this is not supported as of now, but I'm willing to put in some work to find a solution. The concept is that we have a basic application (web client + server) and the user can add modules that contain both JVM parts and UI parts. A kind of a plugin concept, many systems provide this function. The JVM part is quite trivial, we've got that working already. As for the JS part. Checking the code the Kotlin compiler produces, it seems perfectly viable to forget Webpack. This of course means no DCE, but to be honest, I don't really care about DCE. The reason is that DCE helps up until a point, but then, as the application grows, the single-bundle concept starts to hurt more than the DCE helps. So, my plan is to get rid of Webpack altogether and just go with plain modules. The real question is, how to get these modules and how to ensure that all the "requires" use the proper name. The Kotlin compiler actually produces these modules, they are there... somewhere. :) I hacked around a bit and got it almost working already. However, it would be nice to have a "clean" solution for this. I'm not really worried about dependencies, we have like 6 from Kotlin (kotlin, atomicfu, serialization, coroutines, datetime -> js-joda) and a few from our own modules. Any pointers/ideas would be welcome, thanks.