.describe("v", "Verbose")
.describe("V", "Print version number and exit.")
.describe("noerr", "Don't throw an error for unknown options in -c, -b or -m.")
+ .describe("bare-returns", "Allow return outside of functions. Useful when minifying CommonJS modules.")
.alias("p", "prefix")
.alias("o", "output")
.boolean("lint")
.boolean("V")
.boolean("noerr")
+ .boolean("bare-returns")
.wrap(80)
else {
try {
TOPLEVEL = UglifyJS.parse(code, {
- filename : file,
- toplevel : TOPLEVEL,
- expression : ARGS.expr,
+ filename : file,
+ toplevel : TOPLEVEL,
+ expression : ARGS.expr,
+ bare_returns : ARGS.bare_returns,
});
} catch(ex) {
if (ex instanceof UglifyJS.JS_Parse_Error) {
toplevel : null,
expression : false,
html5_comments : true,
+ bare_returns : false,
});
var S = {
return if_();
case "return":
- if (S.in_function == 0)
+ if (S.in_function == 0 && !options.bare_returns)
croak("'return' outside of function");
return new AST_Return({
value: ( is("punc", ";")