From ec0dff3e3ecfdfc0ed57d15a9dc2ef15c6bdfa3e Mon Sep 17 00:00:00 2001 From: Rick nagual Date: Thu, 6 Apr 2023 23:42:51 +0800 Subject: [PATCH] fix(react-native): add aliasFields to handle replaced files in browser env (#16106) (cherry picked from commit 7a4adf58939ee6dec301381a3f5fea19a2a81918) --- packages/expo/plugins/metro-resolver.ts | 1 + packages/react-native/plugins/metro-resolver.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/expo/plugins/metro-resolver.ts b/packages/expo/plugins/metro-resolver.ts index 4b1fab107d06c..74153d2404f29 100644 --- a/packages/expo/plugins/metro-resolver.ts +++ b/packages/expo/plugins/metro-resolver.ts @@ -205,6 +205,7 @@ function getPnpmResolver(extensions: string[]) { modules: [join(workspaceRoot, 'node_modules'), 'node_modules'], conditionNames: ['native', 'browser', 'require', 'default'], mainFields: ['react-native', 'browser', 'main'], + aliasFields: ['browser'], }); } return resolver; diff --git a/packages/react-native/plugins/metro-resolver.ts b/packages/react-native/plugins/metro-resolver.ts index 4b1fab107d06c..74153d2404f29 100644 --- a/packages/react-native/plugins/metro-resolver.ts +++ b/packages/react-native/plugins/metro-resolver.ts @@ -205,6 +205,7 @@ function getPnpmResolver(extensions: string[]) { modules: [join(workspaceRoot, 'node_modules'), 'node_modules'], conditionNames: ['native', 'browser', 'require', 'default'], mainFields: ['react-native', 'browser', 'main'], + aliasFields: ['browser'], }); } return resolver;