Files
react/compiler/docs/DEVELOPMENT_GUIDE.md
Joseph Savona 3ce1316b05 [compiler][snap] Fixes to relative path resolution; compile subcommand (#35688)
More snap improvements for use with agents:
* `yarn snap compile [--debug] <path>` for compiling any file,
optionally with debug logs
* `yarn snap minimize <path>` now accepts path as a positional param for
consistency w 'compile' command
* Both compile/minimize commands properly handle paths relative to the
compiler/ directory. When using `yarn snap` the current working
directory is compiler/packages/snap, but you're generally running it
from the compiler directory so this matches expectations of callers
better.
2026-02-03 22:12:21 -05:00

1.6 KiB

React Compiler Development Guide

Note: for general notes about contributing, see the CONTRIBUTING.md.

Compiler Development

For general compiler development we recommend the following workflow:

# Install dependencies
yarn

# build the custom test runner
yarn snap:build

# Run the primary tests in watch mode
yarn snap --watch

snap is our custom test runner, which creates "golden" test files that have the expected output for each input fixture, as well as the results of executing a specific input (or sequence of inputs) in both the uncompiled and compiler versions of the input.

Compiling Arbitrary Files

You can compile any file (not just fixtures) using:

# Compile a file and see the output
yarn snap compile <path>

# Compile with debug output to see the state after each compiler pass
# This is an alternative to `yarn snap -d -p <pattern>` when you don't have a fixture file yet
yarn snap compile --debug <path>

Minimizing Test Cases

To reduce a failing test case to its minimal reproduction:

# Minimize a file that causes a compiler error
yarn snap minimize <path>

# Minimize and update the file in-place
yarn snap minimize --update <path>

When contributing changes, we prefer to:

  • Add one or more fixtures that demonstrate the current compiled output for a particular combination of input and configuration. Send this as a first PR.
  • Then, make changes to the compiler that achieve the desired output for those examples. Commit both the output changes and the corresponding compiler changes in a second PR.