@@ -10,7 +10,7 @@ import {
1010} from '@vue-macros/common'
1111import { walkAST } from 'ast-walker-scope'
1212import { filterMacro , hasPropsOrEmits } from './utils'
13- import type { ExportDefaultDeclaration , Statement } from '@babel/types'
13+ import type { ExportDefaultDeclaration , Program , Statement } from '@babel/types'
1414
1515export function transformDefineOptions ( code :string , id :string ) {
1616if ( ! code . includes ( DEFINE_OPTIONS ) ) return
@@ -70,7 +70,7 @@ export function transformDefineOptions(code: string, id: string) {
7070return getTransformResult ( s , id )
7171}
7272
73- const checkDefaultExport = ( stmts :Statement [ ] ) => {
73+ export const checkDefaultExport = ( stmts :Statement [ ] ) => {
7474const hasDefaultExport = stmts . some (
7575( node ) :node isExportDefaultDeclaration =>
7676node . type === 'ExportDefaultDeclaration'
@@ -81,28 +81,26 @@ const checkDefaultExport = (stmts: Statement[]) => {
8181)
8282}
8383
84- const getIdentifiers = ( stmts :Statement [ ] ) => {
84+ export const getIdentifiers = ( stmts :Statement [ ] ) => {
8585let ids :string [ ] = [ ]
86- walkAST (
87- {
88- type :'Program' ,
89- body :stmts ,
90- directives :[ ] ,
91- sourceType :'module' ,
92- sourceFile :'' ,
86+ const program :Program = {
87+ type :'Program' ,
88+ body :stmts ,
89+ directives :[ ] ,
90+ sourceType :'module' ,
91+ sourceFile :'' ,
92+ }
93+ walkAST ( program , {
94+ enter ( node ) {
95+ if ( node . type === 'BlockStatement' ) {
96+ this . skip ( )
97+ }
9398} ,
94- {
95- enter ( node ) {
96- if ( node . type === 'BlockStatement' ) {
97- this . skip ( )
98- }
99- } ,
100- leave ( node ) {
101- if ( node . type !== 'Program' ) return
102- ids = Object . keys ( this . scope )
103- } ,
104- }
105- )
99+ leave ( node ) {
100+ if ( node . type !== 'Program' ) return
101+ ids = Object . keys ( this . scope )
102+ } ,
103+ } )
106104
107105return ids
108106}