fix(compiler-sfc): automatically infer component name from filename when using script setup (#4997)

close #4993
This commit is contained in:
ygj6
2022-05-10 09:16:28 +08:00
committed by GitHub
parent 7dfe146096
commit 16939241b0
5 changed files with 137 additions and 5 deletions

View File

@@ -1,13 +1,19 @@
import { parse, SFCScriptCompileOptions, compileScript } from '../src'
import {
parse,
SFCScriptCompileOptions,
compileScript,
SFCParseOptions
} from '../src'
import { parse as babelParse } from '@babel/parser'
export const mockId = 'xxxxxxxx'
export function compileSFCScript(
src: string,
options?: Partial<SFCScriptCompileOptions>
options?: Partial<SFCScriptCompileOptions>,
parseOptions?: SFCParseOptions
) {
const { descriptor } = parse(src)
const { descriptor } = parse(src, parseOptions)
return compileScript(descriptor, {
...options,
id: mockId