expect(bindings!.__isScriptSetup).toBe(false)
})
+ it('recognizes exported vars', () => {
+ const { bindings } = compile(`
+ <script>
+ export const foo = 2
+ </script>
+ <script setup>
+ console.log(foo)
+ </script>
+ `)
+ expect(bindings).toStrictEqual({
+ foo: BindingTypes.SETUP_CONST
+ })
+ })
+
it('recognizes async setup return', () => {
const { bindings } = compile(`
<script>
const start = node.start! + scriptStartOffset!
const end = node.declaration.start! + scriptStartOffset!
s.overwrite(start, end, `const ${defaultTempVar} = `)
- } else if (node.type === 'ExportNamedDeclaration' && node.specifiers) {
+ } else if (node.type === 'ExportNamedDeclaration') {
const defaultSpecifier = node.specifiers.find(
s => s.exported.type === 'Identifier' && s.exported.name === 'default'
) as ExportSpecifier
)
}
}
+ if (node.declaration) {
+ walkDeclaration(node.declaration, setupBindings, userImportAlias)
+ }
} else if (
(node.type === 'VariableDeclaration' ||
node.type === 'FunctionDeclaration' ||