Safari 10, Uglify: SyntaxError: Cannot declare a let variable twice: 'e'
[issue link]Note, I would have used the CMTY app, but authorization grants you FULL access to my personal information, including private email addresses, private profile info, followers, and organization access! Just to file a bug report!?
It appears that there is a bug in Safari 10, that will result in a Loading chunk 0 failed.
error. It appears to be due to a preceding error SyntaxError: Cannot declare a let variable twice: 'e'
caused by the Safari 10 ES6 loop bug
There is a related Uglify (UglifyJS2/issues/1753) thread that provides a work-around:
CLI:
--mangle safari10=true
or from minify() with the option:
{
mangle: {
safari10: true
}
}
So in the context of Nuxt, the config can be tweaked to:
// nuxt.config.js
module.exports = {
build: {
uglify: {
uglifyOptions: {
mangle: { safari10: true }
}
}
}
}
But my suggestion is that Nuxt add this as a default Uglify option, as Safari 10 is still a relatively common browser for those who haven’t yet upgraded to High Sierra.
// https://github.com/nuxt/nuxt.js/blob/master/lib/builder/webpack/client.config.js
// line 187
new UglifyJSPlugin(
Object.assign(
{
// cache: true,
sourceMap: true,
parallel: true,
extractComments: {
filename: 'LICENSES'
},
uglifyOptions: {
mangle: {
safari10: true
},
output: {
comments: /^\**!|@preserve|@license|@cc_on/
}
}
},
this.options.build.uglify
)
)