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 the exports #744

Closed
wants to merge 1 commit into from
Closed

Conversation

f8k8
Copy link

@f8k8 f8k8 commented Jul 15, 2022

Summary

The React Native build tools search through all dependencies and parse the package.json from each. When the package.json is not included in a dependencies exports, the build fails, and so currently svgr/webpack cannot be used with React Native.
There's thread with a feature request for Node to have special treatment for package.json, but the Node team have stated this isn't likely to happen: nodejs/node#33460
There's an open PR for the React Native tools to add an attempt at a fallback to deal with this, but it's more of a workaround than an actual fix: react-native-community/cli#1648
The actual fix requires any used dependencies to either exclude the exports section in their package.json, or to list the package.json as an export. This also fixes #742

Test plan

  • Build the project (npm run build).
  • Include the project as a dependency in another project.
  • Require the package.json: require("@svgr/webpack/package.json");

Without explicitly specifying the package.json in the exports, the require fails with: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports".

@vercel
Copy link

vercel bot commented Jul 15, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
svgr ✅ Ready (Inspect) Visit Preview Jul 15, 2022 at 9:10PM (UTC)

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.

ERR_PACKAGE_PATH_NOT_EXPORTED
1 participant