From 6bf36b73ef0463e54b4bb76e23746390de669062 Mon Sep 17 00:00:00 2001 From: pborunda Date: Sat, 25 Feb 2017 10:34:26 -0700 Subject: [PATCH] Add drop_error to new Error Apply option to new Error also --- lib/compress.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/compress.js b/lib/compress.js index 9e07e724..0f0cee36 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2627,6 +2627,23 @@ merge(Compressor.prototype, { }); OPT(AST_New, function(self, compressor){ + + if (compressor.option("drop_error")) { + var exp = self.expression; + if (exp instanceof AST_SymbolRef + && (exp.name == "Error" || + exp.name == "EvalError" || + exp.name == "InternalError" || + exp.name == "RangeError" || + exp.name == "ReferenceError" || + exp.name == "SyntaxError" || + exp.name == "TypeError" || + exp.name == "URIError") + && exp.undeclared()) { + // drop error description(s) + self.args = []; + } + } if (compressor.option("unsafe")) { var exp = self.expression; if (exp instanceof AST_SymbolRef && exp.undeclared()) {