Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitad75c56

Browse files
authored
fix: resolve.conditions in ResolvedConfig wasdefaultServerConditions (#19174)
1 parent282496d commitad75c56

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

‎packages/vite/src/node/__tests__/config.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,3 +481,35 @@ test('config compat 2', async () => {
481481
]
482482
`)
483483
})
484+
485+
test('config compat 3',async()=>{
486+
constconfig=awaitresolveConfig({},'serve')
487+
expect(config.resolve.conditions).toMatchInlineSnapshot(`
488+
[
489+
"module",
490+
"browser",
491+
"development|production",
492+
]
493+
`)
494+
expect(config.environments.client.resolve.conditions).toMatchInlineSnapshot(`
495+
[
496+
"module",
497+
"browser",
498+
"development|production",
499+
]
500+
`)
501+
expect(config.ssr.resolve?.conditions).toMatchInlineSnapshot(`
502+
[
503+
"module",
504+
"node",
505+
"development|production",
506+
]
507+
`)
508+
expect(config.environments.ssr.resolve?.conditions).toMatchInlineSnapshot(`
509+
[
510+
"module",
511+
"node",
512+
"development|production",
513+
]
514+
`)
515+
})

‎packages/vite/src/node/config.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ function resolveEnvironmentResolveOptions(
867867
alias:Alias[],
868868
preserveSymlinks:boolean,
869869
logger:Logger,
870+
/** undefined when resolving the top-level resolve options */
870871
consumer:'client'|'server'|undefined,
871872
// Backward compatibility
872873
isSsrTargetWebworkerEnvironment?:boolean,
@@ -875,11 +876,15 @@ function resolveEnvironmentResolveOptions(
875876
{
876877
...configDefaults.resolve,
877878
mainFields:
878-
consumer==='client'||isSsrTargetWebworkerEnvironment
879+
consumer===undefined||
880+
consumer==='client'||
881+
isSsrTargetWebworkerEnvironment
879882
?DEFAULT_CLIENT_MAIN_FIELDS
880883
:DEFAULT_SERVER_MAIN_FIELDS,
881884
conditions:
882-
consumer==='client'||isSsrTargetWebworkerEnvironment
885+
consumer===undefined||
886+
consumer==='client'||
887+
isSsrTargetWebworkerEnvironment
883888
?DEFAULT_CLIENT_CONDITIONS
884889
:DEFAULT_SERVER_CONDITIONS.filter((c)=>c!=='browser'),
885890
enableBuiltinNoExternalCheck:!!isSsrTargetWebworkerEnvironment,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp