diff --git a/lib/output.js b/lib/output.js index 40800559..e9dbcb54 100644 --- a/lib/output.js +++ b/lib/output.js @@ -360,11 +360,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 c960b493..ef0a80c9 100644 --- a/lib/parse.js +++ b/lib/parse.js @@ -735,6 +735,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; };