(preRunResult?: DepOptimizationResult)
| 313 | } |
| 314 | |
| 315 | async function runOptimizer(preRunResult?: DepOptimizationResult) { |
| 316 | // a successful completion of the optimizeDeps rerun will end up |
| 317 | // creating new bundled version of all current and discovered deps |
| 318 | // in the cache dir and a new metadata info object assigned |
| 319 | // to _metadata. A fullReload is only issued if the previous bundled |
| 320 | // dependencies have changed. |
| 321 | |
| 322 | // if the rerun fails, _metadata remains untouched, current discovered |
| 323 | // deps are cleaned, and a fullReload is issued |
| 324 | |
| 325 | // All deps, previous known and newly discovered are rebundled, |
| 326 | // respect insertion order to keep the metadata file stable |
| 327 | |
| 328 | const isRerun = firstRunCalled |
| 329 | firstRunCalled = true |
| 330 | |
| 331 | // Ensure that rerun is called sequentially |
| 332 | enqueuedRerun = undefined |
| 333 | |
| 334 | // Ensure that a rerun will not be issued for current discovered deps |
| 335 | if (debounceProcessingHandle) clearTimeout(debounceProcessingHandle) |
| 336 | |
| 337 | if (closed) { |
| 338 | currentlyProcessing = false |
| 339 | depOptimizationProcessing.resolve() |
| 340 | resolveEnqueuedProcessingPromises() |
| 341 | return |
| 342 | } |
| 343 | |
| 344 | currentlyProcessing = true |
| 345 | |
| 346 | try { |
| 347 | let processingResult: DepOptimizationResult |
| 348 | if (preRunResult) { |
| 349 | processingResult = preRunResult |
| 350 | } else { |
| 351 | const knownDeps = prepareKnownDeps() |
| 352 | startNextDiscoveredBatch() |
| 353 | |
| 354 | optimizationResult = runOptimizeDeps(environment, knownDeps) |
| 355 | processingResult = await optimizationResult.result |
| 356 | optimizationResult = undefined |
| 357 | } |
| 358 | |
| 359 | if (closed) { |
| 360 | currentlyProcessing = false |
| 361 | processingResult.cancel() |
| 362 | resolveEnqueuedProcessingPromises() |
| 363 | return |
| 364 | } |
| 365 | |
| 366 | const newData = processingResult.metadata |
| 367 | |
| 368 | const needsInteropMismatch = findInteropMismatches( |
| 369 | metadata.discovered, |
| 370 | newData.optimized, |
| 371 | ) |
| 372 |
no test coverage detected