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,17 +255,21 @@ 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)) {
map.addMapping({ const originalLine = index + 1 + lineOffset
source: filename, const generatedLine = index + 1
original: { for (let i = 0; i < line.length; i++) {
line: index + 1 + lineOffset, map.addMapping({
column: 0 source: filename,
}, original: {
generated: { line: originalLine,
line: index + 1, column: i
column: 0 },
} generated: {
}) line: generatedLine,
column: i
}
})
}
} }
}) })
return JSON.parse(map.toString()) return JSON.parse(map.toString())