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 inline functions if keep_fnames is enabled #8093

Merged
merged 31 commits into from
Oct 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove safari10
  • Loading branch information
kdy1 committed Oct 11, 2023
commit 8f71bc21f43f3e96aa33afe1e0cf3ce0cf82dd08
47 changes: 11 additions & 36 deletions crates/swc_ecma_transforms_base/src/rename/analyzer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub(super) mod scope;

#[derive(Debug, Default)]
pub(super) struct Analyzer {
pub safari_10: bool,
/// If `eval` exists for the current scope, we only rename synthesized
/// identifiers.
pub has_eval: bool,
Expand Down Expand Up @@ -50,7 +49,6 @@ impl Analyzer {
{
{
let mut v = Analyzer {
safari_10: self.safari_10,
has_eval: self.has_eval,
top_level_mark: self.top_level_mark,

Expand Down Expand Up @@ -146,43 +144,20 @@ impl Visit for Analyzer {
}

fn visit_catch_clause(&mut self, n: &CatchClause) {
if self.safari_10 {
let old_is_pat_decl = self.is_pat_decl;
let old_in_catch_params = self.in_catch_params;

self.is_pat_decl = true;
self.in_catch_params = true;
n.param.visit_with(self);

self.in_catch_params = old_in_catch_params;
self.is_pat_decl = old_is_pat_decl;

self.with_scope(ScopeKind::Block, |v| {
let old = v.is_pat_decl;
let old_in_catch_params = v.in_catch_params;

v.is_pat_decl = false;
n.body.visit_children_with(v);

v.is_pat_decl = old;
v.in_catch_params = old_in_catch_params;
})
} else {
self.with_scope(ScopeKind::Block, |v| {
let old = v.is_pat_decl;
let old_in_catch_params = v.in_catch_params;
self.with_scope(ScopeKind::Block, |v| {
let old = v.is_pat_decl;
let old_in_catch_params = v.in_catch_params;

v.is_pat_decl = false;
n.body.visit_children_with(v);
v.is_pat_decl = false;
n.body.visit_children_with(v);

v.is_pat_decl = true;
v.in_catch_params = true;
n.param.visit_with(v);
v.is_pat_decl = true;
v.in_catch_params = true;
n.param.visit_with(v);

v.is_pat_decl = old;
v.in_catch_params = old_in_catch_params;
})
}
v.is_pat_decl = old;
v.in_catch_params = old_in_catch_params;
})
}

fn visit_class_decl(&mut self, c: &ClassDecl) {
Expand Down