[Wizard, JS] Change js compiler default
^KT-41656 fixed
This commit is contained in:
+2
-2
@@ -11,12 +11,12 @@ repositories {
|
||||
}
|
||||
}
|
||||
kotlin {
|
||||
js('nodeJs') {
|
||||
js('nodeJs', LEGACY) {
|
||||
nodejs {
|
||||
binaries.executable()
|
||||
}
|
||||
}
|
||||
js('browser') {
|
||||
js('browser', LEGACY) {
|
||||
browser {
|
||||
binaries.executable()
|
||||
webpackTask {
|
||||
|
||||
+2
-2
@@ -11,12 +11,12 @@ repositories {
|
||||
}
|
||||
}
|
||||
kotlin {
|
||||
js("nodeJs") {
|
||||
js("nodeJs", LEGACY) {
|
||||
nodejs {
|
||||
binaries.executable()
|
||||
}
|
||||
}
|
||||
js("browser") {
|
||||
js("browser", LEGACY) {
|
||||
browser {
|
||||
binaries.executable()
|
||||
webpackTask {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ kotlin {
|
||||
kotlinOptions.jvmTarget = '9'
|
||||
}
|
||||
}
|
||||
js('a') {
|
||||
js('a', LEGACY) {
|
||||
browser {
|
||||
binaries.executable()
|
||||
webpackTask {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ kotlin {
|
||||
kotlinOptions.jvmTarget = "9"
|
||||
}
|
||||
}
|
||||
js("a") {
|
||||
js("a", LEGACY) {
|
||||
browser {
|
||||
binaries.executable()
|
||||
webpackTask {
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ dependencies {
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-js'
|
||||
}
|
||||
kotlin {
|
||||
js {
|
||||
js(LEGACY) {
|
||||
browser {
|
||||
binaries.executable()
|
||||
webpackTask {
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ dependencies {
|
||||
testImplementation(kotlin("test-js"))
|
||||
}
|
||||
kotlin {
|
||||
js {
|
||||
js(LEGACY) {
|
||||
browser {
|
||||
binaries.executable()
|
||||
webpackTask {
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ dependencies {
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-js'
|
||||
}
|
||||
kotlin {
|
||||
js {
|
||||
js(LEGACY) {
|
||||
nodejs {
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ dependencies {
|
||||
testImplementation(kotlin("test-js"))
|
||||
}
|
||||
kotlin {
|
||||
js {
|
||||
js(LEGACY) {
|
||||
nodejs {
|
||||
binaries.executable()
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ dependencies {
|
||||
testImplementation 'org.jetbrains.kotlin:kotlin-test-js'
|
||||
}
|
||||
kotlin {
|
||||
js {
|
||||
js(LEGACY) {
|
||||
browser {
|
||||
binaries.executable()
|
||||
webpackTask {
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ dependencies {
|
||||
testImplementation(kotlin("test-js"))
|
||||
}
|
||||
kotlin {
|
||||
js {
|
||||
js(LEGACY) {
|
||||
browser {
|
||||
binaries.executable()
|
||||
webpackTask {
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ kotlin {
|
||||
}
|
||||
withJava()
|
||||
}
|
||||
js {
|
||||
js(LEGACY) {
|
||||
browser {
|
||||
binaries.executable()
|
||||
webpackTask {
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ kotlin {
|
||||
}
|
||||
withJava()
|
||||
}
|
||||
js {
|
||||
js(LEGACY) {
|
||||
browser {
|
||||
binaries.executable()
|
||||
webpackTask {
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ kotlin {
|
||||
kotlinOptions.jvmTarget = '1.8'
|
||||
}
|
||||
}
|
||||
js {
|
||||
js(LEGACY) {
|
||||
browser {
|
||||
testTask {
|
||||
useKarma {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ kotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
js {
|
||||
js(LEGACY) {
|
||||
browser {
|
||||
testTask {
|
||||
useKarma {
|
||||
|
||||
+10
-6
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.GradleIRLi
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.irsList
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.BrowserJsSinglePlatformModuleConfigurator.settingsValue
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.JSConfigurator.Companion.isApplication
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.JSConfigurator.Companion.jsCompilerParam
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.JsBrowserBasedConfigurator.Companion.browserSubTarget
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.JsBrowserBasedConfigurator.Companion.cssSupport
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.JsNodeBasedConfigurator.Companion.nodejsSubTarget
|
||||
@@ -44,7 +45,6 @@ interface JSConfigurator : ModuleConfiguratorWithModuleType, ModuleConfiguratorW
|
||||
GradlePlugin.gradleProperties
|
||||
.addValues(
|
||||
"kotlin.js.generate.executable.default" to "false",
|
||||
"kotlin.js.compiler" to JsCompiler.IR.text.toLowerCase()
|
||||
)
|
||||
|
||||
override fun getConfiguratorSettings(): List<ModuleConfiguratorSetting<*, *>> =
|
||||
@@ -72,7 +72,7 @@ interface JSConfigurator : ModuleConfiguratorWithModuleType, ModuleConfiguratorW
|
||||
KotlinNewProjectWizardBundle.message("module.configurator.js.target.settings.compiler"),
|
||||
GenerationPhase.PROJECT_GENERATION
|
||||
) {
|
||||
defaultValue = value(JsCompiler.IR)
|
||||
defaultValue = value(JsCompiler.LEGACY)
|
||||
filter = filter@{ reference, compilerCandidate ->
|
||||
when {
|
||||
reference !is ModuleConfiguratorSettingReference<*, *> -> false
|
||||
@@ -84,6 +84,11 @@ interface JSConfigurator : ModuleConfiguratorWithModuleType, ModuleConfiguratorW
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Reader.jsCompilerParam(
|
||||
module: Module
|
||||
): String? =
|
||||
settingValue(module, compiler)?.text
|
||||
|
||||
fun Reader.isApplication(module: Module): Boolean =
|
||||
settingsValue(module, kind) == JsTargetKind.APPLICATION
|
||||
}
|
||||
@@ -156,10 +161,9 @@ abstract class JsSinglePlatformModuleConfigurator :
|
||||
module: Module
|
||||
): List<BuildSystemIR> = irsList {
|
||||
"kotlin" {
|
||||
val compiler = reader.settingsValue(module, JSConfigurator.compiler)
|
||||
val param = if (compiler != JsCompiler.IR) {
|
||||
"(${compiler.text})"
|
||||
} else ""
|
||||
val param = reader.jsCompilerParam(module)
|
||||
?.let { "($it)" } ?: ""
|
||||
|
||||
"js${param}" {
|
||||
subTarget(module, reader)
|
||||
}
|
||||
|
||||
+7
-12
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.GradleStri
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.irsList
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.multiplatform.DefaultTargetConfigurationIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.ir.buildsystem.gradle.multiplatform.TargetAccessIR
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.JSConfigurator.Companion.jsCompilerParam
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.JsBrowserBasedConfigurator.Companion.browserSubTarget
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.JsBrowserBasedConfigurator.Companion.cssSupport
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.JsNodeBasedConfigurator.Companion.nodejsSubTarget
|
||||
@@ -79,16 +80,6 @@ internal fun Module.createTargetAccessIr(
|
||||
|
||||
interface JsTargetConfigurator : JSConfigurator, TargetConfigurator, SingleCoexistenceTargetConfigurator, ModuleConfiguratorWithSettings
|
||||
|
||||
internal fun JsTargetConfigurator.jsCompilerParam(
|
||||
reader: Reader,
|
||||
module: Module
|
||||
) =
|
||||
reader.settingValue(module, JSConfigurator.compiler)?.let {
|
||||
if (it != JsCompiler.IR) {
|
||||
listOf(it.text)
|
||||
} else emptyList()
|
||||
} ?: emptyList()
|
||||
|
||||
enum class JsTargetKind(override val text: String) : DisplayableSettingItem {
|
||||
LIBRARY(KotlinNewProjectWizardBundle.message("module.configurator.js.target.settings.kind.library")),
|
||||
APPLICATION(KotlinNewProjectWizardBundle.message("module.configurator.js.target.settings.kind.application"))
|
||||
@@ -119,7 +110,7 @@ object JsBrowserTargetConfigurator : JsTargetConfigurator, ModuleConfiguratorWit
|
||||
+DefaultTargetConfigurationIR(
|
||||
module.createTargetAccessIr(
|
||||
ModuleSubType.js,
|
||||
jsCompilerParam(this@createTargetIrs, module)
|
||||
paramsWithJsCompiler(module)
|
||||
)
|
||||
) {
|
||||
browserSubTarget(module, this@createTargetIrs)
|
||||
@@ -139,7 +130,7 @@ object JsNodeTargetConfigurator : JsTargetConfigurator {
|
||||
+DefaultTargetConfigurationIR(
|
||||
module.createTargetAccessIr(
|
||||
ModuleSubType.js,
|
||||
jsCompilerParam(this@createTargetIrs, module)
|
||||
paramsWithJsCompiler(module)
|
||||
)
|
||||
) {
|
||||
nodejsSubTarget(module, this@createTargetIrs)
|
||||
@@ -147,6 +138,10 @@ object JsNodeTargetConfigurator : JsTargetConfigurator {
|
||||
}
|
||||
}
|
||||
|
||||
internal fun Reader.paramsWithJsCompiler(module: Module): List<String> = jsCompilerParam(module)?.let {
|
||||
listOf(it)
|
||||
} ?: emptyList()
|
||||
|
||||
object CommonTargetConfigurator : TargetConfiguratorWithTests(), SimpleTargetConfigurator, SingleCoexistenceTargetConfigurator {
|
||||
override val moduleSubType = ModuleSubType.common
|
||||
override val text: String = KotlinNewProjectWizardBundle.message("module.configurator.common")
|
||||
|
||||
Reference in New Issue
Block a user