refactor(transformer/react-refresh): use generate_uid_in_current_hoist_scope to add hoisted binding (#7492)

This commit is contained in:
Dunqing 2024-11-26 16:12:11 +00:00
parent 488029ea24
commit ef62b9dacc

View file

@ -582,14 +582,7 @@ impl<'a, 'ctx> ReactRefresh<'a, 'ctx> {
arguments.push(function); arguments.push(function);
} }
// TODO: Handle var hoisted in ctx API let binding = ctx.generate_uid_in_current_hoist_scope("s");
let target_scope_id = ctx
.scopes()
.ancestors(ctx.current_scope_id())
.find(|&scope_id| ctx.scopes().get_flags(scope_id).is_var())
.unwrap_or_else(|| ctx.current_scope_id());
let binding = ctx.generate_uid("s", target_scope_id, SymbolFlags::FunctionScopedVariable);
// _s(); // _s();
let call_expression = ctx.ast.statement_expression( let call_expression = ctx.ast.statement_expression(