-
Notifications
You must be signed in to change notification settings - Fork 35
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
Switch from react-scripts
(Create React App) to Vite
#2462
Conversation
Here's the npm trends graph for react-scripts vs vite, just for fun. ![]() |
This is now working, tested, rebased, and ready for review. Note that I've split this upgrade out into a whole bunch of commits, in case that makes reviewing easier, but I'll be squashing them all together at merge time because some of the intermediate commits don't build, or have failing tests. |
I think there is something wrong with the handling of oauth... I am unable to log in.
|
Other than that, i had no problem running the app and everything else is working great! |
Thanks for testing and catching this. I think I've fixed this now. Running with a local backend on port 9000 works for me now, using this
The cause of the issue was that I'd messed up a search-and-replace on |
Yup, oauth is working now for me. There is one more thing that should be investigated/fixed soon after or before merging this... Screen.Recording.2024-10-15.at.3.49.07.PM.movAs you can see in the video, the points link to the leaderboard seems to open a new instance of the application causing the long initial load to happen again, this is much more apparent in the vite app. |
I assume users would be fine with the initial load taking longer for now... maybe we can add a placeholder till the app is fully loaded so that its not a blank white screen, but in the meantime i feel like making sure all the links in the app dont open another instance is a good first step. |
It looks like that particular link is a plain old HTML The Vite app seems like it's slower than react-scripts was at handling these full page reload events (it might be faster if you close the devtools? having them open sometimes disables caching). But that is only true of the developer experience with Vite. Full page loads of the production build of the app should be pretty fast. Nonetheless, there's no reason for the link in question to be an |
This reverts commit 890f942.
Create React App seems to be effectively abandoned. It hasn't had a release in over two years, and has fallen far behind the latest versions of its major dependencies (babel, eslint, jest, postcss, tailwind, webpack). I looked but couldn't find an active fork of the project.
It seems like the "batteries included" build tool that people are using these days is Vite. So I took a stab at porting MapRoulette to use Vite (and its companion test framework, Vitest) instead of
react-scripts
and Jest.It actually wasn't as difficult as I thought it might be. Vite's docs are pretty good, and mostly it works the way you'd want it to out of the box, so the configuration file ended up just being a dozen lines or so.
In addition to no longer being tied to an unmaintained project, some other benefits of switching to Vite are:
The developer experience with Vite is mostly the same. A few differences worth noting are:
.jsx
(or.tsx
) extensionimport.meta.env
instead ofprocess.env
dist/
, notbuild/
Other than that it's pretty much the same.
yarn {start,build,test}
work like before. Source maps still work. Localization files work the same..env
files work the same.