(
id: string,
resolved: string,
)
| 554 | } |
| 555 | |
| 556 | function registerMissingImport( |
| 557 | id: string, |
| 558 | resolved: string, |
| 559 | ): OptimizedDepInfo { |
| 560 | const optimized = metadata.optimized[id] |
| 561 | if (optimized) { |
| 562 | return optimized |
| 563 | } |
| 564 | const chunk = metadata.chunks[id] |
| 565 | if (chunk) { |
| 566 | return chunk |
| 567 | } |
| 568 | let missing = metadata.discovered[id] |
| 569 | if (missing) { |
| 570 | // We are already discover this dependency |
| 571 | // It will be processed in the next rerun call |
| 572 | return missing |
| 573 | } |
| 574 | |
| 575 | missing = addMissingDep(id, resolved) |
| 576 | |
| 577 | // Until the first optimize run is called, avoid triggering processing |
| 578 | // We'll wait until the user codebase is eagerly processed by Vite so |
| 579 | // we can get a list of every missing dependency before giving to the |
| 580 | // browser a dependency that may be outdated, thus avoiding full page reloads |
| 581 | |
| 582 | if (!waitingForCrawlEnd) { |
| 583 | // Debounced rerun, let other missing dependencies be discovered before |
| 584 | // the running next optimizeDeps |
| 585 | debouncedProcessing() |
| 586 | } |
| 587 | |
| 588 | // Return the path for the optimized bundle, this path is known before |
| 589 | // esbuild is run to generate the pre-bundle |
| 590 | return missing |
| 591 | } |
| 592 | |
| 593 | function addMissingDep(id: string, resolved: string) { |
| 594 | newDepsDiscovered = true |
nothing calls this directly
no test coverage detected