It seems compress:false has no effect, it still produces minified file
UglifyJS2.minify(files, {
outSourceMap: mapPath,
mangle: false,
compress: false,
...
});
same issue in grunt-contrib-uglify https://github.com/gruntjs/grunt-contrib-uglify/issues/257
Does it also disable mangle?
Anyway, the compress options are parsed here
https://github.com/mishoo/UglifyJS2/blob/e1c3861832014448d1d54163c62144786ea91900/tools/node.js#L91
Maybe its because UglifyJS.defaults at line 65 converts false into {}
And since false == false outputs true and false == {} outputs false, its simply not skipping the minify phase.
And this should be the same for the mangle phase.
So I went to /tools/node.js#L63 in my local install and changed it to mangle: false & compress: false. Didn't make any difference. Then I commented out the entire part
// // 2. compress
// if (options.compress) {
// var compress = { warnings: options.warnings };
// UglifyJS.merge(compress, options.compress);
// toplevel.figure_out_scope();
// var sq = UglifyJS.Compressor(compress);
// toplevel = toplevel.transform(sq);
// }
// // 3. mangle
// if (options.mangle) {
// toplevel.figure_out_scope(options.mangle);
// toplevel.compute_char_frequency(options.mangle);
// toplevel.mangle_names(options.mangle);
// }
Didn't make a difference. Still got compressed file. Doesn't make any sense to me :/
Make sure though you are executing that piece of code...
(like putting console.log("Test") in front of that code)
I myself had made a lot of mistakes by editing code in a clone and then end up executing uglifyjs in the npm repo :p
Great stuff :-)
Though once the code is parsed, you won't be able to retrieve the code in its original state.
The output without minifying is the internal representation passed to the code generator.
The only option to get clean code out is by passing it to the beautifier. This however is not the original output.
I need to look up for that though on how to do that...
Ah... if you give UglifyJS.minify these values
{
output: {beautify: true}
}
I'm sure it will beautify the output
Oh, and here is where UglifyJS translates its internal tree representation (which you get after it reads the input) to the output:
https://github.com/mishoo/UglifyJS2/blob/e1c3861832014448d1d54163c62144786ea91900/tools/node.js#L130
Good luck
thanks @avdg
output: {beautify: true}
Hi @avdg :) Do you know if there's any way to combine that with the drop_console option?
Most helpful comment
Ah... if you give UglifyJS.minify these values
I'm sure it will beautify the output