Search code examples
meteorsafariios10minify

Meteor error 'cannot declare let twice' when minifying


When minifying meteor app, safari on IOS 10 throws the following error

SyntaxError: Cannot declare a let variable twice: 't'.

I have tried to remove standart-minifier and added abernix:standart-minifier as it was recommended on this comment - they work fine on all the other browsers but on safari ios10 it crashes.

Do you have any recommendations?

Thanks a lot

Edit:

I ended up removing minify packages as it was mentioned here however it definitely not a long-term solution.


Solution

  • The solution to this ios10 safari bug is here

    Problem is caused by minify default option

    safari10:false
    

    to solve the problem

    find these files

    /Users/USER/.meteor/packages/abernix_standard-minifier-js/.2.1.0.1v4h096++os+web.browser+web.cordova/plugin.minifyStdJS.os/npm/node_modules/meteor/abernix_minifier-js/node_modules/uglify-es/lib/minify.js

    and

    /Users/USER/.meteor/packages/abernix_minifier-js/.2.1.0.106pai4++os+web.browser+web.cordova/npm/node_modules/uglify-es/lib/minify.js

    then find the following lines and change it as "safari10:true"

    if (options.mangle) {
            options.mangle = defaults(options.mangle, {
                cache: null,
                eval: false,
                ie8: false,
                keep_classnames: false,
                keep_fnames: false,
                properties: false,
                reserved: [],
                safari10: true,
                toplevel: false,
            }, true);
        }