Files
Jordan ThomsonandGitHub fc0221dd89 fix(react-compiler): Remove React-like prefilter (#12007)
**Description:**

Remove SWC's React-like function prefilter and defer compilation
eligibility to React Compiler.

The prefilter duplicates React Compiler policy and rejects source before
the compiler can evaluate it. For example:

```jsx
function createFoo() {
  return function Foo() {
    "use memo";
    return <div>hello, world</div>;
  };
}
```

React Compiler's Babel integration compiles the annotated inner
function, but SWC previously returned the source unchanged because
`createFoo` did not look React-like and the prefilter intentionally did
not inspect nested function bodies.

This pattern is not necessarily a React-blessed use of the directive nor
is it conventional React. Regardless, the SWC adapter should not impose
a stricter eligibility policy or limit valid uses of the React Compiler
API. React Compiler should remain responsible for deciding what to
compile.

This PR removes the React-like heuristic while retaining the separate
guard for unsupported resource-management declarations. It also adds a
fixture covering the nested directive case.

**Related issue (if exists):**

N/A

**Verification:**

- `cargo fmt --all`
- `cargo test -p swc_ecma_react_compiler`
- `cargo clippy --all --all-targets -- -D warnings`


---

_Prepared with assistance from OpenAI Codex 🤖._
2026-07-10 14:13:49 +00:00
..