mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
feat(es/minifier): Drop cycles in nested functions (#5933)
This commit is contained in:
parent
098a021a43
commit
e16827cc9d
@ -162,7 +162,6 @@ drop_unused/issue_t161_top_retain_9/input.js
|
||||
drop_unused/issue_t183/input.js
|
||||
drop_unused/keep_assign/input.js
|
||||
drop_unused/reassign_const/input.js
|
||||
drop_unused/unused_circular_references_1/input.js
|
||||
drop_unused/unused_circular_references_2/input.js
|
||||
drop_unused/unused_circular_references_3/input.js
|
||||
drop_unused/var_catch_toplevel/input.js
|
||||
|
@ -438,6 +438,7 @@ drop_unused/issue_t161_top_retain_7/input.js
|
||||
drop_unused/keep_fnames/input.js
|
||||
drop_unused/unused_block_decls/input.js
|
||||
drop_unused/unused_block_decls_in_catch/input.js
|
||||
drop_unused/unused_circular_references_1/input.js
|
||||
drop_unused/unused_class_which_extends_might_throw/input.js
|
||||
drop_unused/unused_class_which_might_throw/input.js
|
||||
drop_unused/unused_class_which_might_throw_2/input.js
|
||||
|
@ -216,6 +216,7 @@ struct Analyzer<'a> {
|
||||
#[derive(Debug, Default)]
|
||||
struct Scope<'a> {
|
||||
parent: Option<&'a Scope<'a>>,
|
||||
kind: ScopeKind,
|
||||
|
||||
bindings_affected_by_eval: AHashSet<Id>,
|
||||
found_direct_eval: bool,
|
||||
@ -235,6 +236,12 @@ enum ScopeKind {
|
||||
ArrowFn,
|
||||
}
|
||||
|
||||
impl Default for ScopeKind {
|
||||
fn default() -> Self {
|
||||
Self::Fn
|
||||
}
|
||||
}
|
||||
|
||||
impl Analyzer<'_> {
|
||||
fn with_ast_path<F>(&mut self, ids: Vec<Id>, op: F)
|
||||
where
|
||||
@ -327,6 +334,10 @@ impl Analyzer<'_> {
|
||||
.add_dep_edge(component.clone(), id.clone(), assign)
|
||||
}
|
||||
|
||||
if s.kind == ScopeKind::Fn && !s.ast_path.is_empty() {
|
||||
break;
|
||||
}
|
||||
|
||||
scope = s.parent;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
export function f(x, y) {
|
||||
function g() {
|
||||
return h();
|
||||
}
|
||||
function h() {
|
||||
return g();
|
||||
}
|
||||
return x + y;
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
export function f(x, y) {
|
||||
return x + y;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
export function f(x, y) {
|
||||
return x + y;
|
||||
}
|
Loading…
Reference in New Issue
Block a user