From: Mihai Bazon Date: Mon, 8 Oct 2012 09:52:25 +0000 (+0300) Subject: for certain nodes that we invent we might not have a original source file to X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=80a18fe2fa60d8a689516b921a386839d30b6abe;p=UglifyJS.git for certain nodes that we invent we might not have a original source file to map from, so just use "?". and in any case, don't fail hard when addMapping throws. --- diff --git a/lib/output.js b/lib/output.js index 09721625..b0a01613 100644 --- a/lib/output.js +++ b/lib/output.js @@ -248,12 +248,23 @@ function OutputStream(options) { }; var add_mapping = options.source_map ? function(token, name) { - options.source_map.add( - token.file, - current_line, current_col, - token.line, token.col, - (!name && token.type == "name") ? token.value : name - ); + try { + if (token) options.source_map.add( + token.file || "?", + current_line, current_col, + token.line, token.col, + (!name && token.type == "name") ? token.value : name + ); + } catch(ex) { + AST_Node.warn("Couldn't figure out mapping for {file}:{line},{col} → {cline},{ccol} [{name}]", { + file: token.file, + line: token.line, + col: token.col, + cline: current_line, + ccol: current_col, + name: name || "" + }) + } } : noop; function get() {