Skip to content

Commit

Permalink
chore: serialize esbuild scan calls
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Jul 2, 2022
1 parent 387b18e commit 80e7a4d
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions packages/vite/src/node/optimizer/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import type { PluginContainer } from '../server/pluginContainer'
import { createPluginContainer } from '../server/pluginContainer'
import { transformGlobImport } from '../plugins/importMetaGlob'
import { enqueueEsbuildTask } from './index'

const debug = createDebugger('vite:deps')

Expand Down Expand Up @@ -98,18 +99,24 @@ export async function scanImports(config: ResolvedConfig): Promise<{
config.optimizeDeps?.esbuildOptions ?? {}

await Promise.all(
entries.map((entry) =>
build({
absWorkingDir: process.cwd(),
write: false,
entryPoints: [entry],
bundle: true,
format: 'esm',
logLevel: 'error',
plugins: [...plugins, plugin],
...esbuildOptions
entries.map((entry) => {
return new Promise((resolve) => {
return enqueueEsbuildTask(() => {
const result = build({
absWorkingDir: process.cwd(),
write: false,
entryPoints: [entry],
bundle: true,
format: 'esm',
logLevel: 'error',
plugins: [...plugins, plugin],
...esbuildOptions
})
resolve(result)
return result
})
})
)
})
)

debug(`Scan completed in ${(performance.now() - start).toFixed(2)}ms:`, deps)
Expand Down

0 comments on commit 80e7a4d

Please sign in to comment.