From b2e9d5a02d8b988420f0874e79c4d14d720a6426 Mon Sep 17 00:00:00 2001 From: Andy Wood Date: Mon, 12 May 2014 11:01:07 +0100 Subject: [PATCH] If the input source map has inline source content (e.g. from Browserify in debug mode), copy that across to the new source map so it continues to be inline after minification. --- lib/sourcemap.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/sourcemap.js b/lib/sourcemap.js index 663ef12e..403b4f4d 100644 --- a/lib/sourcemap.js +++ b/lib/sourcemap.js @@ -58,6 +58,15 @@ function SourceMap(options) { sourceRoot : options.root }); var orig_map = options.orig && new MOZ_SourceMap.SourceMapConsumer(options.orig); + + // Copy across inline sourcesContent, if any + if (options.orig.sourcesContent) { + var len = options.orig.sourcesContent.length; + for (var i = 0; i < len; i++) { + generator.setSourceContent(options.orig.sources[i], options.orig.sourcesContent[i]); + } + } + function add(source, gen_line, gen_col, orig_line, orig_col, name) { if (orig_map) { var info = orig_map.originalPositionFor({