From 4f46ae2b1618ebe0ea08411e516248577a3afb6d Mon Sep 17 00:00:00 2001 From: Caridy Patino Date: Tue, 11 Nov 2014 14:38:01 -0500 Subject: [PATCH] using the original sourcemap as the base * Creates a new SourceMapGenerator based on a SourceMapConsumer: https://github.com/mozilla/source-map#sourcemapgeneratorfromsourcemapsourcemapconsumer --- lib/sourcemap.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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 },