diff --git a/package-lock.json b/package-lock.json index d3fd29d..5a2ce63 100644 --- a/package-lock.json +++ b/package-lock.json @@ -56,6 +56,7 @@ "@testing-library/react": "^16.3.2", "@vitejs/plugin-react": "^4.3.3", "autoprefixer": "^10.4.20", + "babel-plugin-react-compiler": "^1.0.0", "concurrently": "^9.1.0", "eslint": "^9.39.4", "eslint-plugin-react-hooks": "^5.2.0", @@ -6488,6 +6489,16 @@ "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" } }, + "node_modules/babel-plugin-react-compiler": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/babel-plugin-react-compiler/-/babel-plugin-react-compiler-1.0.0.tgz", + "integrity": "sha512-Ixm8tFfoKKIPYdCCKYTsqv+Fd4IJ0DQqMyEimo+pxUOMUR9cVPlwTrFt9Avu+3cb6Zp3mAzl+t1MrG2fxxKsxw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.26.0" + } + }, "node_modules/balanced-match": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", diff --git a/package.json b/package.json index f8dc7c5..f410c6b 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "@testing-library/react": "^16.3.2", "@vitejs/plugin-react": "^4.3.3", "autoprefixer": "^10.4.20", + "babel-plugin-react-compiler": "^1.0.0", "concurrently": "^9.1.0", "eslint": "^9.39.4", "eslint-plugin-react-hooks": "^5.2.0", diff --git a/vite.config.mjs b/vite.config.mjs index 0625f39..b72ea64 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -12,7 +12,14 @@ const apiPort = process.env.API_PORT || process.env.PORT || 3000; export default defineConfig({ plugins: [ - react(), + // React Compiler (React 19): auto-memoizes components/hooks at build time, so + // manual useMemo/useCallback become largely unnecessary. Safe here because the + // codebase is rules-of-hooks clean (enforced by eslint-plugin-react-hooks). + react({ + babel: { + plugins: [['babel-plugin-react-compiler', {}]], + }, + }), VitePWA({ registerType: 'autoUpdate', includeAssets: ['img/logo.png', 'img/pwa-192.png', 'img/pwa-512.png'],