react/compiler
Niklas Mollenhauer 946da518eb
feat(compiler): implement constant folding for unary minus (#33140)
## Summary
`-constant` is represented as a `UnaryExpression` node that is currently
not part of constant folding. If the operand is a constant number, the
node is folded to `constant * -1`. This also coerces `-0` to `0`,
resulting in `0 === -0` being folded to `true`.

## How did you test this change?
See attached tests
2025-05-07 10:15:11 -07:00
..
apps/playground [chore] Update caniuse-lite (#33013) 2025-04-24 13:50:03 -04:00
docs Update DEVELOPMENT_GUIDE.md (#32281) 2025-03-13 11:45:26 -04:00
fixtures [cleanup] Remove compiler runtime-compat fixture library (#31430) 2024-11-05 14:14:39 -05:00
packages feat(compiler): implement constant folding for unary minus (#33140) 2025-05-07 10:15:11 -07:00
scripts [compiler] Add missing copyrights (#33004) 2025-04-23 22:04:44 -04:00
.eslintrc.js [compiler:codegen] Wrap non-ascii characters in JsxExpressionContainer 2024-06-21 10:08:15 -04:00
.gitignore [forgive] Init (#31918) 2025-02-25 12:19:11 -05:00
CHANGELOG.md [compiler] Add changelog (#32983) 2025-04-24 16:20:02 -04:00
package.json [compiler] Update rimraf (#32868) 2025-04-14 15:15:14 -04:00
README.md Update readme and other docs 2024-05-06 14:53:47 -07:00
yarn.lock [mcp] Fix package.json (#33101) 2025-05-02 13:56:01 -04:00

React Compiler

React Compiler is a compiler that optimizes React applications, ensuring that only the minimal parts of components and hooks will re-render when state changes. The compiler also validates that components and hooks follow the Rules of React.

More information about the design and architecture of the compiler are covered in the Design Goals.

More information about developing the compiler itself is covered in the Development Guide.