-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Open
Description
Describe the bug
Using Svelte 5.37.3, while trying to consume the sourcemaps generated by the svelte compiler, I constantly get errors popping out, similar to Error parsing mappings: the mappings contained a negative line, column, source index, or name index
.
Let's say I have a very simple svelte file:
<script lang="ts">
const message = "hello";
</script>
<p>
{message}
</p>
Then compiling the component, and consuming the sourcemaps:
const filename = "path/to/the/svelte/component";
// Loading source
const source = fs.readFileSync(filename, {
encoding: "utf-8",
});
// Compiling works fine
const compileResult = compile(source, {
filename: filename,
});
// Consuming the sourcemaps does not work
// Here using source-map library (https://github.com/mozilla/source-map).
await SourceMapConsumer.with(
compileResult.js.map,
null,
(consumer) => {
consumer.eachMapping(function (m) {
// ...
});
},
);
Consuming the sourcemaps leads to the error specified above.
It's happening whatever sourcemaps-consumer library I am using.
The component is so simple that I wonder if I am not missing something along the lines here. I tried various CompileOptions settings, without much success.
Is it indeed a bug ?
Thanks in advance for any hints.
Reproduction
See reproduction steps provided above.
Logs
System Info
System:
OS: macOS 15.6
CPU: (8) arm64 Apple M3
Memory: 475.55 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.18.0 - ~/.n/bin/node
npm: 10.9.3 - ~/.n/bin/npm
pnpm: 10.14.0 - ~/.n/bin/pnpm
Browsers:
Chrome: 139.0.7258.67
Safari: 18.6
npmPackages:
svelte: ^5.37.3 => 5.37.3
Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels