fix: preserve location information for `await` wrappers (#18859)

Helps with code coverage tools:
https://github.com/sveltejs/esrap/pull/124
main
Rich Harris 2 days ago committed by GitHub
parent 7fe14a508a
commit 688a4e49b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: preserve location information for `await` wrappers

@ -18,7 +18,8 @@ export function AwaitExpression(node, context) {
// in dev, note which values are read inside a reactive expression, // in dev, note which values are read inside a reactive expression,
// but don't track them // but don't track them
else if (dev && !is_ignored(node, 'await_reactivity_loss')) { else if (dev && !is_ignored(node, 'await_reactivity_loss')) {
return b.call(b.await(b.call('$.track_reactivity_loss', argument))); // don't use b.await here, this way we preserve location information
return b.call({ ...node, argument: b.call('$.track_reactivity_loss', argument) });
} }
return argument === node.argument ? node : { ...node, argument }; return argument === node.argument ? node : { ...node, argument };

Loading…
Cancel
Save