From e47ffc6e577e5420b22633cb2be8e741a20194d0 Mon Sep 17 00:00:00 2001 From: Arnavion Date: Tue, 4 Aug 2015 10:59:15 -0700 Subject: [PATCH] Don't search orig_maps if the source filename is unknown. When the AST is not associated with a filename, only orig_map can be queried to get the original filename. If that wasn't provided, then the best we can do is add a mapping literally for "?" --- lib/output.js | 2 +- lib/sourcemap.js | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/output.js b/lib/output.js index 396c6a29..40493fcf 100644 --- a/lib/output.js +++ b/lib/output.js @@ -303,7 +303,7 @@ function OutputStream(options) { var add_mapping = options.source_map ? function(token, name) { try { if (token) options.source_map.add( - token.file || "?", + token.file, current_line, current_col, token.line, token.col, (!name && token.type == "name") ? token.value : name diff --git a/lib/sourcemap.js b/lib/sourcemap.js index bfffe8f8..f62b43e1 100644 --- a/lib/sourcemap.js +++ b/lib/sourcemap.js @@ -69,7 +69,14 @@ function SourceMap(options) { orig_maps[consumer.file] = consumer; } function add(source, gen_line, gen_col, orig_line, orig_col, name) { - var originalMap = orig_maps[source] || orig_map; + var originalMap; + if (source) { + originalMap = orig_maps[source] || orig_map; + } + else { + source = "?"; + originalMap = orig_map; + } if (originalMap) { var info = originalMap.originalPositionFor({