Unverified Commit e680bee9 authored by Donny/강동윤's avatar Donny/강동윤 Committed by GitHub

fix(next-swc): Fix react compiler usefulness detector (#79479)

### What?

Fix usefulness detector for the React Compiler

### Why?

JSX was also target of the React Compiler

### How?

Closes https://github.com/vercel/next.js/issues/79385
parent 5ce70650
...@@ -38,6 +38,18 @@ impl Visit for Finder { ...@@ -38,6 +38,18 @@ impl Visit for Finder {
if self.found { if self.found {
return; return;
} }
if matches!(
node,
Expr::JSXMember(..)
| Expr::JSXNamespacedName(..)
| Expr::JSXEmpty(..)
| Expr::JSXElement(..)
| Expr::JSXFragment(..)
) {
self.found = true;
return;
}
node.visit_children_with(self); node.visit_children_with(self);
} }
...@@ -54,7 +66,7 @@ impl Visit for Finder { ...@@ -54,7 +66,7 @@ impl Visit for Finder {
fn visit_fn_expr(&mut self, node: &FnExpr) { fn visit_fn_expr(&mut self, node: &FnExpr) {
let old = self.is_interested; let old = self.is_interested;
self.is_interested = node.ident.as_ref().is_some_and(|ident| { self.is_interested |= node.ident.as_ref().is_some_and(|ident| {
ident.sym.starts_with("use") || ident.sym.starts_with(|c: char| c.is_ascii_uppercase()) ident.sym.starts_with("use") || ident.sym.starts_with(|c: char| c.is_ascii_uppercase())
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment