Merge remote-tracking branch 'upstream/master' into ternary-improvements

This commit is contained in:
Tal Ater 2014-12-07 19:37:13 +02:00
commit 0702f083c8
3 changed files with 9 additions and 5 deletions

View File

@ -64,6 +64,7 @@ You need to pass an argument to this option to specify the name that your module
.describe("v", "Verbose") .describe("v", "Verbose")
.describe("V", "Print version number and exit.") .describe("V", "Print version number and exit.")
.describe("noerr", "Don't throw an error for unknown options in -c, -b or -m.") .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("p", "prefix")
.alias("o", "output") .alias("o", "output")
@ -100,6 +101,7 @@ You need to pass an argument to this option to specify the name that your module
.boolean("lint") .boolean("lint")
.boolean("V") .boolean("V")
.boolean("noerr") .boolean("noerr")
.boolean("bare-returns")
.wrap(80) .wrap(80)
@ -275,9 +277,10 @@ async.eachLimit(files, 1, function (file, cb) {
else { else {
try { try {
TOPLEVEL = UglifyJS.parse(code, { TOPLEVEL = UglifyJS.parse(code, {
filename : file, filename : file,
toplevel : TOPLEVEL, toplevel : TOPLEVEL,
expression : ARGS.expr, expression : ARGS.expr,
bare_returns : ARGS.bare_returns,
}); });
} catch(ex) { } catch(ex) {
if (ex instanceof UglifyJS.JS_Parse_Error) { if (ex instanceof UglifyJS.JS_Parse_Error) {

View File

@ -609,6 +609,7 @@ function parse($TEXT, options) {
toplevel : null, toplevel : null,
expression : false, expression : false,
html5_comments : true, html5_comments : true,
bare_returns : false,
}); });
var S = { var S = {
@ -788,7 +789,7 @@ function parse($TEXT, options) {
return if_(); return if_();
case "return": case "return":
if (S.in_function == 0) if (S.in_function == 0 && !options.bare_returns)
croak("'return' outside of function"); croak("'return' outside of function");
return new AST_Return({ return new AST_Return({
value: ( is("punc", ";") value: ( is("punc", ";")

View File

@ -70,7 +70,7 @@ function SourceMap(options) {
source = info.source; source = info.source;
orig_line = info.line; orig_line = info.line;
orig_col = info.column; orig_col = info.column;
name = info.name; name = info.name || name;
} }
generator.addMapping({ generator.addMapping({
generated : { line: gen_line + options.dest_line_diff, column: gen_col }, generated : { line: gen_line + options.dest_line_diff, column: gen_col },