@@ -400,46 +400,29 @@ async function fetchUpdate({ path, acceptedPath, timestamp }: Update) {
400
400
const moduleMap = new Map < string , ModuleNamespace > ( )
401
401
const isSelfUpdate = path === acceptedPath
402
402
403
- // make sure we only import each dep once
404
- const modulesToUpdate = new Set < string > ( )
405
- if ( isSelfUpdate ) {
406
- // self update - only update self
407
- modulesToUpdate . add ( path )
408
- } else {
409
- // dep update
410
- for ( const { deps } of mod . callbacks ) {
411
- deps . forEach ( ( dep ) => {
412
- if ( acceptedPath === dep ) {
413
- modulesToUpdate . add ( dep )
414
- }
415
- } )
416
- }
417
- }
418
-
419
403
// determine the qualified callbacks before we re-import the modules
420
- const qualifiedCallbacks = mod . callbacks . filter ( ( { deps } ) => {
421
- return deps . some ( ( dep ) => modulesToUpdate . has ( dep ) )
422
- } )
423
-
424
- await Promise . all (
425
- Array . from ( modulesToUpdate ) . map ( async ( dep ) => {
426
- const disposer = disposeMap . get ( dep )
427
- if ( disposer ) await disposer ( dataMap . get ( dep ) )
428
- const [ path , query ] = dep . split ( `?` )
429
- try {
430
- const newMod : ModuleNamespace = await import (
431
- /* @vite -ignore */
432
- base +
433
- path . slice ( 1 ) +
434
- `?import&t=${ timestamp } ${ query ? `&${ query } ` : '' } `
435
- )
436
- moduleMap . set ( dep , newMod )
437
- } catch ( e ) {
438
- warnFailedFetch ( e , dep )
439
- }
440
- } )
404
+ const qualifiedCallbacks = mod . callbacks . filter ( ( { deps } ) =>
405
+ deps . includes ( acceptedPath )
441
406
)
442
407
408
+ if ( isSelfUpdate || qualifiedCallbacks . length > 0 ) {
409
+ const dep = acceptedPath
410
+ const disposer = disposeMap . get ( dep )
411
+ if ( disposer ) await disposer ( dataMap . get ( dep ) )
412
+ const [ path , query ] = dep . split ( `?` )
413
+ try {
414
+ const newMod : ModuleNamespace = await import (
415
+ /* @vite -ignore */
416
+ base +
417
+ path . slice ( 1 ) +
418
+ `?import&t=${ timestamp } ${ query ? `&${ query } ` : '' } `
419
+ )
420
+ moduleMap . set ( dep , newMod )
421
+ } catch ( e ) {
422
+ warnFailedFetch ( e , dep )
423
+ }
424
+ }
425
+
443
426
return ( ) => {
444
427
for ( const { deps, fn } of qualifiedCallbacks ) {
445
428
fn ( deps . map ( ( dep ) => moduleMap . get ( dep ) ) )
0 commit comments