Didier Villevalois
06/16/2026, 10:08 AMkotlin.js.compilerOptions.sourceMapEmbedSources is not correctly taken in account. I have to directly use -source-map-embed-sources option the freeCompilerArgs. Details in 🧵. (Kotlin 2.4)Didier Villevalois
06/16/2026, 10:13 AMkotlin {
js {
useEsModules()
compilerOptions {
target = "es2015"
freeCompilerArgs.add("-Xes-long-as-bigint")
sourceMapEmbedSources = JsSourceMapEmbedMode.SOURCE_MAP_SOURCE_CONTENT_ALWAYS
}
generateTypeScriptDefinitions()
binaries.library()
}
}
And if I explicitly set the -source-map-embed-sources always, then the sources are embedded but I get a warning telling me the argument is passed multiple times (values being: never, always).
kotlin {
js {
useEsModules()
compilerOptions {
target = "es2015"
freeCompilerArgs.add("-Xes-long-as-bigint")
sourceMapEmbedSources = JsSourceMapEmbedMode.SOURCE_MAP_SOURCE_CONTENT_ALWAYS
freeCompilerArgs.addAll("-source-map-embed-sources", "always")
}
generateTypeScriptDefinitions()
binaries.library()
}
}
This produces the following warnings:
> Task :xyz:compileKotlinJs
w: Argument '-source-map-embed-sources' is passed multiple times: 'never', 'always'. The last value will be used.
> Task :xyz:compileProductionLibraryKotlinJs
w: Argument '-source-map-embed-sources' is passed multiple times: 'never', 'always'. The last value will be used.
It is as if the sourceMapEmbedSources was ignored and the compiler option was incorrectly initialized somewhere.Didier Villevalois
06/16/2026, 10:34 AMsourceMapEmbedSources directly in the sub target the compiler option is correctly initialized.sourceMapEmbedSources is simply ignored whether it is defined in kotlin.js.compilerOptions or kotlin.js.nodeJs.compilerOptions. And using freeCompilerArgs.addAll("-source-map-embed-sources", "always") is the only way to force the source embedding (though it produces the above warnings).
@Artem Kobzar is this a known bug?Edoardo Luppi
06/17/2026, 1:02 PMtasks.withTypeKotlin2JsCompile().configureEach {
compilerOptions {
sourceMap.set(true)
sourceMapEmbedSources.set(JsSourceMapEmbedMode.SOURCE_MAP_SOURCE_CONTENT_ALWAYS)
}
}Artem Kobzar
06/17/2026, 5:00 PMDidier Villevalois
06/18/2026, 9:29 AMDidier Villevalois
06/18/2026, 9:29 AMArtem Kobzar
06/18/2026, 11:37 AMDidier Villevalois
06/18/2026, 12:08 PM