Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(es/minifier): Don't drop unused properties of top-level vars #7638

Merged
merged 3 commits into from
Jul 7, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/swc_ecma_minifier/src/compress/optimize/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,10 @@ impl Optimizer<'_> {
return None;
}

if self.ctx.top_level && !self.options.top_level() {
return None;
}

let name = v.name.as_ident()?;
let obj = v.init.as_mut()?.as_mut_object()?;

Expand Down