Skip to content

Commit c9e086d

Browse files
authored
refactor: remove isBuild check from preAliasPlugin (#19587)
1 parent 42ff9b3 commit c9e086d

File tree

2 files changed

+0
-25
lines changed

2 files changed

+0
-25
lines changed

packages/vite/src/node/external.ts

-18
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,6 @@ export function shouldExternalize(
3232
return isExternal(id, importer)
3333
}
3434

35-
const isConfiguredAsExternalCache = new WeakMap<
36-
Environment,
37-
(id: string, importer?: string) => boolean
38-
>()
39-
40-
export function isConfiguredAsExternal(
41-
environment: Environment,
42-
id: string,
43-
importer?: string,
44-
): boolean {
45-
let isExternal = isConfiguredAsExternalCache.get(environment)
46-
if (!isExternal) {
47-
isExternal = createIsConfiguredAsExternal(environment)
48-
isConfiguredAsExternalCache.set(environment, isExternal)
49-
}
50-
return isExternal(id, importer)
51-
}
52-
5335
export function createIsConfiguredAsExternal(
5436
environment: PartialEnvironment,
5537
): (id: string, importer?: string) => boolean {

packages/vite/src/node/plugins/preAlias.ts

-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import type {
77
ResolvedConfig,
88
} from '..'
99
import type { Plugin } from '../plugin'
10-
import { isConfiguredAsExternal } from '../external'
1110
import {
1211
bareImportRE,
1312
isInNodeModules,
@@ -22,7 +21,6 @@ import { tryOptimizedResolve } from './resolve'
2221
*/
2322
export function preAliasPlugin(config: ResolvedConfig): Plugin {
2423
const findPatterns = getAliasPatterns(config.resolve.alias)
25-
const isBuild = config.command === 'build'
2624
return {
2725
name: 'vite:pre-alias',
2826
async resolveId(id, importer, options) {
@@ -65,11 +63,6 @@ export function preAliasPlugin(config: ResolvedConfig): Plugin {
6563
(isInNodeModules(resolvedId) ||
6664
optimizeDeps.include?.includes(id)) &&
6765
isOptimizable(resolvedId, optimizeDeps) &&
68-
!(
69-
isBuild &&
70-
ssr &&
71-
isConfiguredAsExternal(environment, id, importer)
72-
) &&
7366
(!ssr || optimizeAliasReplacementForSSR(resolvedId, optimizeDeps))
7467
) {
7568
// aliased dep has not yet been optimized

0 commit comments

Comments
 (0)