fix: browser field should not be included by default for consumer: 'server' (#18575)

This commit is contained in:
翠 / green 2024-11-05 19:09:08 +09:00 committed by GitHub
parent 7523a9fa41
commit 87b2347a13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -754,6 +754,12 @@ function resolveEnvironmentResolveOptions(
// Backward compatibility
isSsrTargetWebworkerEnvironment?: boolean,
): ResolvedAllResolveOptions {
let mainFields = resolve?.mainFields
mainFields ??=
consumer === 'client' || isSsrTargetWebworkerEnvironment
? DEFAULT_MAIN_FIELDS
: DEFAULT_MAIN_FIELDS.filter((f) => f !== 'browser')
let conditions = resolve?.conditions
conditions ??=
consumer === 'client' || isSsrTargetWebworkerEnvironment
@ -761,7 +767,7 @@ function resolveEnvironmentResolveOptions(
: DEFAULT_CONDITIONS.filter((c) => c !== 'browser')
const resolvedResolve: ResolvedAllResolveOptions = {
mainFields: resolve?.mainFields ?? DEFAULT_MAIN_FIELDS,
mainFields,
conditions,
externalConditions:
resolve?.externalConditions ?? DEFAULT_EXTERNAL_CONDITIONS,