-
-
Notifications
You must be signed in to change notification settings - Fork 904
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: export package.json required by react-native and bundlers #449
Conversation
0625b3e
to
bac0341
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something about this smells a bit off. I don't really consider package.json to be part of our public API. Thus, adding it to exports
seems wrong. But I guess there's no alternative. 'Really wish RN had figured out a different approach that didn't require 100's or 1000's of projects to all make the same change. :-(
I think this is only half-true: We have been using the While I also believe that RN should degrade gracefully if it cannot read the Speaking of: @TrySound do you have any clue why |
rollup and webpack use only fs calls for resolving which is not harmed by exports isolation. Metro may use require or require.resolve for some reason but I'm not confident about it as never used metro before. |
It appears that react-native and some bundlers rely on being able to introspect the package.json file of a npm module. After adding the `exports` field to package.json, only the paths defined in that field are accessible to Node.js. In order to support introspection of the package.json file itself it has to be listed as an export as well. See also: ai/nanoevents#44 (comment) Fixes #444
bac0341
to
ab3dec6
Compare
Given the discussion in nodejs/node#33460 I believe the correct thing to do right now is to treat our Lines 19 to 31 in a21e4d8
If node changes behavior of |
Fixes the issue: sindresorhus#145 A similar issue and fix can be found from instance here: uuidjs/uuid#449
It appears that react-native and some bundlers rely on being able to
introspect the package.json file of a npm module. After adding the
exports
field to package.json, only the paths defined in that fieldare accessible to Node.js. In order to support introspection of the
package.json file itself it has to be listed as an export as well (see:
ai/nanoevents#44 (comment)).
It is currently being discussed to change Node.js' behavior again, see:
nodejs/node#33460
Fixes #444