Skip to content

Commit

Permalink
Restore 'import' in default Package Exports conditions (#36902)
Browse files Browse the repository at this point in the history
Summary:
X-link: facebook/react-native#36902

Reverts facebook/react-native#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: 004172388916c902469b49cfc920ebe13c62c430
  • Loading branch information
huntie authored and facebook-github-bot committed Apr 14, 2023
1 parent 026cf09 commit e70ceef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Object {
],
"unstable_conditionNames": Array [
"require",
"import",
],
"unstable_conditionsByPlatform": Object {
"web": Array [
Expand Down Expand Up @@ -252,6 +253,7 @@ Object {
],
"unstable_conditionNames": Array [
"require",
"import",
],
"unstable_conditionsByPlatform": Object {
"web": Array [
Expand Down Expand Up @@ -429,6 +431,7 @@ Object {
],
"unstable_conditionNames": Array [
"require",
"import",
],
"unstable_conditionsByPlatform": Object {
"web": Array [
Expand Down Expand Up @@ -606,6 +609,7 @@ Object {
],
"unstable_conditionNames": Array [
"require",
"import",
],
"unstable_conditionsByPlatform": Object {
"web": Array [
Expand Down
2 changes: 1 addition & 1 deletion packages/metro-config/src/defaults/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const getDefaultValues = (projectRoot: ?string): ConfigT => ({
nodeModulesPaths: [],
resolveRequest: null,
resolverMainFields: ['browser', 'main'],
unstable_conditionNames: ['require'],
unstable_conditionNames: ['require', 'import'],
unstable_conditionsByPlatform: {
web: ['browser'],
},
Expand Down

0 comments on commit e70ceef

Please sign in to comment.