Skip to content

Commit f3550f1

Browse files
committed
fix
1 parent e094f8b commit f3550f1

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

crates/swc_ecma_minifier/src/compress/optimize/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::{
3131
maybe_par,
3232
mode::Mode,
3333
option::{CompressOptions, MangleOptions},
34-
program_data::ProgramData,
34+
program_data::{ProgramData, VarUsageInfo},
3535
util::{
3636
contains_eval, contains_leaping_continue_with_label, make_number, ExprOptExt, ModuleItemExt,
3737
},
@@ -323,7 +323,7 @@ impl From<&Function> for FnMetadata {
323323

324324
impl Optimizer<'_> {
325325
fn may_remove_ident(&self, id: &Ident) -> bool {
326-
if self.ctx.is_exported {
326+
if let Some(VarUsageInfo { exported: true, .. }) = self.data.vars.get(&id.clone().to_id()) {
327327
return false;
328328
}
329329

crates/swc_ecma_minifier/src/compress/optimize/sequences.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,9 +1525,8 @@ impl Optimizer<'_> {
15251525
// Respect top_retain
15261526
if let Some(a_id) = a.id() {
15271527
if a_id.0 == "arguments"
1528-
|| (self.ctx.in_top_level()
1529-
&& a_id.1 == self.marks.top_level_ctxt
1530-
&& self.options.top_retain.contains(&a_id.0))
1528+
|| (matches!(a, Mergable::Var(_) | Mergable::FnDecl(_))
1529+
&& !self.may_remove_ident(&Ident::from(a_id)))
15311530
{
15321531
return Ok(false);
15331532
}

0 commit comments

Comments
 (0)