From e32c1308e8d020261f5c65bb4be17c941748f4d4 Mon Sep 17 00:00:00 2001 From: startswithaj Date: Thu, 15 Oct 2015 16:48:31 +1000 Subject: [PATCH] James change to use original source for mapping --- lib/output.js | 4 +++- lib/parse.js | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/output.js b/lib/output.js index a3b8f1a7..21867f8f 100644 --- a/lib/output.js +++ b/lib/output.js @@ -306,11 +306,13 @@ function OutputStream(options) { var add_mapping = options.source_map ? function(token, name) { try { + var originalSource = token.__HACK_CODE__.substring(token.pos, token.endpos) + if (token) options.source_map.add( token.file || "?", current_line, current_col, token.line, token.col, - (!name && token.type == "name") ? token.value : name + originalSource // (!name && token.type == "name") ? token.value : name ); } catch(ex) { AST_Node.warn("Couldn't figure out mapping for {file}:{line},{col} → {cline},{ccol} [{name}]", { diff --git a/lib/parse.js b/lib/parse.js index 1ab03589..d83a6eff 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -684,6 +684,10 @@ function parse($TEXT, options) { S.in_directives = S.in_directives && ( S.token.type == "string" || is("punc", ";") ); + + // Hacks in the source code + S.token.__HACK_CODE__ = $TEXT + return S.token; };