File tree 3 files changed +22
-12
lines changed 3 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -300,11 +300,16 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
300
300
str ( ) . prepend ( importsString )
301
301
str ( ) . overwrite ( expStart , endIndex , exp )
302
302
imports . forEach ( ( url ) => importedUrls . add ( url . replace ( base , '/' ) ) )
303
- server . _globImporters [ importerModule . file ! ] = {
304
- module : importerModule ,
303
+ if ( ! ( importerModule . file ! in server . _globImporters ) ) {
304
+ server . _globImporters [ importerModule . file ! ] = {
305
+ module : importerModule ,
306
+ importGlobs : [ ]
307
+ }
308
+ }
309
+ server . _globImporters [ importerModule . file ! ] . importGlobs . push ( {
305
310
base,
306
311
pattern
307
- }
312
+ } )
308
313
}
309
314
continue
310
315
}
Original file line number Diff line number Diff line change @@ -177,13 +177,16 @@ export async function handleFileAddUnlink(
177
177
delete server . _globImporters [ file ]
178
178
} else {
179
179
for ( const i in server . _globImporters ) {
180
- const { module, base, pattern } = server . _globImporters [ i ]
181
- const relative = path . relative ( base , file )
182
- if ( match ( relative , pattern ) ) {
183
- modules . push ( module )
184
- // We use `onFileChange` to invalidate `module.file` so that subsequent `ssrLoadModule()`
185
- // calls get fresh glob import results with(out) the newly added(/removed) `file`.
186
- server . moduleGraph . onFileChange ( module . file ! )
180
+ const { module, importGlobs } = server . _globImporters [ i ]
181
+ for ( const { base, pattern } of importGlobs ) {
182
+ const relative = path . relative ( base , file )
183
+ if ( match ( relative , pattern ) ) {
184
+ modules . push ( module )
185
+ // We use `onFileChange` to invalidate `module.file` so that subsequent `ssrLoadModule()`
186
+ // calls get fresh glob import results with(out) the newly added(/removed) `file`.
187
+ server . moduleGraph . onFileChange ( module . file ! )
188
+ break
189
+ }
187
190
}
188
191
}
189
192
}
Original file line number Diff line number Diff line change @@ -273,9 +273,11 @@ export interface ViteDevServer {
273
273
_globImporters : Record <
274
274
string ,
275
275
{
276
- base : string
277
- pattern : string
278
276
module : ModuleNode
277
+ importGlobs : {
278
+ base : string
279
+ pattern : string
280
+ } [ ]
279
281
}
280
282
>
281
283
/**
You can’t perform that action at this time.
0 commit comments