@@ -136,13 +136,13 @@ function vueJsxPlugin(options: Options = {}): Plugin {
136
136
}
137
137
138
138
// check for hmr injection
139
- const declaredComponents : { name : string } [ ] = [ ]
139
+ const declaredComponents : string [ ] = [ ]
140
140
const hotComponents : HotComponent [ ] = [ ]
141
141
let hasDefault = false
142
142
143
143
for ( const node of result . ast ! . program . body ) {
144
144
if ( node . type === 'VariableDeclaration' ) {
145
- const names = parseComponentDecls ( node , code )
145
+ const names = parseComponentDecls ( node )
146
146
if ( names . length ) {
147
147
declaredComponents . push ( ...names )
148
148
}
@@ -154,13 +154,11 @@ function vueJsxPlugin(options: Options = {}): Plugin {
154
154
node . declaration . type === 'VariableDeclaration'
155
155
) {
156
156
hotComponents . push (
157
- ...parseComponentDecls ( node . declaration , code ) . map (
158
- ( { name } ) => ( {
159
- local : name ,
160
- exported : name ,
161
- id : getHash ( id + name ) ,
162
- } ) ,
163
- ) ,
157
+ ...parseComponentDecls ( node . declaration ) . map ( ( name ) => ( {
158
+ local : name ,
159
+ exported : name ,
160
+ id : getHash ( id + name ) ,
161
+ } ) ) ,
164
162
)
165
163
} else if ( node . specifiers . length ) {
166
164
for ( const spec of node . specifiers ) {
@@ -169,7 +167,7 @@ function vueJsxPlugin(options: Options = {}): Plugin {
169
167
spec . exported . type === 'Identifier'
170
168
) {
171
169
const matched = declaredComponents . find (
172
- ( { name } ) => name === spec . local . name ,
170
+ ( name ) => name === spec . local . name ,
173
171
)
174
172
if ( matched ) {
175
173
hotComponents . push ( {
@@ -186,12 +184,10 @@ function vueJsxPlugin(options: Options = {}): Plugin {
186
184
if ( node . type === 'ExportDefaultDeclaration' ) {
187
185
if ( node . declaration . type === 'Identifier' ) {
188
186
const _name = node . declaration . name
189
- const matched = declaredComponents . find (
190
- ( { name } ) => name === _name ,
191
- )
187
+ const matched = declaredComponents . find ( ( name ) => name === _name )
192
188
if ( matched ) {
193
189
hotComponents . push ( {
194
- local : node . declaration . name ,
190
+ local : _name ,
195
191
exported : 'default' ,
196
192
id : getHash ( id + 'default' ) ,
197
193
} )
@@ -255,13 +251,11 @@ function vueJsxPlugin(options: Options = {}): Plugin {
255
251
}
256
252
}
257
253
258
- function parseComponentDecls ( node : types . VariableDeclaration , source : string ) {
254
+ function parseComponentDecls ( node : types . VariableDeclaration ) {
259
255
const names = [ ]
260
256
for ( const decl of node . declarations ) {
261
257
if ( decl . id . type === 'Identifier' && isDefineComponentCall ( decl . init ) ) {
262
- names . push ( {
263
- name : decl . id . name ,
264
- } )
258
+ names . push ( decl . id . name )
265
259
}
266
260
}
267
261
return names
0 commit comments