File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
packages/vite/src/node/optimizer Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -303,7 +303,7 @@ async function createDepsOptimizer(
303303 // Ensure that a rerun will not be issued for current discovered deps
304304 if ( debounceProcessingHandle ) clearTimeout ( debounceProcessingHandle )
305305
306- if ( closed || Object . keys ( metadata . discovered ) . length === 0 ) {
306+ if ( closed ) {
307307 currentlyProcessing = false
308308 return
309309 }
@@ -580,9 +580,6 @@ async function createDepsOptimizer(
580580 }
581581
582582 function debouncedProcessing ( timeout = debounceMs ) {
583- if ( ! newDepsDiscovered ) {
584- return
585- }
586583 // Debounced rerun, let other missing dependencies be discovered before
587584 // the running next optimizeDeps
588585 enqueuedRerun = undefined
@@ -632,8 +629,10 @@ async function createDepsOptimizer(
632629 `✨ no dependencies found by the scanner or crawling static imports` ,
633630 ) ,
634631 )
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 )
637636 return
638637 }
639638
@@ -684,10 +683,10 @@ async function createDepsOptimizer(
684683 ) ,
685684 )
686685 firstRunCalled = true
687- } else {
688- // queue the first optimizer run
689- debouncedProcessing ( 0 )
690686 }
687+
688+ // queue the first optimizer run, even without deps so the result is cached
689+ debouncedProcessing ( 0 )
691690 }
692691 }
693692
You can’t perform that action at this time.
0 commit comments