Using Kotlin to JavaScript compiler as a library?


Hello! Is it possible to use Kotlin to JavaScript compilers as a library? I’d like to write a Kotlin JVM app that will compile Kotlin code (embedded in the JAR as a set of *.kt files) to JavaScript at runtime and output the compiled code to a single dce’d and minified JavaScript file.


It is possible in the sense that all of the code is open-source and you can combine the pieces into something that will do what you need, but there is no supported API for that. The DCE module is completely separate from the compiler at this point, and minification isn’t part of Kotlin at all - we rely on existing external tools for that.