From 05ac8d6e5caab6efe7a8bd2017f4eb392d58b9ef Mon Sep 17 00:00:00 2001 From: Lauri Pokka Date: Tue, 5 Jul 2016 02:06:14 +0900 Subject: [PATCH] lib/sourcemap.js: Copy sourceContent from old souce-map to the new source-map. Should fix #882 --- lib/sourcemap.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/sourcemap.js b/lib/sourcemap.js index e5d7df60..3714027e 100644 --- a/lib/sourcemap.js +++ b/lib/sourcemap.js @@ -58,6 +58,16 @@ function SourceMap(options) { sourceRoot : options.root }); var orig_map = options.orig && new MOZ_SourceMap.SourceMapConsumer(options.orig); + + if (orig_map && Array.isArray(options.orig.sources)) { + options.orig.sources.forEach(function(source) { + var sourceContent = orig_map.sourceContentFor(source, true); + if (sourceContent) { + generator.setSourceContent(source, sourceContent); + } + }); + } + function add(source, gen_line, gen_col, orig_line, orig_col, name) { if (orig_map) { var info = orig_map.originalPositionFor({