@@ -239,6 +239,7 @@ export function compileScript(
239
239
const helperImports : Set < string > = new Set ( )
240
240
const userImports : Record < string , ImportBinding > = Object . create ( null )
241
241
const userImportAlias : Record < string , string > = Object . create ( null )
242
+ const scriptBindings : Record < string , BindingTypes > = Object . create ( null )
242
243
const setupBindings : Record < string , BindingTypes > = Object . create ( null )
243
244
244
245
let defaultExport : Node | undefined
@@ -739,15 +740,15 @@ export function compileScript(
739
740
}
740
741
}
741
742
if ( node . declaration ) {
742
- walkDeclaration ( node . declaration , setupBindings , userImportAlias )
743
+ walkDeclaration ( node . declaration , scriptBindings , userImportAlias )
743
744
}
744
745
} else if (
745
746
( node . type === 'VariableDeclaration' ||
746
747
node . type === 'FunctionDeclaration' ||
747
748
node . type === 'ClassDeclaration' ) &&
748
749
! node . declare
749
750
) {
750
- walkDeclaration ( node , setupBindings , userImportAlias )
751
+ walkDeclaration ( node , scriptBindings , userImportAlias )
751
752
}
752
753
}
753
754
@@ -1070,6 +1071,9 @@ export function compileScript(
1070
1071
? BindingTypes . SETUP_CONST
1071
1072
: BindingTypes . SETUP_MAYBE_REF
1072
1073
}
1074
+ for ( const key in scriptBindings ) {
1075
+ bindingMetadata [ key ] = scriptBindings [ key ]
1076
+ }
1073
1077
for ( const key in setupBindings ) {
1074
1078
bindingMetadata [ key ] = setupBindings [ key ]
1075
1079
}
@@ -1198,8 +1202,11 @@ export function compileScript(
1198
1202
returned = `() => {}`
1199
1203
}
1200
1204
} else {
1201
- // return bindings from setup
1202
- const allBindings : Record < string , any > = { ...setupBindings }
1205
+ // return bindings from script and script setup
1206
+ const allBindings : Record < string , any > = {
1207
+ ...scriptBindings ,
1208
+ ...setupBindings
1209
+ }
1203
1210
for ( const key in userImports ) {
1204
1211
if ( ! userImports [ key ] . isType && userImports [ key ] . isUsedInTemplate ) {
1205
1212
allBindings [ key ] = true
0 commit comments