Skip to content

Commit

Permalink
feat: non-blocking scanning of dependencies (#7379)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed Mar 23, 2022
1 parent 0cc743b commit 676f545
Show file tree
Hide file tree
Showing 13 changed files with 736 additions and 635 deletions.
2 changes: 1 addition & 1 deletion packages/playground/cli-module/__tests__/serve.js
Expand Up @@ -78,7 +78,7 @@ exports.serve = async function serve(root, isProd) {
const timeoutError = `server process still alive after 3s`
try {
killProcess(serverProcess)
await resolvedOrTimeout(serverProcess, 3000, timeoutError)
await resolvedOrTimeout(serverProcess, 10000, timeoutError)
} catch (e) {
if (e === timeoutError || (!serverProcess.killed && !isWindows)) {
collectErrorStreams('server', e)
Expand Down
3 changes: 2 additions & 1 deletion packages/vite/src/node/index.ts
Expand Up @@ -40,7 +40,8 @@ export type {
DepOptimizationOptions,
DepOptimizationResult,
DepOptimizationProcessing,
OptimizedDepInfo
OptimizedDepInfo,
OptimizedDeps
} from './optimizer'
export type { Plugin } from './plugin'
export type { PackageCache, PackageData } from './packages'
Expand Down
10 changes: 5 additions & 5 deletions packages/vite/src/node/optimizer/esbuildDepPlugin.ts
Expand Up @@ -37,8 +37,7 @@ const externalTypes = [
export function esbuildDepPlugin(
qualified: Record<string, string>,
exportsData: Record<string, ExportsData>,
config: ResolvedConfig,
ssr?: boolean
config: ResolvedConfig
): Plugin {
// remove optimizable extensions from `externalTypes` list
const allExternalTypes = config.optimizeDeps.extensions
Expand All @@ -48,12 +47,13 @@ export function esbuildDepPlugin(
: externalTypes

// default resolver which prefers ESM
const _resolve = config.createResolver({ asSrc: false })
const _resolve = config.createResolver({ asSrc: false, scan: true })

// cjs resolver that prefers Node
const _resolveRequire = config.createResolver({
asSrc: false,
isRequire: true
isRequire: true,
scan: true
})

const resolve = (
Expand All @@ -72,7 +72,7 @@ export function esbuildDepPlugin(
_importer = importer in qualified ? qualified[importer] : importer
}
const resolver = kind.startsWith('require') ? _resolveRequire : _resolve
return resolver(id, _importer, undefined, ssr)
return resolver(id, _importer, undefined)
}

return {
Expand Down

0 comments on commit 676f545

Please sign in to comment.