fix(compiler-sfc): register exported bindings in normal script when using script setup (#4601)

fix #4600
This commit is contained in:
edison
2021-09-17 05:22:29 +08:00
committed by GitHub
parent cab9541ffd
commit 8055445b68
3 changed files with 22 additions and 5 deletions

View File

@@ -1295,6 +1295,20 @@ describe('SFC analyze <script> bindings', () => {
expect(bindings!.__isScriptSetup).toBe(false)
})
it('recognizes exported vars', () => {
const { bindings } = compile(`
<script>
export const foo = 2
</script>
<script setup>
console.log(foo)
</script>
`)
expect(bindings).toStrictEqual({
foo: BindingTypes.SETUP_CONST
})
})
it('recognizes async setup return', () => {
const { bindings } = compile(`
<script>