Is it possible to set the module name for a Kotlin...
# javascript
n
Is it possible to set the module name for a Kotlin JS lib (a Kotlin Platform module) via Gradle Kotlin DSL?
Have two Kotlin JS libraries (both Kotlin Platform modules) which use the same module name (js). An error is being printed to the console on a missing module after running a sample program, which uses the Kotlin JS libraries via Gradle Kotlin DSL.
g
You can set different module name. Top level project property "name". Also you probably can set output file name instead, but not sure
n
Ended up applying the kotlin2js plugin and setup the compileKotlin2Js Gradle task, eg:
Copy code
val compileKotlin2Js by tasks.getting(Kotlin2JsCompile::class) {
    val destDir = "${projectDir.absolutePath}/web"
    kotlinOptions {
        outputFile = "$destDir/js/$rootProjectName-$version.js"
        sourceMap = true
        moduleKind = "umd"
    }
    doFirst { File(destDir).deleteRecursively() }
}
The key part in customising the compileKotlin2Js task is setting the kotlinOptions.outputFile property.
1