fix(compiler-sfc): fix <script> and <script setup> co-usage ordering edge case (#4419)

Fix: #4395
Fix: #4376
This commit is contained in:
klwf
2021-08-24 07:02:54 +08:00
committed by GitHub
parent a46b0a9a96
commit 98263821f8
3 changed files with 60 additions and 9 deletions

View File

@@ -202,6 +202,24 @@ defineExpose({ foo: 123 })
`)
assertCode(content)
})
// #4395
test('script setup first, lang="ts", script block content export default', () => {
const { content } = compile(`
<script setup lang="ts">
import { x } from './x'
x()
</script>
<script lang="ts">
export default {
name: "test"
}
</script>
`)
// ensure __default__ is declared before used
expect(content).toMatch(/const __default__[\S\s]*\.\.\.__default__/m)
assertCode(content)
})
})
describe('imports', () => {