Unverified Commit 04176dec authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

fix(react-compiler): Fix detection of interest (#78879)

Backport of #78874 to 15.3.x
Co-authored-by: 's avatarDonny/강동윤 <kdy1997.dev@gmail.com>
parent b40778b3
use swc_core::ecma::{ use swc_core::ecma::{
ast::{Callee, Expr, FnDecl, FnExpr, Program, ReturnStmt}, ast::{Callee, Expr, FnDecl, FnExpr, Pat, Program, ReturnStmt, VarDeclarator},
visit::{Visit, VisitWith}, visit::{Visit, VisitWith},
}; };
...@@ -68,4 +68,19 @@ impl Visit for Finder { ...@@ -68,4 +68,19 @@ impl Visit for Finder {
node.visit_children_with(self); node.visit_children_with(self);
} }
fn visit_var_declarator(&mut self, node: &VarDeclarator) {
let old = self.is_interested;
if let Pat::Ident(ident) = &node.name {
self.is_interested = ident.sym.starts_with("use")
|| ident.sym.starts_with(|c: char| c.is_ascii_uppercase());
} else {
self.is_interested = false;
}
node.visit_children_with(self);
self.is_interested = old;
}
} }
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