SyntaxError: Unexpected identifier 'e'. Cannot declare a lexical variable twice: 'e'.
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
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.
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
Does
terseralso supportsafari10flag ?
Yes, it appears to.
Not reproducible in uglify-js