[K/JS] Introduce v2015 target

This commit is contained in:
Artem Kobzar
2024-03-06 12:21:38 +00:00
committed by Space Team
parent e989e6d397
commit 77f0cba23f
19 changed files with 115 additions and 84 deletions
@@ -33,6 +33,7 @@ annotation class GradleOption(
enum class DefaultValue {
BOOLEAN_FALSE_DEFAULT,
BOOLEAN_TRUE_DEFAULT,
BOOLEAN_NULL_DEFAULT,
STRING_NULL_DEFAULT,
EMPTY_STRING_LIST_DEFAULT,
EMPTY_STRING_ARRAY_DEFAULT,
@@ -166,7 +166,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
gradleInputType = GradleInputTypes.INPUT,
shouldGenerateDeprecatedKotlinOptions = true,
)
@Argument(value = "-target", valueDescription = "{ v5 }", description = "Generate JS files for the specified ECMA version.")
@Argument(value = "-target", valueDescription = "{ es5, es2015 }", description = "Generate JS files for the specified ECMA version.")
var target: String? = null
set(value) {
checkFrozen()
@@ -192,12 +192,12 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
@Argument(
value = "-module-kind",
valueDescription = "{plain|amd|commonjs|umd|es}",
description = "The kind of JS module generated by the compiler."
description = "The kind of JS module generated by the compiler. ES modules are enabled by default in case of ES2015 target usage"
)
var moduleKind: String? = MODULE_PLAIN
var moduleKind: String? = null
set(value) {
checkFrozen()
field = if (value.isNullOrEmpty()) MODULE_PLAIN else value
field = value
}
@GradleOption(
@@ -460,15 +460,15 @@ In combination with '-meta-info', this generates both IR and pre-IR versions of
}
@GradleOption(
value = DefaultValue.BOOLEAN_FALSE_DEFAULT,
value = DefaultValue.BOOLEAN_NULL_DEFAULT,
gradleInputType = GradleInputTypes.INPUT,
shouldGenerateDeprecatedKotlinOptions = true,
)
@Argument(
value = "-Xes-classes",
description = "Let generated JavaScript code use ES2015 classes."
description = "Let generated JavaScript code use ES2015 classes. Enabled by default in case of ES2015 target usage"
)
var useEsClasses = false
var useEsClasses: Boolean? = null
set(value) {
checkFrozen()
field = value
@@ -486,9 +486,9 @@ In combination with '-meta-info', this generates both IR and pre-IR versions of
@Argument(
value = "-Xes-generators",
description = "Enable ES2015 generator functions usage inside the compiled code"
description = "Enable ES2015 generator functions usage inside the compiled code. Enabled by default in case of ES2015 target usage"
)
var useEsGenerators = false
var useEsGenerators: Boolean? = null
set(value) {
checkFrozen()
field = value
@@ -657,7 +657,7 @@ In combination with '-meta-info', this generates both IR and pre-IR versions of
collector.deprecationWarn(irBaseClassInMetadata, false, "-Xir-base-class-in-metadata")
collector.deprecationWarn(irNewIr2Js, true, "-Xir-new-ir2js")
if (irPerFile && moduleKind != MODULE_ES) {
if (irPerFile && (moduleKind != MODULE_ES && target != ES_2015)) {
collector.report(
CompilerMessageSeverity.ERROR,
"Per-file compilation can't be used with any `moduleKind` except `es` (ECMAScript Modules)"
@@ -26,6 +26,8 @@ public interface K2JsArgumentConstants {
String MODULE_UMD = "umd";
String MODULE_ES = "es";
String ES_2015 = "es2015";
String GRANULARITY_WHOLE_PROGRAM = "whole-program";
String GRANULARITY_PER_MODULE = "per-module";
String GRANULARITY_PER_FILE = "per-file";