Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion crates/next-custom-transforms/src/react_compiler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use swc_core::ecma::{
ast::{Callee, Expr, FnDecl, FnExpr, Program, ReturnStmt},
ast::{Callee, Expr, FnDecl, FnExpr, Pat, Program, ReturnStmt, VarDeclarator},
visit::{Visit, VisitWith},
};

Expand Down Expand Up @@ -68,4 +68,19 @@ impl Visit for Finder {

node.visit_children_with(self);
}

fn visit_var_declarator(&mut self, node: &VarDeclarator) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested a review to the turbopack team as it's rust change, and it's about Rust repr of SWC AST

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;
}
}
Loading