Ionic-app-scripts: Uglifyjs Fails with ES6 when bulding for production

Created on 6 Jun 2017  路  9Comments  路  Source: ionic-team/ionic-app-scripts

Short description of the problem:

Error when running ionic cordova build android --prod

Error: Unexpected token: name (xxxxxxx) in www\build\main.js at line 19288, col 4, pos 662013

What behavior are you expecting?

Build success

Steps to reproduce:

  1. Update tsconfig and set "target": "es6"
  2. run ionic cordova build android --prod
  3. Error Message after UglifyJS started

Which @ionic/app-scripts version are you using?
1.3.7

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

global packages:

@ionic/cli-utils : 1.3.0
Cordova CLI      : 6.5.0
Ionic CLI        : 3.3.0

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.3.0
@ionic/cli-plugin-ionic-angular : 1.3.0
Cordova Platforms               : android 6.1.2 ios 4.4.0
Ionic Framework                 : ionic-angular 3.3.0

typescript 2.3.3

System:

Node       : v6.9.2
OS         : Windows 10
Xcode      : not installed
ios-deploy : not installed
ios-sim    : not installed

Most helpful comment

Hello all! The version of Uglify we used in these old versions of app-scripts did not support es6. If you update to the latest release of app-scripts 2.0.2 we now use the es6 friendly version of uglify. Thanks!

All 9 comments

Hi, i've got th same. I update to 1.3.12 and same error.

Hello all! The version of Uglify we used in these old versions of app-scripts did not support es6. If you update to the latest release of app-scripts 2.0.2 we now use the es6 friendly version of uglify. Thanks!

Hi, I update to app-script 2.0.2 but it doesn't work. So i used to understand --aot --optimizejs --minifyjs --minifycss and i've the same error

It works only with --aot --optimizejs --minifycss

but when i use --minifyjs, I've got the same than --prod.
Here is the error:

ionic-app-scripts build "--minifyjs"

[09:01:29] ionic-app-scripts 2.0.2
[09:01:29] build dev started ...
[09:01:29] clean started ...
[09:01:29] clean finished in 18 ms
[09:01:29] copy started ...
[09:01:29] transpile started ...
[09:01:39] transpile finished in 9.21 s
[09:01:39] preprocess started ...
[09:01:39] deeplinks started ...
[09:01:39] deeplinks finished in 416 ms
[09:01:39] preprocess finished in 419 ms
[09:01:39] webpack started ...
[09:01:40] copy finished in 10.16 s
[09:02:05] webpack finished in 25.71 s
[09:02:05] sass started ...
[09:02:05] uglifyjs started ...
[09:02:05] ionic-app-script task: "build"
[09:02:05] Error: Uglify failed: Unexpected token: name (XXXPageModule) in undefined at line undefined, col
undefined, pos undefined
Error: Uglify failed: Unexpected token: name (XXXPageModule) in undefined at line undefined, col undefined, pos undefined
at BuildError.Error (native)
at new BuildError (C:...APPS...Directory...\node_modules@ionic\app-scripts\dist\util\errors.js:16:28)
at taskReject (C:...APPS...Directory...\node_modules@ionic\app-scripts\dist\worker-process.js:36:22)
at C:...APPS...Directory...\node_modules@ionic\app-scripts\dist\worker-process.js:14:13

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\login\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "ionic:build" "--" "--minifyjs"
npm ERR! node v4.4.0
npm ERR! npm v4.1.2

Thanks in advance

Confirmed, app-scripts 2.1.3 still does not work.

Hello
I have same problem in production build
I updated app-script but same..
Please help me so that I can build production build

Actually the fix ins't released yet. The change from uglify-js to uglify-es is in this commit.

Any solution yet?

npm install @ionic/app-scripts@latest --save-dev

This solve me the problem .
npm install @ionic/app-scripts@latest --save-dev

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Manduro picture Manduro  路  78Comments

ValterSantosMatos picture ValterSantosMatos  路  63Comments

kleeb picture kleeb  路  48Comments

lrlarson picture lrlarson  路  76Comments

shlomiassaf picture shlomiassaf  路  83Comments