Uglifyjs: DefaultsError: `warnings` is not a supported option

Created on 2 May 2019  路  3Comments  路  Source: mishoo/UglifyJS

Bug report
When using the latest version 3.5.10 I'm seeing error when building with webpack.
Version 3.5.9 has no problems.

Version 3.5.10, webpack version 4.29.6

JavaScript output or error produced.

ERROR in ac6445b1ba753e562a1c.js from UglifyJs
DefaultsError: `warnings` is not a supported option
    at DefaultsError.Object.defineProperty.get (eval at <anonymous> (/node_modules/uglify-js/tools/node.js:1:0), <anonymous>:71:23)
    at Function.buildError (/node_modules/uglifyjs-webpack-plugin/dist/index.js:103:53)
    at results.forEach (/node_modules/uglifyjs-webpack-plugin/dist/index.js:256:52)
    at Array.forEach (native)
    at taskRunner.run (/node_modules/uglifyjs-webpack-plugin/dist/index.js:231:17)
    at step (/node_modules/uglifyjs-webpack-plugin/dist/TaskRunner.js:83:9)
    at done (/node_modules/uglifyjs-webpack-plugin/dist/TaskRunner.js:94:30)
    at boundWorkers (/Users/node_modules/uglifyjs-webpack-plugin/dist/TaskRunner.js:99:13)
    at TaskRunner.boundWorkers.error [as boundWorkers] (/node_modules/uglifyjs-webpack-plugin/dist/TaskRunner.js:68:11)
    at enqueue (/node_modules/uglifyjs-webpack-plugin/dist/TaskRunner.js:89:14)
    at tasks.forEach (/node_modules/uglifyjs-webpack-plugin/dist/TaskRunner.js:109:9)
    at Array.forEach (native)
    at TaskRunner.run (/node_modules/uglifyjs-webpack-plugin/dist/TaskRunner.js:87:11)
    at UglifyJsPlugin.optimizeFn (/node_modules/uglifyjs-webpack-plugin/dist/index.js:225:18)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:7:1)
    at AsyncSeriesHook.lazyCompileHook (/node_modules/tapable/lib/Hook.js:154:20

Most helpful comment

I've just checked, and even uglifyjs-webpack-plugin does not use the deprecated compress.warnings option anymore.

And since you haven't provided any details of your particular issue, I can only assume that you've the following:

{
    "compress": {
        "warnings": value
    }
}

instead of simply:

{
    "warnings": value
}

All 3 comments

I've just checked, and even uglifyjs-webpack-plugin does not use the deprecated compress.warnings option anymore.

And since you haven't provided any details of your particular issue, I can only assume that you've the following:

{
    "compress": {
        "warnings": value
    }
}

instead of simply:

{
    "warnings": value
}

I do. That fixes it. Thanks for the quick reply/fix!

I noticed the same error (warnings is not a supported option) in my setup using uglify-js 3.5.6 and uglifyjs-webpack-plugin 2.1.2 and webpack 4.30.0. I'm not sure why but the error only popped up in the last few days even though I hadn't touched my package versions in a few weeks.

I wasn't setting compress -> warnings in my config. However, what I am doing is calling UglifyJS.default_options() and tweaking that. The default_options apparently did include the unwanted compress -> warnings setting.

I see warnings: false listed in uglify-js/lib/compress.js at line 97 in uglify-js 3.5.6, so that's where it came from.

I upgraded to uglify-js 3.5.10 and in that version, warnings is no longer listed in compress.js in the defaults stuff and I don't get the error. So I guess that's my fix. I still don't understand why it only popped up recently because I haven't changed anything there in a while, but at least I have a solution. I'm noting this for the benefit of anyone else in a similar situation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrismanley picture chrismanley  路  5Comments

uiteoi picture uiteoi  路  5Comments

alexlamsl picture alexlamsl  路  5Comments

hacdias picture hacdias  路  5Comments

andreialecu picture andreialecu  路  5Comments