[JS IR] Add a compiler option for generating name entries in sourcemaps

This commit is contained in:
Sergej Jaskiewicz
2022-10-04 11:17:32 +02:00
committed by Space Team
parent 8f237a60f7
commit 227864c6ec
15 changed files with 191 additions and 3 deletions
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.gradle.dsl.JsMainFunctionExecutionMode
import org.jetbrains.kotlin.gradle.dsl.JsModuleKind
import org.jetbrains.kotlin.gradle.dsl.JsSourceMapEmbedMode
import org.jetbrains.kotlin.gradle.dsl.JsSourceMapNamesPolicy
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion as KotlinVersionDsl
import org.jetbrains.kotlin.gradle.dsl.JvmTarget as JvmTargetDsl
import kotlin.reflect.KType
@@ -118,6 +119,23 @@ open class DefaultValues(
""".trimIndent()
)
object JsSourceMapNamesPolicies : DefaultValues(
"null",
typeOf<JsSourceMapNamesPolicy?>(),
typeOf<String?>(),
possibleValues = listOf(
K2JsArgumentConstants.SOURCE_MAP_NAMES_POLICY_NO,
K2JsArgumentConstants.SOURCE_MAP_NAMES_POLICY_SIMPLE_NAMES,
K2JsArgumentConstants.SOURCE_MAP_NAMES_POLICY_FQ_NAMES,
).map { "\"$it\"" },
fromKotlinOptionConverterProp = """
this?.let { ${typeOf<JsSourceMapNamesPolicy>()}.fromPolicy(it) }
""".trimIndent(),
toKotlinOptionConverterProp = """
this?.policy
""".trimIndent()
)
object JsMain : DefaultValues(
"${typeOf<JsMainFunctionExecutionMode>()}.${JsMainFunctionExecutionMode.CALL.name}",
typeOf<JsMainFunctionExecutionMode>(),
@@ -96,6 +96,17 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
)
var sourceMapEmbedSources: String? by NullableStringFreezableVar(null)
@GradleOption(
value = DefaultValues.JsSourceMapNamesPolicies::class,
gradleInputType = GradleInputTypes.INPUT
)
@Argument(
value = "-source-map-names-policy",
valueDescription = "{no|simple-names|fully-qualified-names}",
description = "How to map generated names to original names (IR backend only)"
)
var sourceMapNamesPolicy: String? by NullableStringFreezableVar(null)
@GradleOption(
value = DefaultValues.BooleanTrueDefault::class,
gradleInputType = GradleInputTypes.INPUT
@@ -30,6 +30,10 @@ public interface K2JsArgumentConstants {
String SOURCE_MAP_SOURCE_CONTENT_NEVER = "never";
String SOURCE_MAP_SOURCE_CONTENT_INLINING = "inlining";
String SOURCE_MAP_NAMES_POLICY_NO = "no";
String SOURCE_MAP_NAMES_POLICY_SIMPLE_NAMES = "simple-names";
String SOURCE_MAP_NAMES_POLICY_FQ_NAMES = "fully-qualified-names";
String RUNTIME_DIAGNOSTIC_LOG = "log";
String RUNTIME_DIAGNOSTIC_EXCEPTION = "exception";
}