using the original sourcemap as the base

* Creates a new SourceMapGenerator based on a SourceMapConsumer:
  https://github.com/mozilla/source-map#sourcemapgeneratorfromsourcemapsourcemapconsumer
This commit is contained in:
Caridy Patino 2014-11-11 14:38:01 -05:00
parent f36a1eaa8b
commit 4f46ae2b16

View File

@ -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 },