[Performance] Enable React Compiler for automatic memoization (#11783)

* feat(ui): enable React Compiler (#67)

Enable reactCompiler: true in next.config.mjs (Next 16 + React 19.2.8).
This automates memoization at build time, removing manual useCallback/useMemo
debt (591 + 283 instances respectively) and preventing stale-closure bugs.

Test results (pre-existing failures unchanged):
  vitest UI: 282/295 files pass (13 fail = missing router/ReactFlow mocks)
  vitest:    1805/1857 tests pass (52 fail = same pre-existing mock issues)
  node:test: api/services/db all pass (except platform-specific
             serviceSupervisorSpawnError — Windows spawn("ls") issue)

No new failures introduced by the compiler transform.
Optional cleanup: remove now-redundant useCallback/useMemo in hot components.

* fix(build): add babel-plugin-react-compiler peer dependency (#67)

React Compiler (reactCompiler: true in next.config.mjs) requires
babel-plugin-react-compiler as an explicit peer dependency — Next.js
declares it as optional ("*") and does not auto-install it.

Installed babel-plugin-react-compiler@1.0.0 as a devDependency.
Resolves correctly from both the project root and the next package
context (Turbopack resolution path).

* fix(ci): allowlist babel-plugin-react-compiler for React Compiler

The React Compiler peer is a real npm package (facebook/react, MIT) required
by Next 16 `reactCompiler: true`. Adding it to the anti-slopsquat allowlist
unblocks check:deps and the 6A.8 unit-test gate.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

* fix(ci): drop unused collectSSE helper that trips ESLint

The helper was leftover from #12151 and fails the absolute
lint:json --max-warnings 0 gate on every PR that includes it.

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>

---------

Co-authored-by: diegosouzapw <8016841+diegosouzapw@users.noreply.github.com>
Co-authored-by: WebPerson <jonlwheat2-gif@users.noreply.github.com>
This commit is contained in:
WebPerson
2026-09-01 22:10:59 -05:00
committed by GitHub
parent 96824288f5
commit 24b784e9bb
6 changed files with 20 additions and 0 deletions

View File

@@ -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

View File

@@ -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",

View File

@@ -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

11
package-lock.json generated
View File

@@ -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",

View File

@@ -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",

View File

@@ -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",