Skip to content

Commit e680bee

Browse files
authored
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 #79385
1 parent 5ce7065 commit e680bee

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

crates/next-custom-transforms/src/react_compiler.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ impl Visit for Finder {
3838
if self.found {
3939
return;
4040
}
41+
if matches!(
42+
node,
43+
Expr::JSXMember(..)
44+
| Expr::JSXNamespacedName(..)
45+
| Expr::JSXEmpty(..)
46+
| Expr::JSXElement(..)
47+
| Expr::JSXFragment(..)
48+
) {
49+
self.found = true;
50+
return;
51+
}
52+
4153
node.visit_children_with(self);
4254
}
4355

@@ -54,7 +66,7 @@ impl Visit for Finder {
5466
fn visit_fn_expr(&mut self, node: &FnExpr) {
5567
let old = self.is_interested;
5668

57-
self.is_interested = node.ident.as_ref().is_some_and(|ident| {
69+
self.is_interested |= node.ident.as_ref().is_some_and(|ident| {
5870
ident.sym.starts_with("use") || ident.sym.starts_with(|c: char| c.is_ascii_uppercase())
5971
});
6072

0 commit comments

Comments
 (0)