After updating target to es6 giving uglifyjs failed SyntaxError

I have created the Ionic2 app where I have added async function. Due to async function supported ES6 I have updated tsconfig target to es6.

While using ionic serve command its build & run perfectly. But when using ionic run android its gives me error as below.

[21:17:09] uglifyjs failed: SyntaxError: Unexpected token: name (Wrapper_Button)
[21:17:09] ionic-app-script task: “build”
[21:17:09] Error: SyntaxError: Unexpected token: name (Wrapper_Button)

Please suggest whats going wrong. I wanted to use the async functions.

Share some sample code from what fails?

tsConfig settings for es6

"compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    // "module": "es2015",
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    //"target": "es5"
    "target": "es6"
  }

Async method created as below.

     async UpdateGlobalVarUserCurrentLocation() {

         let options = {timeout:8000, enableHighAccuracy:true, maximumAge:1000};
         return new Promise<void>(resolve => {
             setTimeout(resolve, milliseconds);
                 Geolocation.getCurrentPosition(options).then((position) => {
                    
                     this.coordinateData.isUserCurrentLocationFound = true;
                     this.coordinateData.lat = position.coords.latitude;
                     this.coordinateData.lng = position.coords.longitude;                    
                     this.globalVars.setUserCurrentLocation(this.coordinateData);

                 }, (err) => {

                     this.coordinateData.isUserCurrentLocationFound = false;
                     this.coordinateData.lat = null;
                     this.coordinateData.lng = null;
                     this.globalVars.setUserCurrentLocation(this.coordinateData);

                 });
         });
     }

If i will fire command ionic serve everything is working perfect. But when fire command ionic run android to deploy app on android its shows me uglifyjs syntax error.

Even I have commented the above methods still the same error displayed.

Below is the my ionic version details

ordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.2
Ionic CLI Version: 2.1.8
Ionic App Lib Version: 2.1.4
Ionic App Scripts Version: 0.0.44
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.9.1
Xcode version: Not installed

I have resolved this problem. Resolution for this issue already on github. (https://github.com/driftyco/ionic-app-scripts/issues/239)
Thanks a lot @jgw96.

Do the following changes.

  • On your root project directory, edit node_modules/@ionic/app-scripts/package.json file. Then in that file update uglify-js like this “uglify-js”: “git+https://github.com/mishoo/UglifyJS2.git#harmony”.

  • Then after that execute npm install (make sure right now you’re at node_modules/@ionic/app-scripts. Ignore error that shown.

After this my solution successfully build & deploy on the device without failed.

Is this still the best solution for this problem?

This is not the recommended but no any other alternative fixes available.