Migrate from Create React App to Vite and upgrade to React 19#19
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Migrate from Create React App to Vite and upgrade to React 19#19devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
- Replace react-scripts with vite, @vitejs/plugin-react, vitest, jsdom - Add vite.config.js with src/* path aliases and vitest config (jsdom env) - Move public/index.html -> index.html, add <script type="module" src="/src/index.jsx"> - Rename src/index.js -> src/index.jsx and switch to ReactDOM createRoot - Upgrade React/ReactDOM to ^19.0.0 - Pass nodeRef to CSSTransition in Modal and Alert (React 19 dropped findDOMNode) - Upgrade @testing-library/react ^16, @testing-library/jest-dom ^6, user-event ^14 - Use @testing-library/jest-dom/vitest in src/setupTests.js - Rewrite src/App.test.jsx to wrap App in AlertProvider (CRA boilerplate test removed) - Rename src/context/AlertContext.js -> .jsx (Vite/rolldown won't transform JSX in .js) - Upgrade react-icons to ^5, react-countdown to ^2.3.6, web-vitals to ^5 and migrate reportWebVitals to web-vitals v5 onCLS/onINP/onFCP/onLCP/onTTFB API - Drop CRA-specific eslintConfig and browserslist from package.json - Add /dist to .gitignore Co-Authored-By: vanessa.salas <vanessa.salas@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates the project off the unmaintained
react-scripts(CRA) toolchain onto Vite, and upgrades the runtime to React 19 along with related testing and icon libraries.Build tooling: CRA → Vite
react-scripts, addedvite ^8.0.12,@vitejs/plugin-react ^6.0.1.vite.config.jsat the repo root with:components,constants,context,hooks,lib,styles(replicating CRA'sjsconfig.jsonbaseUrl: srcbehaviour so existing absolute imports keep working).server.port: 3000to preserve the previous dev URL.environment: 'jsdom',globals: true,setupFiles: './src/setupTests.js').public/index.html→ repo rootindex.html. Replaced%PUBLIC_URL%references with absolute paths and added<script type="module" src="/src/index.jsx">.src/index.js→src/index.jsx(Vite/rolldown require explicit JSX extensions).src/context/AlertContext.js→src/context/AlertContext.jsx— the build failed without it because rolldown doesn't transpile JSX inside.jsfiles (the other.jsfiles insrc/hooks/don't contain JSX, so they were left alone).package.jsonscripts:start→vite,build→vite build,test→vitest, plus a newpreview→vite preview. Removed the CRA-specificeslintConfigandbrowserslistblocks. Added"type": "module"(required for ESMvite.config.js)./distto.gitignore.React 19
reactandreact-domto^19.0.0.src/index.jsxto usecreateRootfromreact-dom/clientinstead of the legacyReactDOM.render.src/components/Modal/Modal.jsxandsrc/components/Alert/Alert.jsx: added anodeRefto eachCSSTransitionsoreact-transition-groupno longer relies onfindDOMNode(removed in React 19).react-transition-groupis still v4 (no v5 published yet); thenodeRefapproach is the documented fix.Testing: Jest (via CRA) → Vitest
vitest ^4.1.6andjsdom ^29.1.1as dev deps.@testing-library/reactto^16.3.2,@testing-library/jest-domto^6.9.1,@testing-library/user-eventto^14.6.1.src/setupTests.jsnow imports@testing-library/jest-dom/vitest(the v6 entrypoint that wires matchers into Vitest'sexpect).src/App.test.jsxpreviously asserted on"learn react"text (CRA boilerplate that never matched anything in this app). Rewrote it as a real smoke test that renders<App />wrapped in<AlertProvider>and asserts the container isn't empty.Other dependency upgrades
react-icons^4.3.1→^5.6.0(compatible with React 19).react-countdown^2.3.2→^2.3.6(latest, supports React 19).web-vitals^2.1.4→^5.2.0. Updatedsrc/reportWebVitals.jsto use the v3+ API (onCLS,onINP,onFCP,onLCP,onTTFB) — the v2 functionsgetFID,getCLS, etc. no longer exist in v5, so the file would otherwise crash at runtime as soon asreportWebVitals(console.log)was called.Verification
npm install→ clean install (216 packages, 0 vulnerabilities).npm run check(Prettier) → all files formatted.npm run build→vite buildsucceeds (dist/index.html+ assets emitted).npx vitest run→ 1 test passes.npm start(Vite dev server onhttp://localhost:3000) → app loads, board renders, keyboard renders, welcome modal animates in. No console errors.Screenshot of the running dev server (Vite, React 19) before the welcome modal appears:
Review & Testing Checklist for Human
Risk level: yellow — large dependency bump and toolchain swap, but functional surface area of the app is small and the smoke test + manual run looked good.
npm install && npm start, then play a full game: type guesses, submit with Enter, verify the row flip animation runs and the keyboard highlights correctly. Open the Stats, Settings, and How to play modals — each one should fade in and the click-outside behaviour should still close them (this is theCSSTransition+nodeRefpath).npm run build && npm run previewand confirm the production bundle behaves identically — Vite's prod build is a different code path than dev.localStoragepersistence still works (refresh after a guess; the row should still be filled in).Notes
react-transition-groupdoes not yet have a v5; v4.4.5 +nodeRefis the React 19-compatible path."type": "module"was added topackage.jsonsovite.config.jscan be authored as ESM (usesimportsyntax). This shouldn't affect anything else in this project since there are no CommonJS scripts.jsconfig.jsonin place — it still helps editors resolve the path aliases even though Vite no longer reads it.src/App.test.jsxwas a boilerplate test that asserted on text (/learn react/i) that has never existed in this app — it would have failed under either toolchain. Replaced with a smoke test rather than deleted sonpm testcontinues to exercise something real.Link to Devin session: https://app.devin.ai/sessions/9ac47575d81b421d9a0ea23513ca0609
Requested by: @vanessasalas-cog
Devin Review