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

feat(@netlify/build-info): add React Router 7 detection #5930

Merged
merged 3 commits into from
Dec 16, 2024

Conversation

serhalp
Copy link
Contributor

@serhalp serhalp commented Dec 9, 2024

Summary

React Router 7 was released a couple weeks ago. It's sort of the next version of Remix and also sort of the next version of React Router. It can be used as a library or as a framework.

Thus, this adds it to our framework detection, but only for version 7+.

There are some oddities here:

  • Technically we can't quite exhaustively know if the user is using "framework mode" or "library mode". We can check for @react-router/dev as an almost certain hint that the site uses RR7 as a framework, but according to the Remix/RR team this may not hold forever. Seems OK for now.
  • Technically we'd want to add react-router to Vite's excludedNpmDependencies, but we actually only want to exclude RR >=7 (many RR <7 users will be using Vite or something else, so we don't want to break that).
    • But everything works fine if we just don't do anything here, since frameworks get priority over bundlers when there are multiple matches (I'm not really sure why we both excluding Vite frameworks in the Vite logic), and the code to do this right would be a bit gross.

@serhalp serhalp force-pushed the serhalp/frb-1511-support-react-router-7 branch from bfe95a3 to d6c7af4 Compare December 10, 2024 20:43
@serhalp serhalp force-pushed the serhalp/frb-1511-support-react-router-7 branch from d6c7af4 to 820bd41 Compare December 10, 2024 21:30
Technically we'd want to add it to Vite's `excludedNpmDependencies`, but we actually only
want to exclude RR >=7. Many RR <7 users will be using Vite, so we don't want to break
that.

But everything works fine if we just don't do anything here, since frameworks get priority
over bundlers when there are multiple matches. (I'm not really sure why we both excluding
Vite frameworks in the Vite logic).
@serhalp serhalp force-pushed the serhalp/frb-1511-support-react-router-7 branch from 820bd41 to a75b85a Compare December 10, 2024 21:33
@serhalp serhalp marked this pull request as ready for review December 10, 2024 21:33
@serhalp serhalp requested a review from a team as a code owner December 10, 2024 21:33
readonly id = 'react-router'
name = 'React Router'
configFiles = ['react-router.config.ts', 'react-router.config.js']
npmDependencies = ['react-router']
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to detect the plugin we built as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. We've been doing that for some of the frameworks, but I was thinking about it and couldn't come up with any reason for it, so I didn't include it. You definitely need react-router to use react-router; checking for additional dependencies won't help.

mrstork
mrstork previously approved these changes Dec 11, 2024
@serhalp serhalp merged commit 2289a78 into main Dec 16, 2024
33 checks passed
@serhalp serhalp deleted the serhalp/frb-1511-support-react-router-7 branch December 16, 2024 14:41
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