Skip to content

Commit

Permalink
feat(compiler-sfc): improve sfc source map generation
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed May 7, 2020
1 parent e08f6f0 commit 698c8d3
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions packages/compiler-sfc/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,21 @@ function generateSourceMap(
map.setSourceContent(filename, source)
generated.split(splitRE).forEach((line, index) => {
if (!emptyRE.test(line)) {
map.addMapping({
source: filename,
original: {
line: index + 1 + lineOffset,
column: 0
},
generated: {
line: index + 1,
column: 0
}
})
const originalLine = index + 1 + lineOffset
const generatedLine = index + 1
for (let i = 0; i < line.length; i++) {
map.addMapping({
source: filename,
original: {
line: originalLine,
column: i
},
generated: {
line: generatedLine,
column: i
}
})
}
}
})
return JSON.parse(map.toString())
Expand Down

1 comment on commit 698c8d3

@andrew0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yyx990803 Why was this added? This adds a mapping for every single character in the block, resulting in a very large generated sourcemap. I was testing the playground for Vite - the main App.vue in the playground produces a sourcemap with 10 kB of mappings. If I revert this change it goes to 307 bytes.

Please sign in to comment.