File tree 1 file changed +8
-9
lines changed
packages/vite/src/node/optimizer
1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -303,7 +303,7 @@ async function createDepsOptimizer(
303
303
// Ensure that a rerun will not be issued for current discovered deps
304
304
if ( debounceProcessingHandle ) clearTimeout ( debounceProcessingHandle )
305
305
306
- if ( closed || Object . keys ( metadata . discovered ) . length === 0 ) {
306
+ if ( closed ) {
307
307
currentlyProcessing = false
308
308
return
309
309
}
@@ -580,9 +580,6 @@ async function createDepsOptimizer(
580
580
}
581
581
582
582
function debouncedProcessing ( timeout = debounceMs ) {
583
- if ( ! newDepsDiscovered ) {
584
- return
585
- }
586
583
// Debounced rerun, let other missing dependencies be discovered before
587
584
// the running next optimizeDeps
588
585
enqueuedRerun = undefined
@@ -632,8 +629,10 @@ async function createDepsOptimizer(
632
629
`✨ no dependencies found by the scanner or crawling static imports` ,
633
630
) ,
634
631
)
635
- result . cancel ( )
636
- firstRunCalled = true
632
+ // We still commit the result so the scanner isn't run on the next cold start
633
+ // for projects without dependencies
634
+ startNextDiscoveredBatch ( )
635
+ runOptimizer ( result )
637
636
return
638
637
}
639
638
@@ -684,10 +683,10 @@ async function createDepsOptimizer(
684
683
) ,
685
684
)
686
685
firstRunCalled = true
687
- } else {
688
- // queue the first optimizer run
689
- debouncedProcessing ( 0 )
690
686
}
687
+
688
+ // queue the first optimizer run, even without deps so the result is cached
689
+ debouncedProcessing ( 0 )
691
690
}
692
691
}
693
692
You can’t perform that action at this time.
0 commit comments