File tree 2 files changed +39
-2
lines changed
2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -481,3 +481,35 @@ test('config compat 2', async () => {
481
481
]
482
482
` )
483
483
} )
484
+
485
+ test ( 'config compat 3' , async ( ) => {
486
+ const config = await resolveConfig ( { } , '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
+ } )
Original file line number Diff line number Diff line change @@ -867,6 +867,7 @@ function resolveEnvironmentResolveOptions(
867
867
alias : Alias [ ] ,
868
868
preserveSymlinks : boolean ,
869
869
logger : Logger ,
870
+ /** undefined when resolving the top-level resolve options */
870
871
consumer : 'client' | 'server' | undefined ,
871
872
// Backward compatibility
872
873
isSsrTargetWebworkerEnvironment ?: boolean ,
@@ -875,11 +876,15 @@ function resolveEnvironmentResolveOptions(
875
876
{
876
877
...configDefaults . resolve ,
877
878
mainFields :
878
- consumer === 'client' || isSsrTargetWebworkerEnvironment
879
+ consumer === undefined ||
880
+ consumer === 'client' ||
881
+ isSsrTargetWebworkerEnvironment
879
882
? DEFAULT_CLIENT_MAIN_FIELDS
880
883
: DEFAULT_SERVER_MAIN_FIELDS ,
881
884
conditions :
882
- consumer === 'client' || isSsrTargetWebworkerEnvironment
885
+ consumer === undefined ||
886
+ consumer === 'client' ||
887
+ isSsrTargetWebworkerEnvironment
883
888
? DEFAULT_CLIENT_CONDITIONS
884
889
: DEFAULT_SERVER_CONDITIONS . filter ( ( c ) => c !== 'browser' ) ,
885
890
enableBuiltinNoExternalCheck : ! ! isSsrTargetWebworkerEnvironment ,
You can’t perform that action at this time.
0 commit comments