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

fix: Move react-router-dom as an explicit dependency #204

Closed
wants to merge 2 commits into from

Conversation

dubzzz
Copy link

@dubzzz dubzzz commented Jan 28, 2022

While react-router-dom is not always required at runtime (only really requested when using <SecureRoute />), having it defined as a peer dependency raises issues for any user wanted to move to next majors of react-router-dom and not relying on <SecureRoute />.

Indeed for such users of okta-react, WebPack and other bundlers will fail to build the project because of the import of useMatchRoute not being part of the new major of react-router-dom. While it probably makes a bit of sense when you use <SecureRoute />, having your build broken because of it while you don't need it at all is strange. By moving the library as a clear dependency, okta-react will always pull the right version and stop making user's builds fail.

Suggestion for #178

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Adding Tests
  • Build related changes
  • CI related changes
  • Documentation changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Reviewers

While `react-router-dom` is not always required at runtime (only really requested when using `<SecureRoute />`), having it defined as a peer dependency raise issues for any user wanted to move to next majors of `react-router-dom` and not relying on `<SecureRoute />`.

Indeed for such users of `okta-react`, WebPack and other bundlers will fail to build the project because of the import of `useMatchRoute` not being part of the new major of `react-router-dom`. While it probably make a bit of sense whne you use `<SecureRoute />`, having your build broken because of it while you don't need it at all is strange. By moving the library as a clear dependency, `okta-react` wil always pull the right version and stop making user's builds fail.
@dubzzz dubzzz force-pushed the move-react-router-dom-as-dep branch from 652cb4a to ca91f0c Compare January 28, 2022 16:13
@dubzzz dubzzz changed the title Move react-router-dom as an explicit dependency fix: Move react-router-dom as an explicit dependency Jan 28, 2022
@jaredperreault-okta
Copy link
Contributor

These packages need to be peer dependencies because the same version needs to be used in our sdk as in the application. This is the same reason react-dom lists react as a peer dependency (https://github.com/facebook/react/blob/main/packages/react-dom/package.json#L25).

However we are currently re-evaluating SecureRoute (and it's corresponding dependencies) to find a cleaner solution

@dubzzz
Copy link
Author

dubzzz commented Jan 28, 2022

Closing following comment #178 (comment)

It seems that there is something under way to unlock the situation.

@dubzzz dubzzz closed this Jan 28, 2022
@dubzzz
Copy link
Author

dubzzz commented Jan 28, 2022

@jaredperreault-okta So far I used patch-package to remove SecureRoute from the bundle of okta-react (and imports of react-router-dom) I'm using. It fixed my build issue and allows me to use v6.

@dubzzz dubzzz deleted the move-react-router-dom-as-dep branch March 9, 2022 10:31
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.

2 participants