Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uglifier runs into problems with certain combination of modern JS syntax (await, destructuring, Promise.all) #175

Open
chris-geelhoed opened this issue Jul 18, 2020 · 1 comment

Comments

@chris-geelhoed
Copy link

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!

@selfawaresoup
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants