terser 5.3.3 → 5.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/bundle.min.js +17 -13
- package/dist/bundle.min.js.map +1 -1
- package/lib/compress/index.js +17 -13
- package/package.json +1 -1
package/lib/compress/index.js
CHANGED
@@ -4140,9 +4140,12 @@ AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
|
|
4140
4140
|
hoisted.push(node);
|
4141
4141
|
return make_node(AST_EmptyStatement, node);
|
4142
4142
|
}
|
4143
|
-
if (
|
4143
|
+
if (
|
4144
|
+
hoist_vars
|
4145
|
+
&& node instanceof AST_Var
|
4146
|
+
&& !node.definitions.some(def => def.name instanceof AST_Destructuring)
|
4147
|
+
) {
|
4144
4148
|
node.definitions.forEach(function(def) {
|
4145
|
-
if (def.name instanceof AST_Destructuring) return;
|
4146
4149
|
vars.set(def.name.name, def);
|
4147
4150
|
++vars_found;
|
4148
4151
|
});
|
@@ -4222,8 +4225,7 @@ AST_Scope.DEFMETHOD("hoist_declarations", function(compressor) {
|
|
4222
4225
|
continue;
|
4223
4226
|
}
|
4224
4227
|
if (self.body[i] instanceof AST_BlockStatement) {
|
4225
|
-
|
4226
|
-
self.body.splice.apply(self.body, tmp);
|
4228
|
+
self.body.splice(i, 1, ...self.body[i].body);
|
4227
4229
|
continue;
|
4228
4230
|
}
|
4229
4231
|
break;
|
@@ -4969,10 +4971,12 @@ AST_Definitions.DEFMETHOD("remove_initializers", function() {
|
|
4969
4971
|
|
4970
4972
|
AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
|
4971
4973
|
var reduce_vars = compressor.option("reduce_vars");
|
4972
|
-
var assignments =
|
4973
|
-
|
4974
|
+
var assignments = [];
|
4975
|
+
|
4976
|
+
for (const def of this.definitions) {
|
4977
|
+
if (def.value) {
|
4974
4978
|
var name = make_node(AST_SymbolRef, def.name, def.name);
|
4975
|
-
|
4979
|
+
assignments.push(make_node(AST_Assign, def, {
|
4976
4980
|
operator : "=",
|
4977
4981
|
left : name,
|
4978
4982
|
right : def.value
|
@@ -4987,13 +4991,13 @@ AST_Definitions.DEFMETHOD("to_assignments", function(compressor) {
|
|
4987
4991
|
var var_ = make_node(AST_Var, def, {
|
4988
4992
|
definitions: [ varDef ]
|
4989
4993
|
});
|
4990
|
-
|
4994
|
+
assignments.push(var_);
|
4991
4995
|
}
|
4992
|
-
|
4993
|
-
|
4994
|
-
|
4995
|
-
|
4996
|
-
|
4996
|
+
const thedef = def.name.definition();
|
4997
|
+
thedef.eliminated++;
|
4998
|
+
thedef.replaced--;
|
4999
|
+
}
|
5000
|
+
|
4997
5001
|
if (assignments.length == 0) return null;
|
4998
5002
|
return make_sequence(this, assignments);
|
4999
5003
|
});
|