@@ -605,13 +605,14 @@ export function patchResolvedViteConfig(viteConfig, options) {
605
605
606
606
/**
607
607
* Mutates `config` to ensure `resolve.mainFields` is set. If unset, it emulates Vite's default fallback.
608
+ * @param {string } name
608
609
* @param {import('vite').EnvironmentOptions } config
609
610
* @param {{ isSsrTargetWebworker?: boolean } } opts
610
611
*/
611
- export function ensureConfigEnvironmentMainFields ( config , opts ) {
612
+ export function ensureConfigEnvironmentMainFields ( name , config , opts ) {
612
613
config . resolve ??= { } ;
613
614
if ( config . resolve . mainFields == null ) {
614
- if ( config . consumer === 'client' || opts . isSsrTargetWebworker ) {
615
+ if ( config . consumer === 'client' || name === 'client' || opts . isSsrTargetWebworker ) {
615
616
config . resolve . mainFields = [ ...defaultClientMainFields ] ;
616
617
} else {
617
618
config . resolve . mainFields = [ ...defaultServerMainFields ] ;
@@ -622,13 +623,14 @@ export function ensureConfigEnvironmentMainFields(config, opts) {
622
623
623
624
/**
624
625
* Mutates `config` to ensure `resolve.conditions` is set. If unset, it emulates Vite's default fallback.
626
+ * @param {string } name
625
627
* @param {import('vite').EnvironmentOptions } config
626
628
* @param {{ isSsrTargetWebworker?: boolean } } opts
627
629
*/
628
- export function ensureConfigEnvironmentConditions ( config , opts ) {
630
+ export function ensureConfigEnvironmentConditions ( name , config , opts ) {
629
631
config . resolve ??= { } ;
630
632
if ( config . resolve . conditions == null ) {
631
- if ( config . consumer === 'client' || opts . isSsrTargetWebworker ) {
633
+ if ( config . consumer === 'client' || name === 'client' || opts . isSsrTargetWebworker ) {
632
634
config . resolve . conditions = [ ...defaultClientConditions ] ;
633
635
} else {
634
636
config . resolve . conditions = [ ...defaultServerConditions ] ;
0 commit comments