From: b-fuze Date: Sat, 31 Mar 2018 11:26:40 +0000 (-0400) Subject: Don't load source map until the JS source is fully received (#3040) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=8adfc29f914efd2af62638491b6c3034e1cc8712;p=UglifyJS.git Don't load source map until the JS source is fully received (#3040) --- diff --git a/bin/uglifyjs b/bin/uglifyjs index 2ff1feb7..7617d781 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -46,7 +46,7 @@ program.option("--name-cache ", "File to hold mangled name mappings."); program.option("--rename", "Force symbol expansion."); program.option("--no-rename", "Disable symbol expansion."); program.option("--self", "Build UglifyJS as a library (implies --wrap UglifyJS)"); -program.option("--source-map [options]", "Enable source map/specify source map options.", parse_source_map()); +program.option("--source-map [options]", "Enable source map/specify source map options.", parse_js()); program.option("--timings", "Display operations run time on STDERR.") program.option("--toplevel", "Compress and/or mangle variables in toplevel scope."); program.option("--verbose", "Print diagnostic messages."); @@ -176,6 +176,11 @@ function run() { UglifyJS.AST_Node.warn_function = function(msg) { print_error("WARN: " + msg); }; + var content = program.sourceMap && program.sourceMap.content; + if (content && content != "inline") { + print_error("INFO: Using input source map: " + content); + options.sourceMap.content = read_file(content, content); + } if (program.timings) options.timings = true; try { if (program.parse) { @@ -377,19 +382,6 @@ function parse_js(flag) { } } -function parse_source_map() { - var parse = parse_js(); - return function(value, options) { - var hasContent = options && "content" in options; - var settings = parse(value, options); - if (!hasContent && settings.content && settings.content != "inline") { - print_error("INFO: Using input source map: " + settings.content); - settings.content = read_file(settings.content, settings.content); - } - return settings; - } -} - function skip_key(key) { return skip_keys.indexOf(key) >= 0; } diff --git a/test/input/pr-3040/expect.js b/test/input/pr-3040/expect.js new file mode 100644 index 00000000..b911f3f8 --- /dev/null +++ b/test/input/pr-3040/expect.js @@ -0,0 +1,2 @@ +function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i