@@ -605,13 +605,14 @@ export function patchResolvedViteConfig(viteConfig, options) {
605605
606606/**
607607 * Mutates `config` to ensure `resolve.mainFields` is set. If unset, it emulates Vite's default fallback.
608+ * @param {string } name
608609 * @param {import('vite').EnvironmentOptions } config
609610 * @param {{ isSsrTargetWebworker?: boolean } } opts
610611 */
611- export function ensureConfigEnvironmentMainFields ( config , opts ) {
612+ export function ensureConfigEnvironmentMainFields ( name , config , opts ) {
612613 config . resolve ??= { } ;
613614 if ( config . resolve . mainFields == null ) {
614- if ( config . consumer === 'client' || opts . isSsrTargetWebworker ) {
615+ if ( config . consumer === 'client' || name === 'client' || opts . isSsrTargetWebworker ) {
615616 config . resolve . mainFields = [ ...defaultClientMainFields ] ;
616617 } else {
617618 config . resolve . mainFields = [ ...defaultServerMainFields ] ;
@@ -622,13 +623,14 @@ export function ensureConfigEnvironmentMainFields(config, opts) {
622623
623624/**
624625 * Mutates `config` to ensure `resolve.conditions` is set. If unset, it emulates Vite's default fallback.
626+ * @param {string } name
625627 * @param {import('vite').EnvironmentOptions } config
626628 * @param {{ isSsrTargetWebworker?: boolean } } opts
627629 */
628- export function ensureConfigEnvironmentConditions ( config , opts ) {
630+ export function ensureConfigEnvironmentConditions ( name , config , opts ) {
629631 config . resolve ??= { } ;
630632 if ( config . resolve . conditions == null ) {
631- if ( config . consumer === 'client' || opts . isSsrTargetWebworker ) {
633+ if ( config . consumer === 'client' || name === 'client' || opts . isSsrTargetWebworker ) {
632634 config . resolve . conditions = [ ...defaultClientConditions ] ;
633635 } else {
634636 config . resolve . conditions = [ ...defaultServerConditions ] ;
0 commit comments