fix(compiler-sfc): fix parse-only mode when there is no script setup block

This commit is contained in:
Evan You
2021-07-02 08:24:24 -04:00
parent dd280ddaba
commit 253ca2729d
2 changed files with 17 additions and 2 deletions

View File

@@ -74,4 +74,14 @@ describe('compileScript parseOnly mode', () => {
const { ranges } = compile(`<script setup lang="ts">${src}</script>`)
expect(getRange(src, ranges!.emitsTypeArg!)).toBe(`{ (e: 'x'): void }`)
})
test('no script setup block', () => {
const src = `import { x } from './x'`
const { ranges } = compile(`<script>${src}</script>`)
expect(getRange(src, ranges!.scriptBindings[0])).toBe(`x`)
})
test('no script block', () => {
expect(() => compile(`<style>hello</style>`)).not.toThrow()
})
})