uglifier
uglifier copied to clipboard
Uglifier runs into problems with certain combination of modern JS syntax (await, destructuring, Promise.all)
Hi there,
Version (4.2.0)
My JS compressor settings are this:
config.assets.js_compressor = Uglifier.new({
harmony: true, # Required for ES6 scripts
output: {
comments: :none, # Remove absolutely every comment
max_line_len: 512, # Automatically wrap minified lines to 512 characters
}
})
On rake assets:precompile
I get this error:
excluded from capture: DSN not set
rake aborted!
Uglifier::Error:
After a lot of trial and error and debugging I was able to deduce the issue to be this syntax:
var [defaultsRes, selectedData] = await Promise.all(reqs);
The code ran as expected in development but could not be handled by the prod uglifier settings (noted above). Switching to the following fixed things for me:
var responses = await Promise.all(reqs);
var defaultsRes = responses[0];
var selectedData = responses[1];
Thanks!
Anything happening on this issue? I just ran into the same problem. No error message or line number so I had to remove pieces of my JS code to narrow down where Uglifier failed. Turned out to be a destructuring statement.