[Gradle, JS] Default conpiler type instead of legacy
This commit is contained in:
+4
-2
@@ -98,8 +98,10 @@ open class KotlinJsProjectExtension : KotlinSingleTargetExtension() {
|
||||
|
||||
override lateinit var target: KotlinJsTargetDsl
|
||||
|
||||
internal lateinit var defaultCompilerType: JsCompilerType
|
||||
|
||||
open fun js(
|
||||
compiler: JsCompilerType = legacy,
|
||||
compiler: JsCompilerType = defaultCompilerType,
|
||||
body: KotlinJsTargetDsl.() -> Unit
|
||||
) {
|
||||
val target: KotlinJsTargetDsl = when (compiler) {
|
||||
@@ -131,7 +133,7 @@ open class KotlinJsProjectExtension : KotlinSingleTargetExtension() {
|
||||
|
||||
open fun js(
|
||||
body: KotlinJsTargetDsl.() -> Unit
|
||||
) = js(compiler = legacy, body = body)
|
||||
) = js(compiler = defaultCompilerType, body = body)
|
||||
|
||||
@Deprecated("Use js instead", ReplaceWith("js(body)"))
|
||||
open fun target(body: KotlinJsTargetDsl.() -> Unit) = js(body)
|
||||
|
||||
+8
@@ -19,6 +19,8 @@ package org.jetbrains.kotlin.gradle.plugin
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.dsl.Coroutines
|
||||
import org.jetbrains.kotlin.gradle.dsl.NativeCacheKind
|
||||
import org.jetbrains.kotlin.gradle.plugin.JsCompilerType
|
||||
import org.jetbrains.kotlin.gradle.plugin.JsCompilerType.Companion.jsCompilerProperty
|
||||
import org.jetbrains.kotlin.gradle.targets.native.DisabledNativeTargetsReporter
|
||||
import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile
|
||||
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
||||
@@ -168,6 +170,12 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
||||
val jsDiscoverTypes: Boolean?
|
||||
get() = booleanProperty("kotlin.js.experimental.discoverTypes")
|
||||
|
||||
/**
|
||||
* Use Kotlin/JS backend mode
|
||||
*/
|
||||
val jsCompiler: JsCompilerType
|
||||
get() = property(jsCompilerProperty)?.let { JsCompilerType.byArgument(it) } ?: JsCompilerType.legacy
|
||||
|
||||
private fun propertyWithDeprecatedVariant(propName: String, deprecatedPropName: String): String? {
|
||||
val deprecatedProperty = property(deprecatedPropName)
|
||||
if (deprecatedProperty != null) {
|
||||
|
||||
+2
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.kotlinExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.TEST_COMPILATION_NAME
|
||||
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.plugin.configureDefaultVersionsResolutionStrategy
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsSingleTargetPreset
|
||||
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrSingleTargetPreset
|
||||
@@ -35,6 +36,7 @@ open class KotlinJsPlugin(
|
||||
kotlinExtension.apply {
|
||||
irPreset = KotlinJsIrSingleTargetPreset(project, kotlinPluginVersion)
|
||||
legacyPreset = KotlinJsSingleTargetPreset(project, kotlinPluginVersion)
|
||||
defaultCompilerType = PropertiesProvider(project).jsCompiler
|
||||
}
|
||||
|
||||
// Explicitly create configurations for main and test
|
||||
|
||||
Reference in New Issue
Block a user