Skip to content

Commit 698c8d3

Browse files
committed
feat(compiler-sfc): improve sfc source map generation
1 parent e08f6f0 commit 698c8d3

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

packages/compiler-sfc/src/parse.ts

+15-11
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,21 @@ function generateSourceMap(
255255
map.setSourceContent(filename, source)
256256
generated.split(splitRE).forEach((line, index) => {
257257
if (!emptyRE.test(line)) {
258-
map.addMapping({
259-
source: filename,
260-
original: {
261-
line: index + 1 + lineOffset,
262-
column: 0
263-
},
264-
generated: {
265-
line: index + 1,
266-
column: 0
267-
}
268-
})
258+
const originalLine = index + 1 + lineOffset
259+
const generatedLine = index + 1
260+
for (let i = 0; i < line.length; i++) {
261+
map.addMapping({
262+
source: filename,
263+
original: {
264+
line: originalLine,
265+
column: i
266+
},
267+
generated: {
268+
line: generatedLine,
269+
column: i
270+
}
271+
})
272+
}
269273
}
270274
})
271275
return JSON.parse(map.toString())

0 commit comments

Comments
 (0)