Added support for sourcesContent property of source map

This commit is contained in:
Artemy Tregubenko
2014-01-09 15:12:00 +01:00
parent c3087dd179
commit 03cf94ebe8
3 changed files with 26 additions and 1 deletions

View File

@@ -64,7 +64,8 @@ exports.minify = function(files, options) {
UglifyJS.base54.reset();
// 1. parse
var toplevel = null;
var toplevel = null,
sourcesContent = {};
if (options.spidermonkey) {
toplevel = UglifyJS.AST_Node.from_mozilla_ast(files);
@@ -75,6 +76,7 @@ exports.minify = function(files, options) {
var code = options.fromString
? file
: fs.readFileSync(file, "utf8");
sourcesContent[file] = code;
toplevel = UglifyJS.parse(code, {
filename: options.fromString ? "?" : file,
toplevel: toplevel
@@ -110,6 +112,12 @@ exports.minify = function(files, options) {
orig: inMap,
root: options.sourceRoot
});
if (options.sourceMapIncludeSources) {
for (var file in sourcesContent) {
options.source_map.get().setSourceContent(file, sourcesContent[file]);
}
}
}
if (options.output) {
UglifyJS.merge(output, options.output);