lib/sourcemap.js: Copy sourceContent from old souce-map to the new source-map. Should fix #882

This commit is contained in:
Lauri Pokka
2016-07-05 02:06:14 +09:00
committed by Richard van Velzen
parent 7eb52d2837
commit 41a9329409
2 changed files with 53 additions and 0 deletions

View File

@@ -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({