-
-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
bugSomething isn't workingSomething isn't working
Description
In this function the sourcemap positions are always returned as position 0. This breaks mapping back to the original source and coverage reporting.
transformWithMap(code: string, _id: string) { |
transformWithMap(code: string, _id: string) {
const generated = this.transform(code, _id)
if (generated) {
const ms = new MagicString(code, { filename: _id })
ms.overwrite(0, code.length, generated)
return {
code: ms.toString(),
map: ms.generateMap({ hires: true }),
}
}
}
A simpler reproducible example (effectively the same code):
import MagicString from 'magic-string';
const code = `const answer = 42;\n\nconsole.log("The answer is", answer);`;
const generated = code;
const ms = new MagicString(code, { filename: 'test.ts' })
ms.overwrite(0, code.length, generated)
console.log(ms.generateMap({ hires: true }));
Returns:
SourceMap {
version: 3,
file: undefined,
sources: [ '' ],
sourcesContent: undefined,
names: [],
mappings: 'AAAA;AAAA'
}
AAAA
is position 0 for both statements.
KeJunMao, foxschatcopilot3 and NoahCardoza
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working