diff --git a/changelog.d/features/11783-react-compiler.md b/changelog.d/features/11783-react-compiler.md new file mode 100644 index 0000000000..9c38f22557 --- /dev/null +++ b/changelog.d/features/11783-react-compiler.md @@ -0,0 +1 @@ +- **feat(ui):** enable React Compiler (`reactCompiler: true` + `babel-plugin-react-compiler`) for automatic memoization at build time ([#11783](https://github.com/diegosouzapw/OmniRoute/pull/11783)) — thanks @jonlwheat2-gif diff --git a/config/quality/dependency-allowlist.json b/config/quality/dependency-allowlist.json index ef32957851..e29948160e 100644 --- a/config/quality/dependency-allowlist.json +++ b/config/quality/dependency-allowlist.json @@ -3,6 +3,7 @@ "_justifications": { "@testing-library/dom": "Peer dep obrigatoria de @testing-library/react v16 (adicionada no PR #11224); Refs #9985.", "@testing-library/user-event": "Utilitario oficial do ecossistema testing-library para testes de UI (adicionada no PR #11224); Refs #9985.", + "babel-plugin-react-compiler": "Official React Compiler Babel plugin (facebook/react, MIT). Required peer of Next.js 16 `reactCompiler: true`; Next declares it optional (`*`) and does not auto-install. Added by PR #11783 / issue #67.", "eslint-plugin-react-hooks": "React Hooks lint rules (set-state-in-effect, immutability, refs, purity) pinned at 7.0.1 by the release/v3.8.51 cycle; the 224 findings it raised are tracked in #11924. Refs #11924." }, "allowed": [ @@ -44,6 +45,7 @@ "ajv", "ajv-formats", "axios", + "babel-plugin-react-compiler", "bcryptjs", "better-sqlite3", "bottleneck", diff --git a/next.config.mjs b/next.config.mjs index e384d2d88f..c5b9899adb 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -223,6 +223,9 @@ const nextConfig = { ...(isContributorBuild ? {} : { output: "standalone" }), compress: true, productionBrowserSourceMaps: false, + // Issue #67: enable React Compiler — automates memoization, removes manual useCallback/useMemo debt. + // See: https://next.dev/blog/react-compiler + reactCompiler: true, // OmniRoute is a proxy for AI APIs — request bodies routinely include // multi-MB payloads (vision models, image edits, base64-encoded files, // long chat histories with embedded images). Next.js's Server Action diff --git a/package-lock.json b/package-lock.json index 0e942c17d8..4b71b7e3b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -122,6 +122,7 @@ "@types/safe-regex": "^1.1.6", "@types/ws": "^8.18.0", "@vitejs/plugin-react": "^6.1.0", + "babel-plugin-react-compiler": "^1.0.0", "bun": "1.4.0", "c8": "^12.0.0", "concurrently": "^10.0.5", @@ -16173,6 +16174,16 @@ "npm": ">=6" } }, + "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/babel-walk": { "version": "3.0.0-canary-5", "resolved": "https://registry.npmjs.org/babel-walk/-/babel-walk-3.0.0-canary-5.tgz", diff --git a/package.json b/package.json index 8f12f4272e..f315bcd433 100644 --- a/package.json +++ b/package.json @@ -386,6 +386,7 @@ "@types/safe-regex": "^1.1.6", "@types/ws": "^8.18.0", "@vitejs/plugin-react": "^6.1.0", + "babel-plugin-react-compiler": "^1.0.0", "bun": "1.4.0", "c8": "^12.0.0", "concurrently": "^10.0.5", diff --git a/tests/unit/next-config.test.ts b/tests/unit/next-config.test.ts index 589255d837..9503a9b4ea 100644 --- a/tests/unit/next-config.test.ts +++ b/tests/unit/next-config.test.ts @@ -30,6 +30,8 @@ test("next config exposes standalone build settings and canonical rewrites", asy assert.equal(nextConfig.distDir, ".next-task607"); assert.equal(nextConfig.output, "standalone"); + // #67 / #11783: React Compiler is an explicit Next 16 opt-in (peer babel plugin). + assert.equal(nextConfig.reactCompiler, true); assert.equal(nextConfig.images.unoptimized, true); assert.deepEqual(nextConfig.transpilePackages, [ "@omniroute/open-sse",