feat(compiler): include names in source map
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import { NodeTransform } from '../transform'
|
||||
import { NodeTypes, createExpression } from '../ast'
|
||||
|
||||
// prase inline CSS strings for static style attributes into an object
|
||||
// Parse inline CSS strings for static style attributes into an object.
|
||||
// This is a NodeTransform since it works on the static `style` attribute and
|
||||
// converts it into a dynamic equivalent:
|
||||
// style="color: red" -> :style='{ "color": "red" }'
|
||||
// It is then processed by `transformElement` and included in the generated
|
||||
// props.
|
||||
export const transformStyle: NodeTransform = (node, context) => {
|
||||
if (node.type === NodeTypes.ELEMENT) {
|
||||
node.props.forEach((p, i) => {
|
||||
|
||||
Reference in New Issue
Block a user