aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaridy Patino <caridy@gmail.com>2014-11-11 14:38:01 -0500
committerRichard van Velzen <rvanvelzen1@gmail.com>2015-01-04 21:08:29 +0100
commitad18689d926d25c7a25b95c630c2ad05b7b5f5b5 (patch)
treefb9cced5e30c3b89d33a3431238dab9fb1d8d04b
parent0f80b1058d233f11b95fef567d1b37dd88c94f09 (diff)
downloadtracifyjs-ad18689d926d25c7a25b95c630c2ad05b7b5f5b5.tar.gz
tracifyjs-ad18689d926d25c7a25b95c630c2ad05b7b5f5b5.zip
using the original sourcemap as the base
* Creates a new SourceMapGenerator based on a SourceMapConsumer: https://github.com/mozilla/source-map#sourcemapgeneratorfromsourcemapsourcemapconsumer
-rw-r--r--lib/sourcemap.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/sourcemap.js b/lib/sourcemap.js
index 948e3b39..3998e405 100644
--- a/lib/sourcemap.js
+++ b/lib/sourcemap.js
@@ -53,11 +53,16 @@ function SourceMap(options) {
orig_line_diff : 0,
dest_line_diff : 0,
});
- var generator = new MOZ_SourceMap.SourceMapGenerator({
- file : options.file,
- sourceRoot : options.root
- });
var orig_map = options.orig && new MOZ_SourceMap.SourceMapConsumer(options.orig);
+ var generator;
+ if (orig_map) {
+ generator = MOZ_SourceMap.SourceMapGenerator.fromSourceMap(orig_map);
+ } else {
+ generator = new MOZ_SourceMap.SourceMapGenerator({
+ file : options.file,
+ sourceRoot : options.root
+ });
+ }
function add(source, gen_line, gen_col, orig_line, orig_col, name) {
if (orig_map) {
var info = orig_map.originalPositionFor({
@@ -78,7 +83,7 @@ function SourceMap(options) {
source : source,
name : name
});
- };
+ }
return {
add : add,
get : function() { return generator },