fix(compiler-sfc): fix parse-only mode when there is no script setup block
This commit is contained in:
parent
dd280ddaba
commit
253ca2729d
@ -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()
|
||||
})
|
||||
})
|
||||
|
@ -1,5 +1,10 @@
|
||||
import MagicString from 'magic-string'
|
||||
import { BindingMetadata, BindingTypes, UNREF } from '@vue/compiler-core'
|
||||
import {
|
||||
BindingMetadata,
|
||||
BindingTypes,
|
||||
locStub,
|
||||
UNREF
|
||||
} from '@vue/compiler-core'
|
||||
import {
|
||||
ScriptSetupTextRanges,
|
||||
SFCDescriptor,
|
||||
@ -126,7 +131,7 @@ export function compileScript(
|
||||
type: 'script',
|
||||
content: '',
|
||||
attrs: {},
|
||||
loc: null as any
|
||||
loc: locStub
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user