aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartii <thalamew@q.com>2016-02-06 12:46:18 -0700
committerRichard van Velzen <rvanvelzen@experty.com>2016-02-08 10:45:42 +0100
commitcdba43cfa44c15fe12f87c356dad4caa5a946b5b (patch)
tree492cd3c96bc14b962877e05e74be1dc63d618462
parenta123e232b9e4d2fdc3905016fb56b71c5ab3ffcc (diff)
downloadtracifyjs-cdba43cfa44c15fe12f87c356dad4caa5a946b5b.tar.gz
tracifyjs-cdba43cfa44c15fe12f87c356dad4caa5a946b5b.zip
Create and map `bare-returns` into new `parse` property name
-rw-r--r--README.md11
-rw-r--r--tools/node.js6
2 files changed, 14 insertions, 3 deletions
diff --git a/README.md b/README.md
index 4bd1cab5..a145bb6c 100644
--- a/README.md
+++ b/README.md
@@ -125,7 +125,9 @@ The available options are:
--noerr Don't throw an error for unknown options in -c,
-b or -m.
--bare-returns Allow return outside of functions. Useful when
- minifying CommonJS modules.
+ minifying CommonJS modules and Userscripts that
+ may be anonymous function wrapped (IIFE) by the
+ .user.js engine `caller`.
--keep-fnames Do not mangle/drop function names. Useful for
code relying on Function.prototype.name.
--reserved-file File containing reserved names
@@ -636,6 +638,9 @@ Other options:
- `compress` (default `{}`) — pass `false` to skip compressing entirely.
Pass an object to specify custom [compressor options][compressor].
+- `parse` (default {}) — pass an object if you wish to specify some
+ additional [parser options][parser]. (not all options available... see below)
+
##### mangleProperties options
- `regex` — Pass a RegExp to only mangle certain names (maps to the `--mange-regex` CLI arguments option)
@@ -658,6 +663,9 @@ properties are available:
- `strict` — disable automatic semicolon insertion and support for trailing
comma in arrays and objects
+- `bare_returns` — Allow return outside of functions. (maps to the
+ `--bare-returns` CLI arguments option and available to `minify` `parse`
+ other options object)
- `filename` — the name of the file where this code is coming from
- `toplevel` — a `toplevel` node (as returned by a previous invocation of
`parse`)
@@ -797,3 +805,4 @@ The `source_map_options` (optional) can contain the following properties:
[sm-spec]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit
[codegen]: http://lisperator.net/uglifyjs/codegen
[compressor]: http://lisperator.net/uglifyjs/compress
+ [parser]: http://lisperator.net/uglifyjs/parser
diff --git a/tools/node.js b/tools/node.js
index 5764286e..fa8c19dc 100644
--- a/tools/node.js
+++ b/tools/node.js
@@ -42,7 +42,8 @@ exports.minify = function(files, options) {
mangleProperties : false,
nameCache : null,
output : null,
- compress : {}
+ compress : {},
+ parse : {}
});
UglifyJS.base54.reset();
@@ -62,7 +63,8 @@ exports.minify = function(files, options) {
sourcesContent[file] = code;
toplevel = UglifyJS.parse(code, {
filename: options.fromString ? i : file,
- toplevel: toplevel
+ toplevel: toplevel,
+ bare_returns: options.parse ? options.parse.bare_returns : undefined
});
});
}