[K/JS] Move ES modules logic to a new transformer with IC
This commit is contained in:
+4
@@ -183,4 +183,8 @@ constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun useEsModules() {
|
||||
error("ES modules are not supported in legacy JS compiler. Please, use IR one instead.")
|
||||
}
|
||||
}
|
||||
+1
@@ -53,6 +53,7 @@ interface KotlinJsTargetDsl : KotlinTarget {
|
||||
}
|
||||
|
||||
fun useCommonJs()
|
||||
fun useEsModules()
|
||||
|
||||
val binaries: KotlinJsBinaryContainer
|
||||
|
||||
|
||||
+21
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user