fix(codegen): ensure mapping is added only if node source is available

This commit is contained in:
daiwei 2025-05-06 17:22:20 +08:00
parent 56be3dd4db
commit 5285fb6c22
1 changed files with 4 additions and 2 deletions

View File

@ -188,7 +188,9 @@ function createCodegenContext(
name = content
}
}
addMapping(node.loc.start, name)
if (node.loc.source) {
addMapping(node.loc.start, name)
}
}
if (newlineIndex === NewlineType.Unknown) {
// multiple newlines, full iteration
@ -225,7 +227,7 @@ function createCodegenContext(
context.column = code.length - newlineIndex
}
}
if (node && node.loc !== locStub) {
if (node && node.loc !== locStub && node.loc.source) {
addMapping(node.loc.end)
}
}