@@ -1183,7 +1183,7 @@ export function compileScript(
11831183 s . prependLeft ( startOffset , `\nlet __temp${ any } , __restore${ any } \n` )
11841184 }
11851185
1186- const destructureElements = [ `expose` ]
1186+ const destructureElements = hasDefineExposeCall ? [ `expose` ] : [ ]
11871187 if ( emitIdentifier ) {
11881188 destructureElements . push (
11891189 emitIdentifier === `emit` ? `emit` : `emit: ${ emitIdentifier } `
@@ -1256,9 +1256,6 @@ export function compileScript(
12561256 runtimeOptions += genRuntimeEmits ( typeDeclaredEmits )
12571257 }
12581258
1259- // <script setup> components are closed by default. If the user did not
1260- // explicitly call `defineExpose`, call expose() with no args.
1261- const exposeCall = hasDefineExposeCall ? `` : ` expose();\n`
12621259 // wrap setup code with function.
12631260 if ( isTS ) {
12641261 // for TS, make sure the exported type is still valid type with
@@ -1273,7 +1270,7 @@ export function compileScript(
12731270 `defineComponent`
12741271 ) } ({${ def } ${ runtimeOptions } \n ${
12751272 hasAwait ? `async ` : ``
1276- } setup(${ args } ) {\n${ exposeCall } `
1273+ } setup(${ args } ) {\n`
12771274 )
12781275 s . appendRight ( endOffset , `})` )
12791276 } else {
@@ -1283,14 +1280,14 @@ export function compileScript(
12831280 s . prependLeft (
12841281 startOffset ,
12851282 `\nexport default /*#__PURE__*/Object.assign(${ DEFAULT_VAR } , {${ runtimeOptions } \n ` +
1286- `${ hasAwait ? `async ` : `` } setup(${ args } ) {\n${ exposeCall } `
1283+ `${ hasAwait ? `async ` : `` } setup(${ args } ) {\n`
12871284 )
12881285 s . appendRight ( endOffset , `})` )
12891286 } else {
12901287 s . prependLeft (
12911288 startOffset ,
12921289 `\nexport default {${ runtimeOptions } \n ` +
1293- `${ hasAwait ? `async ` : `` } setup(${ args } ) {\n${ exposeCall } `
1290+ `${ hasAwait ? `async ` : `` } setup(${ args } ) {\n`
12941291 )
12951292 s . appendRight ( endOffset , `}` )
12961293 }
0 commit comments