feat(compiler-sfc): improve sfc source map generation

This commit is contained in:
Evan You 2020-05-06 23:46:33 -04:00
parent e08f6f0ede
commit 698c8d35d5

View File

@ -255,18 +255,22 @@ function generateSourceMap(
map.setSourceContent(filename, source) map.setSourceContent(filename, source)
generated.split(splitRE).forEach((line, index) => { generated.split(splitRE).forEach((line, index) => {
if (!emptyRE.test(line)) { if (!emptyRE.test(line)) {
const originalLine = index + 1 + lineOffset
const generatedLine = index + 1
for (let i = 0; i < line.length; i++) {
map.addMapping({ map.addMapping({
source: filename, source: filename,
original: { original: {
line: index + 1 + lineOffset, line: originalLine,
column: 0 column: i
}, },
generated: { generated: {
line: index + 1, line: generatedLine,
column: 0 column: i
} }
}) })
} }
}
}) })
return JSON.parse(map.toString()) return JSON.parse(map.toString())
} }