From 76df77c08c684bc49bebb35d6d527d90cea48108 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 28 Jun 2018 18:16:49 +0800 Subject: implement `directives` (#3203) fixes #3166 --- lib/compress.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/compress.js b/lib/compress.js index e347169e..70ee9363 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -54,6 +54,7 @@ function Compressor(options, false_by_default) { comparisons : !false_by_default, conditionals : !false_by_default, dead_code : !false_by_default, + directives : !false_by_default, drop_console : false, drop_debugger : !false_by_default, evaluate : !false_by_default, @@ -3264,8 +3265,10 @@ merge(Compressor.prototype, { /* -----[ optimizers ]----- */ + var directives = makePredicate(["use asm", "use strict"]); OPT(AST_Directive, function(self, compressor) { - if (compressor.has_directive(self.value) !== self) { + if (compressor.option("directives") + && (!directives[self.value] || compressor.has_directive(self.value) !== self)) { return make_node(AST_EmptyStatement, self); } return self; -- cgit v1.2.3