aboutsummaryrefslogtreecommitdiff
path: root/lib/minify.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/minify.js')
-rw-r--r--lib/minify.js22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/minify.js b/lib/minify.js
index b92d4b53..52246d70 100644
--- a/lib/minify.js
+++ b/lib/minify.js
@@ -204,27 +204,29 @@ function minify(files, options) {
if (options.mangle && options.mangle.properties) mangle_properties(toplevel, options.mangle.properties);
if (timings) timings.output = Date.now();
var result = {};
- if (options.output.ast) {
- result.ast = toplevel;
- }
- if (!HOP(options.output, "code") || options.output.code) {
+ var output = defaults(options.output, {
+ ast: false,
+ code: true,
+ });
+ if (output.ast) result.ast = toplevel;
+ if (output.code) {
if (options.sourceMap) {
- options.output.source_map = SourceMap(options.sourceMap);
+ output.source_map = SourceMap(options.sourceMap);
if (options.sourceMap.includeSources) {
if (files instanceof AST_Toplevel) {
throw new Error("original source content unavailable");
} else for (var name in files) if (HOP(files, name)) {
- options.output.source_map.setSourceContent(name, files[name]);
+ output.source_map.setSourceContent(name, files[name]);
}
}
}
- delete options.output.ast;
- delete options.output.code;
- var stream = OutputStream(options.output);
+ delete output.ast;
+ delete output.code;
+ var stream = OutputStream(output);
toplevel.print(stream);
result.code = stream.get();
if (options.sourceMap) {
- result.map = options.output.source_map.toString();
+ result.map = output.source_map.toString();
var url = options.sourceMap.url;
if (url) {
result.code = result.code.replace(/\n\/\/# sourceMappingURL=\S+\s*$/, "");