Skip to content

Commit

Permalink
reducing phase detection to "bundling" vs "other"
Browse files Browse the repository at this point in the history
  • Loading branch information
ef4 committed Sep 24, 2024
1 parent 7b5b773 commit 2c1067a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/vite/src/esbuild-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 2 additions & 7 deletions packages/vite/src/esbuild-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}

Expand Down

0 comments on commit 2c1067a

Please sign in to comment.