From 21900d4ec62fa789fd7990b70b53fa586600308b Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Fri, 14 Apr 2023 02:15:29 -0700 Subject: [PATCH] Restore 'import' in default Package Exports conditions (#36902) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36902 Reverts https://github.com/facebook/react-native/pull/36584. Since we've come across example packages (typically targeting Node.js) which only distribute ESM, we believe it's more helpful to return to asserting the `"import"` condition by default, for maximum compatibility. The above issue and comments outline the pros/cons. Changelog: [General][Changed] - Default condition set for experimental Package Exports is now ['require', 'import', 'react-native'] Metro changelog: [Experimental] Package Exports unstable_conditionNames now defaults to ['require', 'import'] Reviewed By: robhogan Differential Revision: D44962143 fbshipit-source-id: f110182f37c07bc3fa5a3e6f936148e44b30a536 --- packages/metro-config/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/metro-config/index.js b/packages/metro-config/index.js index ec7d935e041d76..c43b46a34b8cf9 100644 --- a/packages/metro-config/index.js +++ b/packages/metro-config/index.js @@ -42,7 +42,7 @@ function getDefaultConfig( resolver: { resolverMainFields: ['react-native', 'browser', 'main'], platforms: ['android', 'ios'], - unstable_conditionNames: ['require', 'react-native'], + unstable_conditionNames: ['require', 'import', 'react-native'], }, serializer: { getPolyfills: () => require('@react-native/js-polyfills')(),