diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-06-28 18:16:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-28 18:16:49 +0800 |
commit | 76df77c08c684bc49bebb35d6d527d90cea48108 (patch) | |
tree | b9b81b75e4e0556cab728dccbcf82823c2bd0274 /lib | |
parent | 957d5537a80fcb4037df21f0dbe16391fd0424ad (diff) | |
download | tracifyjs-76df77c08c684bc49bebb35d6d527d90cea48108.tar.gz tracifyjs-76df77c08c684bc49bebb35d6d527d90cea48108.zip |
implement `directives` (#3203)
fixes #3166
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 5 |
1 files changed, 4 insertions, 1 deletions
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; |