diff --git a/lib/compress/index.js b/lib/compress/index.js index 80a0f615e..9c0fb5f2c 100644 --- a/lib/compress/index.js +++ b/lib/compress/index.js @@ -7469,7 +7469,7 @@ def_optimize(AST_Array, function(self, compressor) { return self; }); -function inline_object_prop_spread(props) { +function inline_object_prop_spread(props, compressor) { for (var i = 0; i < props.length; i++) { var prop = props[i]; if (prop instanceof AST_Expansion) { @@ -7487,6 +7487,9 @@ function inline_object_prop_spread(props) { // non-iterable value silently does nothing; it is thus safe // to remove. AST_String is the only iterable AST_Constant. props.splice(i, 1); + } else if (is_nullish(expr, compressor)) { + // Likewise, null and undefined can be silently removed. + props.splice(i, 1); } } } @@ -7497,7 +7500,7 @@ def_optimize(AST_Object, function(self, compressor) { if (optimized !== self) { return optimized; } - inline_object_prop_spread(self.properties); + inline_object_prop_spread(self.properties, compressor); return self; });