Skip to main content

Configuration

React Compiler provides extensive configuration options to customize its behavior for your project.

Basic Configuration

babel.config.js

Memoization Options

enablePreserveExistingMemoizationGuarantees

Type: boolean
Default: true
Preserves guarantees about when values are memoized from existing useMemo/useCallback calls.
When true:
  • Compiler uses useMemo/useCallback boundaries to understand mutation points
  • Guarantees existing referential equality behavior is preserved
  • Preserves effect execution patterns that depend on referential equality
When false:
  • Compiler ignores manual memoization completely
  • May change effect execution frequency
  • Mimics removing all manual memoization

validatePreserveExistingMemoizationGuarantees

Type: boolean
Default: true
Validates that all useMemo/useCallback values are also memoized by the compiler.

enablePreserveExistingManualUseMemo

Type: boolean
Default: false
When true, keeps existing useMemo/useCallback calls instead of pruning them.

Validation Options

validateHooksUsage

Type: boolean
Default: true
Validates that the component follows the Rules of Hooks.
Checks for:
  • Conditional hook calls
  • Hook calls in loops
  • Hook calls in nested functions

validateRefAccessDuringRender

Type: boolean
Default: true
Validates that ref.current is not accessed during render.

validateNoSetStateInRender

Type: boolean
Default: true
Validates that setState is not called unconditionally during render.

validateNoSetStateInEffects

Type: boolean
Default: false
Validates that setState is not called synchronously within effects.

validateExhaustiveMemoizationDependencies

Type: boolean
Default: true
Validates that dependencies in manual memoization are exhaustive.

validateExhaustiveEffectDependencies

Type: 'off' | 'all' | 'missing-only' | 'extra-only'
Default: 'off'
Validates effect hook dependencies.
  • 'off': No validation
  • 'all': Report missing and extra dependencies
  • 'missing-only': Only report missing dependencies
  • 'extra-only': Only report unnecessary dependencies

validateMemoizedEffectDependencies

Type: boolean
Default: false
Validates that effect dependencies are memoized to prevent infinite renders.

validateNoDerivedComputationsInEffects

Type: boolean
Default: false
Validates that effects don’t calculate derived data that could be computed during render.

validateNoCapitalizedCalls

Type: string[] | null
Default: null
Validates against calling capitalized functions (potential components with hooks).

Optimization Features

enableOptionalDependencies

Type: boolean
Default: true
Infers optional chaining in dependencies.

lowerContextAccess

Type: boolean
Default: false
Optimizes context access with selectors.

enableJsxOutlining

Type: boolean
Default: false
Extracts static JSX into separate components.

enableFunctionOutlining

Type: boolean
Default: false
Outlines pure functions for better memoization.

Type System Options

enableUseTypeAnnotations

Type: boolean
Default: false
Trusts user-supplied type annotations for better inference.

flowTypeProvider

Type: function | null
Default: null
Provides Flow type information to the compiler.

moduleTypeProvider

Type: function | null
Default: null
Provides module type signatures for imports.

Custom Hooks and Macros

customHooks

Type: Map<string, Hook>
Default: new Map()
Defines custom hook signatures.
Hook Configuration:

customMacros

Type: string[] | null
Default: null
Lists macro function names that should not be transformed.

Development Options

enableResetCacheOnSourceFileChanges

Type: boolean | null
Default: null
Enables HMR support by resetting cache when source changes.

enableEmitFreeze

Type: ExternalFunction | null
Default: null
Wraps memoized values in dev-mode mutation detector.
Generates:

validateSourceLocations

Type: boolean
Default: false
Validates that generated AST has proper source locations.

Advanced Options

enableAssumeHooksFollowRulesOfReact

Type: boolean
Default: true
Assumes hooks follow React’s rules (freeze arguments and return values).

enableTransitivelyFreezeFunctionExpressions

Type: boolean
Default: true
Assumes values captured by functions passed to React are not subsequently modified.

inferEffectDependencies

Type: Array<{function: ExternalFunction, autodepsIndex: number}> | null
Default: null
Auto-infers and inserts effect dependencies.

inlineJsxTransform

Type: {elementSymbol: string, globalDevVar: string} | null
Default: null
Inlines JSX as object literals instead of using JSX runtime.

Complete Example

babel.config.js

Environment-Specific Configuration

Next Steps

Babel Plugin

Advanced Babel integration

ESLint Plugin

Configure linting rules

How It Works

Understand compiler behavior

Architecture

Deep dive into compilation