mirror of
https://github.com/hanzoai/swc.git
synced 2026-10-30 19:42:53 +00:00
**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 🤖._