[JS, Wizard] Add different compilers for JS wizard
^KT-41418 fixed
This commit is contained in:
+1
@@ -96,6 +96,7 @@ module.configurator.js.node=Node.js
|
|||||||
|
|
||||||
module.configurator.js.css=CSS Support
|
module.configurator.js.css=CSS Support
|
||||||
module.configurator.js.target.settings.kind=Target kind
|
module.configurator.js.target.settings.kind=Target kind
|
||||||
|
module.configurator.js.target.settings.compiler=JS Compiler
|
||||||
module.configurator.js.target.settings.kind.library=Library
|
module.configurator.js.target.settings.kind.library=Library
|
||||||
module.configurator.js.target.settings.kind.application=Application
|
module.configurator.js.target.settings.kind.application=Application
|
||||||
|
|
||||||
|
|||||||
+21
-2
@@ -42,10 +42,13 @@ interface JSConfigurator : ModuleConfiguratorWithModuleType, ModuleConfiguratorW
|
|||||||
modulePath: Path
|
modulePath: Path
|
||||||
): TaskResult<Unit> =
|
): TaskResult<Unit> =
|
||||||
GradlePlugin.gradleProperties
|
GradlePlugin.gradleProperties
|
||||||
.addValues("kotlin.js.generate.executable.default" to "false")
|
.addValues(
|
||||||
|
"kotlin.js.generate.executable.default" to "false",
|
||||||
|
"kotlin.js.compiler" to settingsValue(module, compiler).text.toLowerCase()
|
||||||
|
)
|
||||||
|
|
||||||
override fun getConfiguratorSettings(): List<ModuleConfiguratorSetting<*, *>> =
|
override fun getConfiguratorSettings(): List<ModuleConfiguratorSetting<*, *>> =
|
||||||
super.getConfiguratorSettings() + kind
|
super.getConfiguratorSettings() + kind + compiler
|
||||||
|
|
||||||
companion object : ModuleConfiguratorSettings() {
|
companion object : ModuleConfiguratorSettings() {
|
||||||
val kind by enumSetting<JsTargetKind>(
|
val kind by enumSetting<JsTargetKind>(
|
||||||
@@ -65,6 +68,22 @@ interface JSConfigurator : ModuleConfiguratorWithModuleType, ModuleConfiguratorW
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val compiler by enumSetting<JsCompiler>(
|
||||||
|
KotlinNewProjectWizardBundle.message("module.configurator.js.target.settings.compiler"),
|
||||||
|
GenerationPhase.PROJECT_GENERATION
|
||||||
|
) {
|
||||||
|
defaultValue = value(JsCompiler.IR)
|
||||||
|
filter = filter@{ reference, compilerCandidate ->
|
||||||
|
when {
|
||||||
|
reference !is ModuleConfiguratorSettingReference<*, *> -> false
|
||||||
|
reference.module?.let { settingValue(it, kind) } == JsTargetKind.LIBRARY -> true
|
||||||
|
reference.module?.let { settingValue(it, kind) } == JsTargetKind.APPLICATION
|
||||||
|
&& compilerCandidate == JsCompiler.BOTH -> false
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun Reader.isApplication(module: Module): Boolean =
|
fun Reader.isApplication(module: Module): Boolean =
|
||||||
settingsValue(module, kind) == JsTargetKind.APPLICATION
|
settingsValue(module, kind) == JsTargetKind.APPLICATION
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -79,6 +79,12 @@ enum class JsTargetKind(override val text: String) : DisplayableSettingItem {
|
|||||||
APPLICATION(KotlinNewProjectWizardBundle.message("module.configurator.js.target.settings.kind.application"))
|
APPLICATION(KotlinNewProjectWizardBundle.message("module.configurator.js.target.settings.kind.application"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class JsCompiler(override val text: String) : DisplayableSettingItem {
|
||||||
|
IR("IR"),
|
||||||
|
LEGACY("LEGACY"),
|
||||||
|
BOTH("BOTH")
|
||||||
|
}
|
||||||
|
|
||||||
object JsBrowserTargetConfigurator : JsTargetConfigurator, ModuleConfiguratorWithTests {
|
object JsBrowserTargetConfigurator : JsTargetConfigurator, ModuleConfiguratorWithTests {
|
||||||
override fun getConfiguratorSettings(): List<ModuleConfiguratorSetting<*, *>> =
|
override fun getConfiguratorSettings(): List<ModuleConfiguratorSetting<*, *>> =
|
||||||
super<ModuleConfiguratorWithTests>.getConfiguratorSettings() +
|
super<ModuleConfiguratorWithTests>.getConfiguratorSettings() +
|
||||||
|
|||||||
Reference in New Issue
Block a user