diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt index 1ba131dba20..656bdb55c13 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt @@ -128,6 +128,13 @@ class K2JSCompilerArguments : CommonCompilerArguments() { @Argument(value = "-Xir-only", description = "Disables pre-IR backend") var irOnly: Boolean by FreezableVar(false) + @Argument( + value = "-Xir-module-name", + valueDescription = "", + description = "Specify a compilation module name for IR backend" + ) + var irModuleName: String? by NullableStringFreezableVar(null) + @Argument( value = "-Xinclude", valueDescription = "", diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt index c8428c35525..101c1917d4d 100644 --- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt +++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt @@ -149,7 +149,10 @@ class K2JsIrCompiler : CLICompiler() { val outputFile = File(outputFilePath) - configurationJs.put(CommonConfigurationKeys.MODULE_NAME, FileUtil.getNameWithoutExtension(outputFile)) + configurationJs.put( + CommonConfigurationKeys.MODULE_NAME, + arguments.irModuleName ?: FileUtil.getNameWithoutExtension(outputFile) + ) // TODO: in this method at least 3 different compiler configurations are used (original, env.configuration, jsConfig.configuration) // Such situation seems a bit buggy... diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index f4ea73afd5b..c8a449397a5 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -9,6 +9,7 @@ where advanced options include: -Xir-dce-driven Perform a more experimental faster dead code elimination -Xir-dce-print-reachability-info Print declarations' reachability info to stdout during performing DCE + -Xir-module-name= Specify a compilation module name for IR backend -Xir-only Disables pre-IR backend -Xir-produce-js Generates JS file using IR backend. Also disables pre-IR backend -Xir-produce-klib-dir Generate unpacked KLIB into parent directory of output JS file.