Uglifyjs: Setting 'compress' option to 'false' still results in minified output

Created on 29 Apr 2015  路  9Comments  路  Source: mishoo/UglifyJS

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

Most helpful comment

Ah... if you give UglifyJS.minify these values

{
    output: {beautify: true}
}

I'm sure it will beautify the output

All 9 comments

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

Check this out

screenshot1
screenshot2

It's definitely not working for me.

Although, interestingly, it works if for strings. Issue is only for files..

screenshot3

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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

neverfox picture neverfox  路  4Comments

alexlamsl picture alexlamsl  路  5Comments

utdrmac picture utdrmac  路  4Comments

gabmontes picture gabmontes  路  5Comments

diegocr picture diegocr  路  3Comments