UglifyJS icon indicating copy to clipboard operation
UglifyJS copied to clipboard

SyntaxError: Unexpected identifier 'e'. Cannot declare a lexical variable twice: 'e'.

Open hiredgun opened this issue 8 years ago • 4 comments

I encountered a similar issue to #1753 in my React app but couldn't solve it using "safari10: true" option.

I'm using Webpack 4 and in my case I got: SyntaxError: Unexpected identifier 'e'. Cannot declare a lexical variable twice: 'e'.

I prepared a repo which allows to reproduce above error https://github.com/hiredgun/safari-uglifyjs-issue. I described my setup in the readme but in general the problematic code in my case was:

  onChange = event => {
    try {
        ...
    } catch ({ message }) { // removing this destructuring solves the issue
       ...
    }
  };

I managed to solve the issue either by removing destructuring from catch or by increasing the number of supported major Safari versions in my Browserslist config from 2 to 3.

Shouldn't above error be solvable by safari10 flag set to true?

hiredgun avatar Aug 27 '18 17:08 hiredgun

@hiredgun

uglify-es is discontinued. Please re-file your bug over at terser (the continued uglify-es fork). Once patched you want to switch to the terser-webpack-plugin. Webpack will be switching over to it as it's default once they work out versioning/compat.

jdalton avatar Sep 14 '18 21:09 jdalton

is it uglify-es the same name of this ( mishoo/UglifyJS2 repo) ? @jdalton I get rid of this issue by config

optimization: {
      minimizer: [
        new MinifyPlugin({
          cache: true,
          uglifyOptions: {
            safari10: true
          }
        })
      ]
    },

Does terser also support safari10 flag ?

nvcken avatar Sep 18 '18 10:09 nvcken

@nvcken

Does terser also support safari10 flag ?

Yes, it appears to.

jdalton avatar Sep 18 '18 13:09 jdalton

Not reproducible in uglify-js

alexlamsl avatar Feb 27 '21 22:02 alexlamsl