fix(compiler-sfc): fix defineExpose() codegen regression from #7949

This commit is contained in:
Evan You 2023-03-29 20:31:25 +08:00
parent ffe679c490
commit a94072dd2c
3 changed files with 4 additions and 4 deletions

View File

@ -645,7 +645,7 @@ exports[`SFC compile <script setup> > defineExpose() 1`] = `
"export default {
setup(__props, { expose: __expose }) {
expose({ foo: 123 })
__expose({ foo: 123 })
return { }
}
@ -1319,7 +1319,7 @@ exports[`SFC compile <script setup> > inlineTemplate mode > with defineExpose()
setup(__props, { expose: __expose }) {
const count = ref(0)
expose({ count })
__expose({ count })
return () => {}
}

View File

@ -276,7 +276,7 @@ defineExpose({ foo: 123 })
// should generate correct setup signature
expect(content).toMatch(`setup(__props, { expose: __expose }) {`)
// should replace callee
expect(content).toMatch(/\bexpose\(\{ foo: 123 \}\)/)
expect(content).toMatch(/\b__expose\(\{ foo: 123 \}\)/)
})
test('<script> after <script setup> the script content not end with `\\n`', () => {

View File

@ -1252,7 +1252,7 @@ export function compileScript(
s.overwrite(
callee.start! + startOffset,
callee.end! + startOffset,
'expose'
'__expose'
)
}
}