aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-06-28 18:16:49 +0800
committerGitHub <noreply@github.com>2018-06-28 18:16:49 +0800
commit76df77c08c684bc49bebb35d6d527d90cea48108 (patch)
treeb9b81b75e4e0556cab728dccbcf82823c2bd0274 /lib
parent957d5537a80fcb4037df21f0dbe16391fd0424ad (diff)
downloadtracifyjs-76df77c08c684bc49bebb35d6d527d90cea48108.tar.gz
tracifyjs-76df77c08c684bc49bebb35d6d527d90cea48108.zip
implement `directives` (#3203)
fixes #3166
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js5
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;