Skip to content
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

Add package.json to exports for React Native #74

Merged
merged 1 commit into from
Dec 22, 2020

Conversation

acostalima
Copy link
Contributor

This is required or Metro, React Native's bundler, complains and the build breaks.

"import": "./dist/bundle/index.mjs",
"require": "./dist/bundle/index.js"
"./package.json": "./package.json",
".": {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure on that one ? it seems awkward. Anyway I believe you should rather open an issue on Metro repo. This setup is pretty common, is not it?

Copy link
Contributor Author

@acostalima acostalima Dec 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure, as it fixes the issue. I believe Metro and other bundlers process package.json files by importing them instead of reading the file directly. In such case, the package.json's path must be specified in the exports field if it exists. It seems that there has been a lot of discussion about this topic, but not much of a conclusion I think. Therefore, feel free to close this PR for the time being. I'll apply a patch on my end while the issue is not addressed on React Native's side.

react-native-community/cli#1168
nodejs/node#33460

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok 👍 . I was referring to the "."
Have you checked this path does not break nodejs cjs and es import and tools like rollup ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I haven't. I've only checked in React Native.

Copy link

@hugomrdias hugomrdias Dec 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@hugomrdias hugomrdias Dec 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the new line for package.json we can't use the sugar syntax anymore, so it needs to be unpacked to the verbose version.

@lorenzofox3 lorenzofox3 merged commit 89e22a1 into lorenzofox3:master Dec 22, 2020
@acostalima
Copy link
Contributor Author

@lorenzofox3, can you release this? 🙏

@lorenzofox3
Copy link
Owner

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants