How do sourcemaps work? If I create a simple proj...
# javascript
c
How do sourcemaps work? If I create a simple project and run
jsBrowserDevelopmentRun
, I get: •
build/js/packages/example-simple/kotlin/example-simple.js
build/js/packages/example-simple/kotlin/example-simple.js.map
The second one contains:
Copy code
{
	"version": 3,
	"sources": [
		"../../../../../src/jsMain/kotlin/Main.kt",
		"../../../../compileSync/js/main/developmentExecutable/kotlin/src/kotlin/util/Standard.kt"
	],
    // …
The
Main.kt
file refers to my own source code, fine. However, I don't understand that
Standard.kt
file. The
build/compileSync/js/main/developmentExecutable/kotlin
folder does NOT contain a
src/
folder, and there is no
Standard.kt
file anywhere in the
build/
directory. What's going on here?
👍 1
l
In my experience, sourcemaps are broken when producing ECMAScript Modules. I filed this bug report a few months ago. https://youtrack.jetbrains.com/issue/KT-76170/KJS-KMP-sourcemap-source-paths-are-broken-when-building-ECMAScript-modules Does that issue match what you're seeing?
c
I'm using the default configuration
e
It's "normal" as the compiler will process all files (be them sources or from klib metadata) under the compilation and will attempt to include them into the source map file. Obviously it can't link to a real source file.
l
@Edoardo Luppi actually, it seems that the JS build output for each module includes source files for the stdlib and other libraries, as needed (e.g.
kotlin-kotlin-stdlib.mjs
), so I think proper sourcemap linking should be possible. As far as we've been able to figure, there is just a bug that produces broken paths. @Artem Kobzar did acknowledge the issue a couple months ago by marking it as planned so we've just patiently waiting (with broken source maps) in the meantime.
👀 1