diff --git a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithAnyOtherType_es5.2.minified.js b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithAnyOtherType_es5.2.minified.js index d23dd623407..a49abaabcfe 100644 --- a/crates/swc/tests/tsc-references/bitwiseNotOperatorWithAnyOtherType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/bitwiseNotOperatorWithAnyOtherType_es5.2.minified.js @@ -17,4 +17,4 @@ var M, ANY2 = [ M1.n = n; }(M || (M = {})); var objA = new A(); -ANY2[0], obj1.x, obj1.y, objA.a, M.n, A.foo(), ANY2[0], obj1.y, objA.a, M.n, obj1.x; +ANY2[0], obj1.y, objA.a, M.n, A.foo(), ANY2[0], obj1.y, objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/instanceMemberWithComputedPropertyName_es5.2.minified.js b/crates/swc/tests/tsc-references/instanceMemberWithComputedPropertyName_es5.2.minified.js index 07ae53288ad..0a5c962c920 100644 --- a/crates/swc/tests/tsc-references/instanceMemberWithComputedPropertyName_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/instanceMemberWithComputedPropertyName_es5.2.minified.js @@ -2,9 +2,4 @@ import * as swcHelpers from "@swc/helpers"; var C = function() { swcHelpers.classCallCheck(this, C), this[1] = !0; - var ref = { - a: 1, - b: 2 - }; - ref.a, ref.b; }; diff --git a/crates/swc/tests/tsc-references/keyofAndIndexedAccess2_es5.2.minified.js b/crates/swc/tests/tsc-references/keyofAndIndexedAccess2_es5.2.minified.js index e9aa7d44016..ef2c4a2dfcc 100644 --- a/crates/swc/tests/tsc-references/keyofAndIndexedAccess2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/keyofAndIndexedAccess2_es5.2.minified.js @@ -13,17 +13,17 @@ export var c = function() { "use strict"; swcHelpers.classCallCheck(this, c), this.a = "b", this.a = "b"; }; -var actions = [ - "resizeTo", - "resizeBy" -], _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0; +var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0; try { for(var _step, _loop = function(_iterator, _step) { var action = _step.value; window[action] = function(x, y) { window[action](x, y); }; - }, _iterator = actions[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)_loop(_iterator, _step); + }, _iterator = [ + "resizeTo", + "resizeBy" + ][Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0)_loop(_iterator, _step); } catch (err) { _didIteratorError = !0, _iteratorError = err; } finally{ diff --git a/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType_es5.2.minified.js b/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType_es5.2.minified.js index d3f5604df02..3ef441ab9c4 100644 --- a/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/logicalNotOperatorWithAnyOtherType_es5.2.minified.js @@ -2,10 +2,7 @@ import * as swcHelpers from "@swc/helpers"; var M, ANY2 = [ "", "" -], obj1 = { - x: "", - y: function() {} -}, A = function() { +], A = function() { "use strict"; function A() { swcHelpers.classCallCheck(this, A); @@ -17,4 +14,4 @@ var M, ANY2 = [ M1.n = n; }(M || (M = {})); var objA = new A(); -ANY2[0], obj1.x, obj1.y, objA.a, M.n, A.foo(), ANY2[0], objA.a, M.n; +ANY2[0], objA.a, M.n, A.foo(), ANY2[0], objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/negateOperatorWithAnyOtherType_es5.2.minified.js b/crates/swc/tests/tsc-references/negateOperatorWithAnyOtherType_es5.2.minified.js index d3f5604df02..3ef441ab9c4 100644 --- a/crates/swc/tests/tsc-references/negateOperatorWithAnyOtherType_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/negateOperatorWithAnyOtherType_es5.2.minified.js @@ -2,10 +2,7 @@ import * as swcHelpers from "@swc/helpers"; var M, ANY2 = [ "", "" -], obj1 = { - x: "", - y: function() {} -}, A = function() { +], A = function() { "use strict"; function A() { swcHelpers.classCallCheck(this, A); @@ -17,4 +14,4 @@ var M, ANY2 = [ M1.n = n; }(M || (M = {})); var objA = new A(); -ANY2[0], obj1.x, obj1.y, objA.a, M.n, A.foo(), ANY2[0], objA.a, M.n; +ANY2[0], objA.a, M.n, A.foo(), ANY2[0], objA.a, M.n; diff --git a/crates/swc/tests/tsc-references/parserRealSource14_es5.2.minified.js b/crates/swc/tests/tsc-references/parserRealSource14_es5.2.minified.js index 1b80a0a36f6..70d988a9a5e 100644 --- a/crates/swc/tests/tsc-references/parserRealSource14_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/parserRealSource14_es5.2.minified.js @@ -31,13 +31,13 @@ import * as swcHelpers from "@swc/helpers"; }; return TypeScript.getAstWalkerFactory().walk(script, pre), bestOffset; }, walkAST = function(ast, callback) { - var pre = function(cur, parent, walker) { + var path1 = new AstPath(); + TypeScript.getAstWalkerFactory().walk(ast, function(cur, parent, walker) { var path = walker.state; return path.push(cur), callback(path, walker), cur; - }, post = function(cur, parent, walker) { + }, function(cur, parent, walker) { return walker.state.pop(), cur; - }, path1 = new AstPath(); - TypeScript.getAstWalkerFactory().walk(ast, pre, post, null, path1); + }, null, path1); }; TypeScript1.lastOf = lastOf, TypeScript1.max = max, TypeScript1.min = function(a, b) { return a <= b ? a : b; diff --git a/crates/swc/tests/tsc-references/typeTagOnPropertyAssignment_es2015.2.minified.js b/crates/swc/tests/tsc-references/typeTagOnPropertyAssignment_es2015.2.minified.js index f1a95870711..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/typeTagOnPropertyAssignment_es2015.2.minified.js +++ b/crates/swc/tests/tsc-references/typeTagOnPropertyAssignment_es2015.2.minified.js @@ -1,5 +0,0 @@ -const o = { - a: "a", - n: ()=>'b' -}; -o.a, o.n; diff --git a/crates/swc/tests/tsc-references/typeTagOnPropertyAssignment_es5.2.minified.js b/crates/swc/tests/tsc-references/typeTagOnPropertyAssignment_es5.2.minified.js index 273facb3950..e69de29bb2d 100644 --- a/crates/swc/tests/tsc-references/typeTagOnPropertyAssignment_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/typeTagOnPropertyAssignment_es5.2.minified.js @@ -1,7 +0,0 @@ -var o = { - a: "a", - n: function() { - return "b"; - } -}; -o.a, o.n; diff --git a/crates/swc_ecma_minifier/src/analyzer/mod.rs b/crates/swc_ecma_minifier/src/analyzer/mod.rs index 22304c2fe36..79c52e4b9ee 100644 --- a/crates/swc_ecma_minifier/src/analyzer/mod.rs +++ b/crates/swc_ecma_minifier/src/analyzer/mod.rs @@ -4,7 +4,7 @@ use swc_common::{ SyntaxContext, }; use swc_ecma_ast::*; -use swc_ecma_utils::{find_ids, ident::IdentLike, Id, IsEmpty}; +use swc_ecma_utils::{collect_decls, find_ids, ident::IdentLike, Id, IsEmpty}; use swc_ecma_visit::{noop_visit_type, Visit, VisitWith}; use swc_timer::timer; @@ -964,8 +964,9 @@ where for decl in &n.decls { if let (Pat::Ident(var), Some(init)) = (&decl.name, decl.init.as_deref()) { let used_idents = idents_used_by(init); + let excluded: AHashSet = collect_decls(init); - for id in used_idents { + for id in used_idents.into_iter().filter(|id| !excluded.contains(id)) { self.data .var_or_default(id.clone()) .add_infects(var.to_id()); diff --git a/crates/swc_ecma_minifier/src/compress/optimize/hoist_props.rs b/crates/swc_ecma_minifier/src/compress/optimize/hoist_props.rs index f983232c972..0b75c1477a7 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/hoist_props.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/hoist_props.rs @@ -1,5 +1,5 @@ use swc_ecma_ast::*; -use swc_ecma_utils::ident::IdentLike; +use swc_ecma_utils::{contains_this_expr, ident::IdentLike}; use super::Optimizer; use crate::mode::Mode; @@ -28,12 +28,17 @@ where .get(&name.to_id()) .map(|v| { !v.mutated - && !v.reassigned_with_assignment - && !v.reassigned_with_var_decl + && v.mutation_by_call_count == 0 + && !v.used_as_arg + && !v.used_in_cond + && !v.reassigned() && !v.is_infected() }) .unwrap_or(false) { + if cfg!(feature = "debug") { + tracing::trace!("[x] bad usage"); + } return; } @@ -54,7 +59,12 @@ where if let Prop::KeyValue(p) = &**prop { match &*p.value { - Expr::Lit(..) => {} + Expr::Lit(..) | Expr::Arrow(..) => {} + Expr::Fn(f) => { + if contains_this_expr(&f.function.body) { + continue; + } + } _ => continue, }; @@ -72,6 +82,9 @@ where } if !unknown_used_props.is_empty() { + if cfg!(feature = "debug") { + tracing::trace!("[x] unknown used props: {:?}", unknown_used_props); + } return; } @@ -90,7 +103,7 @@ where match &p.key { PropName::Str(s) => { - tracing::trace!( + tracing::debug!( "hoist_props: Storing a variable (`{}`) to inline properties", name.id ); @@ -99,7 +112,7 @@ where self.mode.store(name.to_id(), n.init.as_deref().unwrap()); } PropName::Ident(i) => { - tracing::trace!( + tracing::debug!( "hoist_props: Storing a variable(`{}`) to inline properties", name.id ); @@ -121,8 +134,11 @@ where .map(|v| { v.ref_count == 1 && v.has_property_access + && !v.mutated + && v.mutation_by_call_count == 0 && v.is_fn_local && !v.executed_multiple_time + && !v.used_as_arg && !v.used_in_cond }) .unwrap_or(false) diff --git a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs index 5e96f3c86ff..940ca1b7151 100644 --- a/crates/swc_ecma_minifier/src/compress/optimize/mod.rs +++ b/crates/swc_ecma_minifier/src/compress/optimize/mod.rs @@ -203,9 +203,10 @@ struct Optimizer<'a, M> { simple_functions: FxHashMap>, vars_for_inlining: FxHashMap>, - vars_for_prop_hoisting: AHashMap>, /// Used for `hoist_props`. - simple_props: AHashMap<(Id, JsWord), Box>, + vars_for_prop_hoisting: FxHashMap>, + /// Used for `hoist_props`. + simple_props: FxHashMap<(Id, JsWord), Box>, _simple_array_values: AHashMap<(Id, usize), Box>, typeofs: AHashMap, /// This information is created by analyzing identifier usages. diff --git a/crates/swc_ecma_minifier/tests/TODO.txt b/crates/swc_ecma_minifier/tests/TODO.txt index b8f0b0ae8b6..05b9204a5e9 100644 --- a/crates/swc_ecma_minifier/tests/TODO.txt +++ b/crates/swc_ecma_minifier/tests/TODO.txt @@ -713,7 +713,6 @@ reduce_vars/unsafe_evaluate/input.js reduce_vars/unsafe_evaluate_array_2/input.js reduce_vars/unsafe_evaluate_array_4/input.js reduce_vars/unsafe_evaluate_modified/input.js -reduce_vars/unsafe_evaluate_object_2/input.js reduce_vars/unsafe_evaluate_side_effect_free_1/input.js reduce_vars/unsafe_evaluate_side_effect_free_2/input.js reduce_vars/unused_modified/input.js diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/analysis-snapshot.rust-debug index 31e4d89f727..7176e778bcc 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/analysis-snapshot.rust-debug @@ -139015,7 +139015,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -222439,7 +222439,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 0, mutation_by_call_count: 1, usage_count: 3, reassigned_with_assignment: false, @@ -222477,7 +222477,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 3, + assign_count: 1, mutation_by_call_count: 0, usage_count: 2, reassigned_with_assignment: true, @@ -222517,7 +222517,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 0, mutation_by_call_count: 1, usage_count: 3, reassigned_with_assignment: false, @@ -222555,7 +222555,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 3, + assign_count: 1, mutation_by_call_count: 0, usage_count: 2, reassigned_with_assignment: true, @@ -222595,12 +222595,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 3, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -222633,7 +222633,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 0, mutation_by_call_count: 1, usage_count: 3, reassigned_with_assignment: false, @@ -222671,12 +222671,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 1, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -334671,7 +334671,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 0, mutation_by_call_count: 2, usage_count: 3, reassigned_with_assignment: false, @@ -334709,7 +334709,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 0, mutation_by_call_count: 2, usage_count: 3, reassigned_with_assignment: false, @@ -342617,7 +342617,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 3, + assign_count: 1, mutation_by_call_count: 0, usage_count: 4, reassigned_with_assignment: true, @@ -342657,7 +342657,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 3, + assign_count: 1, mutation_by_call_count: 0, usage_count: 4, reassigned_with_assignment: true, @@ -406189,7 +406189,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -406227,7 +406227,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -406265,7 +406265,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -406303,7 +406303,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 2, usage_count: 6, reassigned_with_assignment: false, @@ -409215,7 +409215,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 0, mutation_by_call_count: 2, usage_count: 2, reassigned_with_assignment: false, @@ -409229,7 +409229,7 @@ TestSnapshot { is_fn_local: true, used_by_nested_fn: true, executed_multiple_time: false, - used_in_cond: true, + used_in_cond: false, var_kind: Some( "var", ), diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/issues/emotion/react/1/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/issues/emotion/react/1/analysis-snapshot.rust-debug index d4fa90def0d..03eb275f482 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/issues/emotion/react/1/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/issues/emotion/react/1/analysis-snapshot.rust-debug @@ -3795,7 +3795,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 1, mutation_by_call_count: 2, usage_count: 4, reassigned_with_assignment: true, @@ -3835,7 +3835,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 1, mutation_by_call_count: 2, usage_count: 4, reassigned_with_assignment: true, @@ -12193,12 +12193,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 1, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/issues/firebase-core/1/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/issues/firebase-core/1/analysis-snapshot.rust-debug index 3e16d3037e7..aa106b0949d 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/issues/firebase-core/1/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/issues/firebase-core/1/analysis-snapshot.rust-debug @@ -41561,12 +41561,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 1, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/issues/quagga2/1.4.2/1/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/issues/quagga2/1.4.2/1/analysis-snapshot.rust-debug index a74ac4a6979..422b54d9b35 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/issues/quagga2/1.4.2/1/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/issues/quagga2/1.4.2/1/analysis-snapshot.rust-debug @@ -45255,9 +45255,9 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, - usage_count: 2, + usage_count: 1, reassigned_with_assignment: false, reassigned_with_var_decl: false, mutated: true, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/issues/react-countup/1/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/issues/react-countup/1/analysis-snapshot.rust-debug index 8ea0f86a8d3..5b51923c552 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/issues/react-countup/1/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/issues/react-countup/1/analysis-snapshot.rust-debug @@ -6713,12 +6713,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 1, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/analysis-snapshot.rust-debug index c26cfe08c78..2de5152e762 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/next/31077/static/chunks/1606726a.10299989c08cb523/analysis-snapshot.rust-debug @@ -13119,12 +13119,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 1, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -23859,7 +23859,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 2, usage_count: 2, reassigned_with_assignment: false, @@ -23872,7 +23872,7 @@ TestSnapshot { used_above_decl: false, is_fn_local: true, used_by_nested_fn: true, - executed_multiple_time: true, + executed_multiple_time: false, used_in_cond: true, var_kind: None, var_initialized: false, @@ -30257,7 +30257,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 4, usage_count: 4, reassigned_with_assignment: false, @@ -30270,7 +30270,7 @@ TestSnapshot { used_above_decl: false, is_fn_local: false, used_by_nested_fn: true, - executed_multiple_time: true, + executed_multiple_time: false, used_in_cond: true, var_kind: None, var_initialized: false, @@ -32481,7 +32481,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 1, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: true, @@ -32494,7 +32494,7 @@ TestSnapshot { used_above_decl: false, is_fn_local: true, used_by_nested_fn: true, - executed_multiple_time: true, + executed_multiple_time: false, used_in_cond: true, var_kind: Some( "var", @@ -35191,7 +35191,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 1, mutation_by_call_count: 1, usage_count: 3, reassigned_with_assignment: true, @@ -35204,7 +35204,7 @@ TestSnapshot { used_above_decl: false, is_fn_local: false, used_by_nested_fn: true, - executed_multiple_time: true, + executed_multiple_time: false, used_in_cond: true, var_kind: Some( "var", @@ -58799,7 +58799,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 1, mutation_by_call_count: 3, usage_count: 14, reassigned_with_assignment: true, @@ -58812,7 +58812,7 @@ TestSnapshot { used_above_decl: false, is_fn_local: false, used_by_nested_fn: true, - executed_multiple_time: true, + executed_multiple_time: false, used_in_cond: true, var_kind: Some( "var", diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/analysis-snapshot.rust-debug index 734551b7b2b..a18e114c835 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/d6e1aeb5-38a8d7ae57119c23/analysis-snapshot.rust-debug @@ -21847,7 +21847,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 1, mutation_by_call_count: 2, usage_count: 4, reassigned_with_assignment: true, @@ -51833,7 +51833,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 4, + assign_count: 2, mutation_by_call_count: 2, usage_count: 2, reassigned_with_assignment: true, @@ -74865,9 +74865,9 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, - usage_count: 2, + usage_count: 1, reassigned_with_assignment: false, reassigned_with_var_decl: false, mutated: true, @@ -148969,7 +148969,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -149325,12 +149325,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, - usage_count: 2, + usage_count: 1, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -212685,12 +212685,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 1, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -228415,7 +228415,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 0, mutation_by_call_count: 1, usage_count: 9, reassigned_with_assignment: false, @@ -243887,12 +243887,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 1, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -243963,12 +243963,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 1, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -244001,12 +244001,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 1, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -244039,12 +244039,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 2, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -244077,12 +244077,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 2, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -328421,7 +328421,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/analysis-snapshot.rust-debug index 9e1f14161d4..8eb35d25c0b 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/analysis-snapshot.rust-debug @@ -27197,7 +27197,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 4, + assign_count: 3, mutation_by_call_count: 3, usage_count: 4, reassigned_with_assignment: true, @@ -28659,7 +28659,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 4, + assign_count: 3, mutation_by_call_count: 1, usage_count: 7, reassigned_with_assignment: true, @@ -54279,7 +54279,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 5, + assign_count: 4, mutation_by_call_count: 6, usage_count: 9, reassigned_with_assignment: true, @@ -55299,7 +55299,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 3, + assign_count: 2, mutation_by_call_count: 1, usage_count: 3, reassigned_with_assignment: true, @@ -88933,7 +88933,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -92853,7 +92853,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 5, usage_count: 5, reassigned_with_assignment: false, @@ -93007,7 +93007,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 2, usage_count: 3, reassigned_with_assignment: false, @@ -101097,7 +101097,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 2, reassigned_with_assignment: false, @@ -107197,7 +107197,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 3, + assign_count: 2, mutation_by_call_count: 2, usage_count: 3, reassigned_with_assignment: true, @@ -113311,7 +113311,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 3, + assign_count: 2, mutation_by_call_count: 1, usage_count: 2, reassigned_with_assignment: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/next/feedback-2/codemirror/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/next/feedback-2/codemirror/analysis-snapshot.rust-debug index f712c5ed5d9..805f427bb5d 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/next/feedback-2/codemirror/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/next/feedback-2/codemirror/analysis-snapshot.rust-debug @@ -10887,7 +10887,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -38467,7 +38467,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 2, usage_count: 5, reassigned_with_assignment: false, @@ -38480,7 +38480,7 @@ TestSnapshot { used_above_decl: false, is_fn_local: true, used_by_nested_fn: true, - executed_multiple_time: true, + executed_multiple_time: false, used_in_cond: true, var_kind: None, var_initialized: false, @@ -114061,7 +114061,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 2, reassigned_with_assignment: false, @@ -114074,7 +114074,7 @@ TestSnapshot { used_above_decl: false, is_fn_local: false, used_by_nested_fn: true, - executed_multiple_time: true, + executed_multiple_time: false, used_in_cond: true, var_kind: Some( "var", @@ -121701,7 +121701,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -121714,8 +121714,8 @@ TestSnapshot { used_above_decl: false, is_fn_local: true, used_by_nested_fn: true, - executed_multiple_time: true, - used_in_cond: true, + executed_multiple_time: false, + used_in_cond: false, var_kind: None, var_initialized: false, declared_as_catch_param: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/next/feedback-util-promisify/chunks/pages/_app-72ad41192608e93a/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/next/feedback-util-promisify/chunks/pages/_app-72ad41192608e93a/analysis-snapshot.rust-debug index 174cf37f9fb..d65c85ef6aa 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/next/feedback-util-promisify/chunks/pages/_app-72ad41192608e93a/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/next/feedback-util-promisify/chunks/pages/_app-72ad41192608e93a/analysis-snapshot.rust-debug @@ -41855,7 +41855,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 0, mutation_by_call_count: 4, usage_count: 4, reassigned_with_assignment: false, @@ -41868,7 +41868,7 @@ TestSnapshot { used_above_decl: false, is_fn_local: true, used_by_nested_fn: true, - executed_multiple_time: true, + executed_multiple_time: false, used_in_cond: true, var_kind: None, var_initialized: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/analysis-snapshot.rust-debug index 9a0566d3daf..1e8bac04282 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/next/react-ace/chunks/8a28b14e.d8fbda268ed281a1/analysis-snapshot.rust-debug @@ -11197,7 +11197,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 8, usage_count: 8, reassigned_with_assignment: false, @@ -12321,7 +12321,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 1, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: true, @@ -16753,7 +16753,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 1, mutation_by_call_count: 1, usage_count: 2, reassigned_with_assignment: true, @@ -19807,7 +19807,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -49047,12 +49047,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 1, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -81911,7 +81911,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 3, usage_count: 3, reassigned_with_assignment: false, @@ -81949,7 +81949,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 2, usage_count: 2, reassigned_with_assignment: false, @@ -81987,7 +81987,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 1, mutation_by_call_count: 0, usage_count: 3, reassigned_with_assignment: true, @@ -82027,7 +82027,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -82065,7 +82065,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 2, usage_count: 2, reassigned_with_assignment: false, @@ -82103,12 +82103,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -82117,7 +82117,7 @@ TestSnapshot { is_fn_local: true, used_by_nested_fn: true, executed_multiple_time: false, - used_in_cond: true, + used_in_cond: false, var_kind: None, var_initialized: false, declared_as_catch_param: false, @@ -102293,7 +102293,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 2, usage_count: 3, reassigned_with_assignment: false, @@ -102331,12 +102331,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 4, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -102369,7 +102369,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -102445,7 +102445,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 2, usage_count: 2, reassigned_with_assignment: false, @@ -102483,7 +102483,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -102521,12 +102521,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 2, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -106959,7 +106959,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 3, + assign_count: 2, mutation_by_call_count: 0, usage_count: 3, reassigned_with_assignment: true, @@ -111555,7 +111555,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -166057,7 +166057,7 @@ TestSnapshot { declared_count: 2, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 4, + assign_count: 3, mutation_by_call_count: 0, usage_count: 5, reassigned_with_assignment: true, @@ -176587,7 +176587,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -192241,7 +192241,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 2, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, @@ -192254,8 +192254,8 @@ TestSnapshot { used_above_decl: false, is_fn_local: true, used_by_nested_fn: true, - executed_multiple_time: true, - used_in_cond: true, + executed_multiple_time: false, + used_in_cond: false, var_kind: None, var_initialized: false, declared_as_catch_param: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/chunkfilename-b114cf1d23876beaa712/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/chunkfilename-b114cf1d23876beaa712/analysis-snapshot.rust-debug index 1d2fe7daef2..22360009c64 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/chunkfilename-b114cf1d23876beaa712/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/chunkfilename-b114cf1d23876beaa712/analysis-snapshot.rust-debug @@ -2335,12 +2335,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 3, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -3339,12 +3339,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -4039,12 +4039,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -5891,7 +5891,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/function-7fe8439c89afccb77983/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/function-7fe8439c89afccb77983/analysis-snapshot.rust-debug index 1d2fe7daef2..22360009c64 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/function-7fe8439c89afccb77983/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/function-7fe8439c89afccb77983/analysis-snapshot.rust-debug @@ -2335,12 +2335,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 3, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -3339,12 +3339,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -4039,12 +4039,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -5891,7 +5891,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/head-432fc3a9a66c90ce2ec2/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/head-432fc3a9a66c90ce2ec2/analysis-snapshot.rust-debug index 2da07a34e14..fe61cc0e6f8 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/head-432fc3a9a66c90ce2ec2/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/head-432fc3a9a66c90ce2ec2/analysis-snapshot.rust-debug @@ -2913,12 +2913,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 3, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -4185,12 +4185,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -5041,12 +5041,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -7047,7 +7047,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/multiple-modules-d02ebebcfa5282e50b34/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/multiple-modules-d02ebebcfa5282e50b34/analysis-snapshot.rust-debug index 36a83bb8418..538b3656234 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/multiple-modules-d02ebebcfa5282e50b34/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/multiple-modules-d02ebebcfa5282e50b34/analysis-snapshot.rust-debug @@ -2375,12 +2375,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 3, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -3379,12 +3379,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -4079,12 +4079,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -5931,7 +5931,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/nested-05a7ce04b1f7eb6da341/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/nested-05a7ce04b1f7eb6da341/analysis-snapshot.rust-debug index 923f2028ac0..aef719ca426 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/nested-05a7ce04b1f7eb6da341/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/nested-05a7ce04b1f7eb6da341/analysis-snapshot.rust-debug @@ -2335,12 +2335,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 3, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -3339,12 +3339,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -4039,12 +4039,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -5891,7 +5891,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/no-chunk-e2d9573b8d7df68a6cde/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/no-chunk-e2d9573b8d7df68a6cde/analysis-snapshot.rust-debug index bb6f8201dd0..58ba4f38d6c 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/no-chunk-e2d9573b8d7df68a6cde/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/no-chunk-e2d9573b8d7df68a6cde/analysis-snapshot.rust-debug @@ -4563,12 +4563,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 3, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -6071,12 +6071,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -6889,12 +6889,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -9239,7 +9239,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/no-ssr-9ced90e71a0d75a11cdd/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/no-ssr-9ced90e71a0d75a11cdd/analysis-snapshot.rust-debug index 1d2fe7daef2..22360009c64 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/no-ssr-9ced90e71a0d75a11cdd/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/no-ssr-9ced90e71a0d75a11cdd/analysis-snapshot.rust-debug @@ -2335,12 +2335,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 3, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -3339,12 +3339,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -4039,12 +4039,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -5891,7 +5891,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/no-ssr-custom-loading-7f61b2e27708ca1854e0/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/no-ssr-custom-loading-7f61b2e27708ca1854e0/analysis-snapshot.rust-debug index 70b6e9683d2..61ff8a47435 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/no-ssr-custom-loading-7f61b2e27708ca1854e0/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/no-ssr-custom-loading-7f61b2e27708ca1854e0/analysis-snapshot.rust-debug @@ -2335,12 +2335,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 3, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -3339,12 +3339,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -4039,12 +4039,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -5929,7 +5929,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/ssr-994266264fb6ff57d32c/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/ssr-994266264fb6ff57d32c/analysis-snapshot.rust-debug index 1d2fe7daef2..22360009c64 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/ssr-994266264fb6ff57d32c/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/ssr-994266264fb6ff57d32c/analysis-snapshot.rust-debug @@ -2335,12 +2335,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 3, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -3339,12 +3339,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -4039,12 +4039,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -5891,7 +5891,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/ssr-true-6d4aa8fc503b9d073aef/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/ssr-true-6d4aa8fc503b9d073aef/analysis-snapshot.rust-debug index 1d2fe7daef2..22360009c64 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/ssr-true-6d4aa8fc503b9d073aef/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/projects/next/archive-3/pages/dynamic/ssr-true-6d4aa8fc503b9d073aef/analysis-snapshot.rust-debug @@ -2335,12 +2335,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 3, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, @@ -3339,12 +3339,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -4039,12 +4039,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 0, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {}, @@ -5891,7 +5891,7 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: false, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 1, usage_count: 1, reassigned_with_assignment: false, diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/projects/wmr/archive-1/chunks/hoofd.module.6c5395cb/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/compress/fixture/projects/wmr/archive-1/chunks/hoofd.module.6c5395cb/analysis-snapshot.rust-debug index 460f8a89752..17aad3e2148 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/projects/wmr/archive-1/chunks/hoofd.module.6c5395cb/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/compress/fixture/projects/wmr/archive-1/chunks/hoofd.module.6c5395cb/analysis-snapshot.rust-debug @@ -2083,12 +2083,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 8, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: true, has_property_mutation: false, accessed_props: {}, diff --git a/crates/swc_ecma_minifier/tests/golden.txt b/crates/swc_ecma_minifier/tests/golden.txt index 222b4dae01b..274b500db7b 100644 --- a/crates/swc_ecma_minifier/tests/golden.txt +++ b/crates/swc_ecma_minifier/tests/golden.txt @@ -1187,6 +1187,7 @@ reduce_vars/unsafe_evaluate_array_3/input.js reduce_vars/unsafe_evaluate_array_5/input.js reduce_vars/unsafe_evaluate_escaped/input.js reduce_vars/unsafe_evaluate_object_1/input.js +reduce_vars/unsafe_evaluate_object_2/input.js reduce_vars/unsafe_evaluate_object_3/input.js reduce_vars/unsafe_evaluate_unknown/input.js reduce_vars/use_before_var/input.js diff --git a/crates/swc_ecma_minifier/tests/projects/output/yui-3.12.0.js b/crates/swc_ecma_minifier/tests/projects/output/yui-3.12.0.js index 084d0053696..af013cd6689 100644 --- a/crates/swc_ecma_minifier/tests/projects/output/yui-3.12.0.js +++ b/crates/swc_ecma_minifier/tests/projects/output/yui-3.12.0.js @@ -24,7 +24,7 @@ var YUI = function() { }, handleLoad = function() { YUI.Env.windowLoaded = !0, YUI.Env.DOMReady = !0, hasWin && remove(window, 'load', handleLoad); }, getLoader = function(Y, o) { - var G_ENV, loader = Y.Env._loader, lCore = [ + var loader = Y.Env._loader, lCore = [ 'loader-base' ], mods = YUI.Env.mods; return loader ? (loader.ignoreRegistered = !1, loader.onEnd = null, loader.data = null, loader.required = [], loader.loadType = null) : (loader = new Y.Loader(Y.config), Y.Env._loader = loader), mods && mods.loader && (lCore = [].concat(lCore, YUI.Env.loaderExtras)), YUI.Env.core = Y.Array.dedupe([].concat(YUI.Env.core, lCore)), loader; diff --git a/crates/swc_ecma_minifier/tests/terser/compress/async/issue_3079/analysis-snapshot.rust-debug b/crates/swc_ecma_minifier/tests/terser/compress/async/issue_3079/analysis-snapshot.rust-debug index 4008e9725e8..e271855d2f6 100644 --- a/crates/swc_ecma_minifier/tests/terser/compress/async/issue_3079/analysis-snapshot.rust-debug +++ b/crates/swc_ecma_minifier/tests/terser/compress/async/issue_3079/analysis-snapshot.rust-debug @@ -91,12 +91,12 @@ TestSnapshot { declared_count: 1, declared_as_fn_param: true, declared_as_fn_expr: false, - assign_count: 1, + assign_count: 0, mutation_by_call_count: 0, usage_count: 1, reassigned_with_assignment: false, reassigned_with_var_decl: false, - mutated: true, + mutated: false, has_property_access: false, has_property_mutation: false, accessed_props: {},