From 2c1067abffdd042b54c708967a4c4c103285cf2f Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Tue, 24 Sep 2024 09:48:26 -0400 Subject: [PATCH] reducing phase detection to "bundling" vs "other" --- packages/vite/src/esbuild-request.ts | 4 ++-- packages/vite/src/esbuild-resolver.ts | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/vite/src/esbuild-request.ts b/packages/vite/src/esbuild-request.ts index 59d63a05a..d05f5c70f 100644 --- a/packages/vite/src/esbuild-request.ts +++ b/packages/vite/src/esbuild-request.ts @@ -11,7 +11,7 @@ type PackageCache = PublicAPI<_PackageCache>; export class EsBuildModuleRequest implements ModuleRequest { static from( packageCache: PackageCache, - phase: 'bundling' | 'scanning', + phase: 'bundling' | 'other', context: PluginBuild, kind: ImportKind, source: string, @@ -41,7 +41,7 @@ export class EsBuildModuleRequest implements ModuleRequest { private constructor( private packageCache: PackageCache, - private phase: 'bundling' | 'scanning', + private phase: 'bundling' | 'other', private context: PluginBuild, private kind: ImportKind, readonly specifier: string, diff --git a/packages/vite/src/esbuild-resolver.ts b/packages/vite/src/esbuild-resolver.ts index fd29d4429..8eab80820 100644 --- a/packages/vite/src/esbuild-resolver.ts +++ b/packages/vite/src/esbuild-resolver.ts @@ -151,17 +151,12 @@ export function esBuildResolver(): EsBuildPlugin { }; } -function detectPhase(build: PluginBuild): 'bundling' | 'scanning' { +function detectPhase(build: PluginBuild): 'bundling' | 'other' { let plugins = (build.initialOptions.plugins ?? []).map(p => p.name); if (plugins.includes('vite:dep-pre-bundle')) { return 'bundling'; - } else if (plugins.includes('vite:dep-scan')) { - return 'scanning'; - } else if (plugins.includes('embroider-esbuild-resolver')) { - // export scanning - return 'scanning'; } else { - throw new Error(`cannot identify what phase vite is in. Saw plugins: ${plugins.join(', ')}`); + throw 'other'; } }