[K/JS] Move ES modules logic to a new transformer with IC

This commit is contained in:
Artem Kobzar
2022-10-13 07:32:44 +00:00
committed by Space Team
parent 54deba63a1
commit de880ce9aa
88 changed files with 2476 additions and 1134 deletions
@@ -183,4 +183,8 @@ constructor(
}
}
}
override fun useEsModules() {
error("ES modules are not supported in legacy JS compiler. Please, use IR one instead.")
}
}
@@ -53,6 +53,7 @@ interface KotlinJsTargetDsl : KotlinTarget {
}
fun useCommonJs()
fun useEsModules()
val binaries: KotlinJsBinaryContainer
@@ -358,9 +358,30 @@ constructor(
legacyTarget?.useCommonJs()
}
override fun useEsModules() {
compilations.all {
it.kotlinOptions.configureEsModulesOptions()
binaries
.withType(JsIrBinary::class.java)
.all {
it.linkTask.configure { linkTask ->
linkTask.kotlinOptions.configureEsModulesOptions()
}
}
}
}
private fun KotlinJsOptions.configureCommonJsOptions() {
moduleKind = "commonjs"
sourceMap = true
sourceMapEmbedSources = "never"
}
private fun KotlinJsOptions.configureEsModulesOptions() {
moduleKind = "es"
sourceMap = true
sourceMapEmbedSources = "never"
}
}