auth0 / auth0-react

Auth0 SDK for React Single Page Applications (SPA)
MIT License
887 stars 256 forks source link

Fix peer deeps for monorepos #673

Open salvoravida opened 10 months ago

salvoravida commented 10 months ago

By submitting a PR to this repository, you agree to the terms within the Auth0 Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.

Description

This PR addresses the issue of peer dependencies involving @types/react for monorepos. Essentially, if you're using this package in a monorepo that includes applications utilizing both React 17 and React 18, it fails to accurately fetch the appropriate types.

References

Include any links supporting this change such as a:

  • GitHub Issue/PR number addressed or fixed
  • Auth0 Community post
  • StackOverflow post
  • Support forum thread
  • Related pull requests/issues from other repos

If there are no references, simply delete this section.

Testing

Describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.

Please include any manual steps for testing end-to-end or functionality not covered by unit/integration tests.

Also include details of the environment this PR was developed in (language/platform/browser version).

Checklist

frederikprijck commented 10 months ago

Thanks for reaching out and providing this PR. Can you help me understand the need to add this as a peer dependency? What if people aren't using typescript? Why would they need to pull in the same peer deps?

salvoravida commented 10 months ago

Thanks for reaching out and providing this PR. Can you help me understand the need to add this as a peer dependency? What if people aren't using typescript? Why would they need to pull in the same peer deps?

@frederikprijck I added peerDependenciesMeta with optional flag.

frederikprijck commented 10 months ago

Thanks for updating the metadata, but I am more curious to understand why you think we should need to have a peer dependency on types, as well as why it solves the issue in your project and why you can not solve it outside of our SDK (in your own project) instead.

Would you be able to share a minimal reproduction of the issue for us to look into and see what's causing it and better understand the issue and solution?

salvoravida commented 10 months ago

Thanks for updating the metadata, but I am more curious to understand why you think we should need to have a peer dependency on types, as well as why it solves the issue in your project and why you can not solve it outside of our SDK (in your own project) instead.

Would you be able to share a minimal reproduction of the issue for us to look into and see what's causing it and better understand the issue and solution?

Apologies, as setting up a test monorepo containing two React applications (one with React 17 and another with React 18) will require considerable time. I suggest examining the approaches used by other libraries to understand the concept better. It's important to note that a library supporting multiple versions of React also needs to have corresponding peer dependencies in the types/*. This allows the consumer application to select the appropriate types.

https://github.com/radix-ui/primitives/blob/main/packages/react/arrow/package.json

frederikprijck commented 10 months ago

Please understand this also takes the same effort for us to reproduce and look into.

Happy to look at something as soon as possible once something that reproduces it is provided. If not, this will need to wait due to other priorities at the moment and will need to get back to this at a later point (but we will still need more information about your setup to ensure we can reproduce this efficiently).

We don't generally just merge PRs with little context (the issue template isnt filled), and we like to understand what code we are adding by seeing it fix a certain issue and ensure we are onboard with the fix, I hope you understand that.