Is it possible to set the module name for a Kotlin JS lib (a Kotlin Platform module) via Gradle Kotlin DSL?
napperley
08/04/2018, 4:34 AM
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
gildor
08/04/2018, 12:47 PM
You can set different module name. Top level project property "name". Also you probably can set output file name instead, but not sure
n
napperley
08/05/2018, 1:26 AM
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() }
}
napperley
08/05/2018, 1:27 AM
The key part in customising the compileKotlin2Js task is setting the kotlinOptions.outputFile property.