diff --git a/lib/sourcemap.js b/lib/sourcemap.js index 663ef12e..7b74bd23 100644 --- a/lib/sourcemap.js +++ b/lib/sourcemap.js @@ -53,10 +53,7 @@ function SourceMap(options) { orig_line_diff : 0, dest_line_diff : 0, }); - var generator = new MOZ_SourceMap.SourceMapGenerator({ - file : options.file, - sourceRoot : options.root - }); + var generator; var orig_map = options.orig && new MOZ_SourceMap.SourceMapConsumer(options.orig); function add(source, gen_line, gen_col, orig_line, orig_col, name) { if (orig_map) { @@ -78,7 +75,15 @@ function SourceMap(options) { source : source, name : name }); - }; + } + if (orig_map) { + generator = MOZ_SourceMap.SourceMapGenerator.fromSourceMap(orig_map); + } else { + generator = new MOZ_SourceMap.SourceMapGenerator({ + file : options.file, + sourceRoot : options.root + }); + } return { add : add, get : function() { return generator },