Skip to content

Commit 3d6f015

Browse files
committed
fix(compiler-sfc): fix prefixIdentifier default value
1 parent fe00815 commit 3d6f015

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Diff for: packages/compiler-sfc/__tests__/compileScript/importUsageCheck.spec.ts

+16
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,19 @@ test('namespace / dot component usage', () => {
234234
expect(content).toMatch('return { get Foo() { return Foo } }')
235235
assertCode(content)
236236
})
237+
238+
test('check when has explicit parse options', () => {
239+
const { content } = compile(
240+
`
241+
<script setup lang="ts">
242+
import { x } from './x'
243+
</script>
244+
<template>
245+
{{ x }}
246+
</template>
247+
`,
248+
undefined,
249+
{ templateParseOptions: {} },
250+
)
251+
expect(content).toMatch('return { get x() { return x } }')
252+
})

Diff for: packages/compiler-sfc/src/parse.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export function parse(
133133
pad = false,
134134
ignoreEmpty = true,
135135
compiler = CompilerDOM,
136-
templateParseOptions = { prefixIdentifiers: true },
136+
templateParseOptions = {},
137137
} = options
138138

139139
const descriptor: SFCDescriptor = {
@@ -152,6 +152,7 @@ export function parse(
152152
const errors: (CompilerError | SyntaxError)[] = []
153153
const ast = compiler.parse(source, {
154154
parseMode: 'sfc',
155+
prefixIdentifiers: true,
155156
...templateParseOptions,
156157
onError: e => {
157158
errors.push(e)

0 commit comments

Comments
 (0)