diff options
author | Mihai Bazon <mihai@bazon.net> | 2013-05-22 21:22:14 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2013-05-22 21:22:14 +0300 |
commit | 9fc6796d2a5f385500efc84020b5f6f73a6bb4a0 (patch) | |
tree | b49a78f8cc7f8efc0ddc83e7eb30dc06202764d9 | |
parent | 9fc8a52142041b903b650923bb08b57876dd4c8c (diff) | |
download | tracifyjs-9fc6796d2a5f385500efc84020b5f6f73a6bb4a0.tar.gz tracifyjs-9fc6796d2a5f385500efc84020b5f6f73a6bb4a0.zip |
Add `negate_iife` option to the code generator.
See discussion in a9511dfbe5c0d96d8cacb87582aa9a19737bbb98
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | lib/output.js | 5 |
2 files changed, 7 insertions, 2 deletions
@@ -287,6 +287,10 @@ can pass additional arguments that control the code output: you pass `false` then whenever possible we will use a newline instead of a semicolon, leading to more readable output of uglified code (size before gzip could be smaller; size after gzip insignificantly larger). +- `negate-iife` (default `!beautify`) -- prefer negation, rather than + parens, for "Immediately-Called Function Expressions". This defaults to + `true` when beautification is off, and `false` if beautification is on; + pass it manually to force a value. ### Keeping copyright notices or other comments diff --git a/lib/output.js b/lib/output.js index b510cb35..60a4a26c 100644 --- a/lib/output.js +++ b/lib/output.js @@ -60,7 +60,8 @@ function OutputStream(options) { bracketize : false, semicolons : true, comments : false, - preserve_line : false + preserve_line : false, + negate_iife : !(options && options.beautify), }, true); var indentation = 0; @@ -352,7 +353,7 @@ function OutputStream(options) { var self = this, generator = self._codegen; stream.push_node(self); var needs_parens = self.needs_parens(stream); - var fc = self instanceof AST_Function && !stream.option("beautify"); + var fc = self instanceof AST_Function && stream.option("negate_iife"); if (force_parens || (needs_parens && !fc)) { stream.with_parens(function(){ self.add_comments(stream); |