Create and map bare-returns into new parse property name
* Following as much previous structure as possible... see analysis at https://github.com/mishoo/UglifyJS2/issues/935#issuecomment-180712909 * Using `undefined` as default since is technically assigned elsewhere * Note entirely sure if https://github.com/mishoo/UglifyJS2/blob/master/test/compress/return_undefined.js is the test for this or not * Change README.md to reflect and add additional sub-note about Userscript IIFE possibility Applies to mishoo/UglifyJS2#935
This commit is contained in:
parent
b5a7197ae5
commit
a13b7defd8
|
|
@ -125,7 +125,9 @@ The available options are:
|
||||||
--noerr Don't throw an error for unknown options in -c,
|
--noerr Don't throw an error for unknown options in -c,
|
||||||
-b or -m.
|
-b or -m.
|
||||||
--bare-returns Allow return outside of functions. Useful when
|
--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
|
--keep-fnames Do not mangle/drop function names. Useful for
|
||||||
code relying on Function.prototype.name.
|
code relying on Function.prototype.name.
|
||||||
--reserved-file File containing reserved names
|
--reserved-file File containing reserved names
|
||||||
|
|
@ -654,6 +656,8 @@ properties are available:
|
||||||
- `filename` — the name of the file where this code is coming from
|
- `filename` — the name of the file where this code is coming from
|
||||||
- `toplevel` — a `toplevel` node (as returned by a previous invocation of
|
- `toplevel` — a `toplevel` node (as returned by a previous invocation of
|
||||||
`parse`)
|
`parse`)
|
||||||
|
- `bare_returns` — Allow return outside of functions. (maps to the
|
||||||
|
`--bare-returns` CLI arguments option)
|
||||||
|
|
||||||
The last two options are useful when you'd like to minify multiple files and
|
The last two options are useful when you'd like to minify multiple files and
|
||||||
get a single file as the output and a proper source map. Our CLI tool does
|
get a single file as the output and a proper source map. Our CLI tool does
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@ exports.minify = function(files, options) {
|
||||||
warnings : false,
|
warnings : false,
|
||||||
mangle : {},
|
mangle : {},
|
||||||
output : null,
|
output : null,
|
||||||
compress : {}
|
compress : {},
|
||||||
|
parse : {}
|
||||||
});
|
});
|
||||||
UglifyJS.base54.reset();
|
UglifyJS.base54.reset();
|
||||||
|
|
||||||
|
|
@ -60,7 +61,8 @@ exports.minify = function(files, options) {
|
||||||
sourcesContent[file] = code;
|
sourcesContent[file] = code;
|
||||||
toplevel = UglifyJS.parse(code, {
|
toplevel = UglifyJS.parse(code, {
|
||||||
filename: options.fromString ? i : file,
|
filename: options.fromString ? i : file,
|
||||||
toplevel: toplevel
|
toplevel: toplevel,
|
||||||
|
bare_returns: options.parse ? options.parse.bare_returns : undefined
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user