refactor(es/minifier): Remove unnecessary check (#8927)

This commit is contained in:
Austaras 2024-05-07 14:19:24 +08:00 committed by GitHub
parent 8654a34385
commit 8932a1b527
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -751,18 +751,6 @@ impl Optimizer<'_> {
}
}
// We should not add a variable to top level scope if the user has disabled it.
//
// See https://github.com/swc-project/swc/issues/8909
if !self.options.top_level() && self.ctx.in_top_level() {
for s in body.stmts.iter() {
if let Stmt::Decl(Decl::Var(..)) = s {
log_abort!("iife: [x] Cannot inline because of top level scope");
return false;
}
}
}
if !body.stmts.iter().all(|stmt| match stmt {
Stmt::Decl(Decl::Var(var))
if matches!(