From 5d9fb88856b977f3d59708fefe9d8a95134ceb84 Mon Sep 17 00:00:00 2001 From: kzc Date: Tue, 5 Sep 2017 19:21:16 -0400 Subject: [PATCH] add `Date` to known globals for `unsafe` compress option --- lib/compress.js | 2 +- test/compress/dead-code.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index 6e766fb0..7c60b763 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -693,7 +693,7 @@ merge(Compressor.prototype, { return node instanceof AST_SymbolRef && node.definition().undeclared; } - var global_names = makePredicate("Array Boolean console Error Function Math Number RegExp Object String"); + var global_names = makePredicate("Array Boolean console Date Error Function Math Number RegExp Object String"); AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) { return !this.definition().undeclared || compressor.option("unsafe") && global_names(this.name); diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js index abf5297c..bee7994e 100644 --- a/test/compress/dead-code.js +++ b/test/compress/dead-code.js @@ -241,6 +241,7 @@ issue_2233_1: { Array.isArray; Boolean; console.log; + Date; Error.name; Function.length; Math.random;