feat(sfc): auto restore current instance after await statements in async setup()

This commit is contained in:
Evan You
2021-06-29 09:24:12 -04:00
parent fd7fa6f694
commit 0240e82a38
5 changed files with 106 additions and 11 deletions

View File

@@ -900,6 +900,11 @@ export function compileScript(
}
if (node.type === 'AwaitExpression') {
hasAwait = true
s.prependRight(
node.argument.start! + startOffset,
helper(`withAsyncContext`) + `(`
)
s.appendLeft(node.argument.end! + startOffset, `)`)
}
}
})