Sapper: SyntaxError: Cannot declare a let variable twice

Created on 15 Aug 2018  路  8Comments  路  Source: sveltejs/sapper

Console error at https://svelte-realworld.now.sh running from Iphone 5, Safari 10.
image

Maybe is an ES6 bug in Safari 10:
https://bugs.webkit.org/show_bug.cgi?id=171041

Most helpful comment

Great now works! you right Rich 馃榾 just added to my client.config.js this:

const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
    ...
    optimization: {
        minimizer: [
          new UglifyJsPlugin({ uglifyOptions: { safari10: true } })
        ]
    },

All 8 comments

Oh, weird. Any idea where specifically it's happening (in the code, or in the app i.e. what page)? Not sure there's anything we can do if it's a browser bug 馃槵

I sort of recall there being an Uglify option to work around a Safari bug that sounded similar to this one;. But I can't locate it right now.

It happens just after sapper build, but not in local dev server.
I think Conduitry is right, I was also looking at the webpack configs to add the option like:
https://github.com/mishoo/UglifyJS2/issues/1753#issuecomment-324814782

but I could not find it either.

Oh right! This is an ES6-specific bug. That means it's mentioned in the uglify-es docs and the terser docs, not in the uglify-js docs.

Yikes, seems like a lot of people have run into it. I guess it's necessary to set the https://webpack.js.org/configuration/optimization/#optimization-minimizer option manually 馃槵

Great now works! you right Rich 馃榾 just added to my client.config.js this:

const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
    ...
    optimization: {
        minimizer: [
          new UglifyJsPlugin({ uglifyOptions: { safari10: true } })
        ]
    },

This just bit me as well. Is it worth adding a note about this to sapper-template?

@amadeu2 I just wanted to say thank you for your snippet with the safari option, I am not using sapper but I am using the uglify plugin which was causing me no end of issues on iOS till I added this so thank you!

Was this page helpful?
0 / 5 - 0 ratings