feat(compiler): include names in source map

This commit is contained in:
Evan You
2019-09-26 10:13:46 -04:00
parent 9be19bcd7e
commit 3bba461128
4 changed files with 105 additions and 26 deletions

View File

@@ -106,7 +106,19 @@ function createCodegenContext(
context.code += code
if (context.map) {
if (node) {
const mapping = {
let name
if (
node.type === NodeTypes.EXPRESSION &&
!node.children &&
!node.isStatic
) {
const content = node.content.replace(/^_ctx\./, '')
if (content !== node.content && isSimpleIdentifier(content)) {
name = content
}
}
context.map.addMapping({
name,
source: context.filename,
original: {
line: node.loc.start.line,
@@ -116,8 +128,7 @@ function createCodegenContext(
line: context.line,
column: context.column - 1
}
}
context.map.addMapping(mapping)
})
}
advancePositionWithMutation(context, code)
}