diff --git a/crates/swc_ecma_minifier/src/compress/optimize/iife.rs b/crates/swc_ecma_minifier/src/compress/optimize/iife.rs index 2ea598c69811..fdc82e11237e 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/iife.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/iife.rs @@ -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!(