Skip to content

Commit

Permalink
fix(compiler-sfc): fix defineExpose() codegen regression from #7949
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Mar 29, 2023
1 parent ffe679c commit a94072d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ exports[`SFC compile <script setup> > defineExpose() 1`] = `
"export default {
setup(__props, { expose: __expose }) {

expose({ foo: 123 })
__expose({ foo: 123 })

return { }
}
Expand Down Expand Up @@ -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 () => {}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-sfc/__tests__/compileScript.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-sfc/src/compileScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@ export function compileScript(
s.overwrite(
callee.start! + startOffset,
callee.end! + startOffset,
'expose'
'__expose'
)
}
}
Expand Down

0 comments on commit a94072d

Please sign in to comment.