Skip to content

Add React Compiler memoization preservation option - #98589

Open
wbinnssmith wants to merge 1 commit into
canaryfrom
codex/configure-react-compiler-memoization
Open

Add React Compiler memoization preservation option#98589
wbinnssmith wants to merge 1 commit into
canaryfrom
codex/configure-react-compiler-memoization

Conversation

@wbinnssmith

Copy link
Copy Markdown
Member

Summary

Add reactCompiler.enablePreserveExistingMemoizationGuarantees and forward it through the Babel and experimental Turbopack Rust compiler paths. Omitted values preserve each compiler implementation's default.

Add focused schema, Babel, and Rust tests and document the option.

Verification

  • pnpm --filter=next types
  • cargo check -p turbopack-ecmascript -p turbopack -p next-core
  • cargo test -p turbopack-ecmascript react_compiler_tests
  • cargo test -p next-core next_config
  • Manually verified in v0 with enablePreserveExistingMemoizationGuarantees: false

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

@wbinnssmith
wbinnssmith marked this pull request as ready for review September 11, 2026 22:01
@wbinnssmith
wbinnssmith requested review from a team, andrewimm, bgw and lukesandberg and removed request for bgw September 11, 2026 22:01
@wbinnssmith
wbinnssmith force-pushed the codex/configure-react-compiler-memoization branch from c3a6d80 to 06f9709 Compare September 11, 2026 22:11
Comment on lines +195 to +199
base: ReactCompilerOptionsWithoutEnvironment {
compilation_mode: react_compiler_options_with_target.compilation_mode,
panic_threshold: &react_compiler_options_with_target.panic_threshold,
target: react_compiler_options_with_target.target,
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a From implementation that could make this a little nicer

],
[undefined, { enableNameAnonymousFunctions: false }],
])(
'forwards the Babel environment option when configured as %s',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This test seems complicated and doesn't seem all that useful. If we really want more coverage we could extend one of our existing e2e tests that writes code that depends on this feature? But also, I don't think we need the coverage here.

);
}

use super::*;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just move this use up to the top of the test block, and don't add more use super::...s.

IMO use super::* is fine for test blocks. It's not okay anywhere else, but in tests it's idiomatic.

Comment on lines +46 to +49
const environment: Pick<EnvironmentConfig, 'enableNameAnonymousFunctions'> &
Partial<
Pick<EnvironmentConfig, 'enablePreserveExistingMemoizationGuarantees'>
> = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do some sort of simpler type like this? This is just a temporary value that we end up shoving into an untyped JSONValue on the next line.

Suggested change
const environment: Pick<EnvironmentConfig, 'enableNameAnonymousFunctions'> &
Partial<
Pick<EnvironmentConfig, 'enablePreserveExistingMemoizationGuarantees'>
> = {
const environment: Partial<EnvironmentConfig> = {

@wbinnssmith
wbinnssmith force-pushed the codex/configure-react-compiler-memoization branch from 06f9709 to b3eb58f Compare September 11, 2026 22:54
@@ -0,0 +1,63 @@
import { configSchema } from '../../packages/next/src/server/config-schema'

@vercel vercel Bot Sep 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new unit test test/unit/react-compiler-options.test.ts drags Next.js internals into the root tsc --noEmit, causing the types and precompiled / build CI job (pnpm run typescript) to fail with exit code 2.

Fix on Vercel

@wbinnssmith
wbinnssmith force-pushed the codex/configure-react-compiler-memoization branch from b3eb58f to 29ded58 Compare September 14, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants