Note: for support questions, please use one of these channels:
https://forum.ionicframework.com/
http://ionicworldwide.herokuapp.com/
When building the project with the --minifyjs argument, we get the following error:
...
[16:21:57] webpack finished in 31.14 s
[16:21:57] sass started ...
[16:21:57] uglifyjs started ...
[16:21:58] copy finished in 45.19 s
[16:21:59] sass finished in 1.55 s
[16:21:59] cleancss started ...
[16:22:00] cleancss finished in 1.32 s
[WARN] Error occurred during command execution from a CLI plugin
(@ionic/cli-plugin-cordova). Your plugins may be out of date.
Error: Uglify failed: Unexpected token: keyword (const) in undefined at line undefined, col undefined, pos undefined
Removing it will give a successful build, but the file size is increased by several MB.
We've seen this error since upgrading to 2.0.0, and we're still seeing it in 2.0.1
To minify the code, giving the same result as v1.1.4. We we're able to use --prod before upgrading to Ionic 3, now --prod gives an ocean of errors.
Steps to reproduce:
ionic cordova run android --aot --minifyjs --minifycss --deviceionic cordova run android --minifyjsionic cordova build ios --aot --minifyjs --minifycssglobal packages:
@ionic/cli-plugin-proxy : 1.3.1
@ionic/cli-plugin-proxy : 1.3.1
@ionic/cli-utils : 1.4.0
Cordova CLI : not installed
Ionic CLI : 3.4.0
local packages:
@ionic/app-scripts : 2.0.1
@ionic/cli-plugin-cordova : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms : none
Ionic Framework : ionic-angular 3.5.0
System:
Node : v8.1.2
OS : macOS Sierra
Xcode : Xcode 8.3.3 Build version 8E3004b
ios-deploy : 1.9.1
ios-sim : 5.0.13
npm : 5.0.3
Which @ionic/app-scripts version are you using?
2.0.1
Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)
paste your tsconfig.json file
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "./src",
"paths": {
"environments/*": [
"./environments/*"
],
"app/*": [
"./app/*"
],
"lib/*": [
"./lib/*"
],
"pages/*": [
"./pages/*"
],
"components/*": [
"./components/*"
],
"validators/*": [
"./validators/*"
],
"providers/*": [
"./providers/*"
],
"models/*": [
"./models/*"
],
"decorators/*": [
"./decorators/*"
],
"pipes/*": [
"./pipes/*"
]
},
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"types": [
"jasmine",
"sinon"
]
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules",
"src/**/*.spec.ts"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
Hello, thanks for using Ionic. Would you mind posting a small sample of some of the errors your getting when running --prod? Also, did you recently update which version of ionic-angular you were running? If so, what version did you update from?
Getting the same error:
"Error: Uglify failed: Unexpected token: keyword (const) in undefined at line undefined, col undefined, pos undefined"
Same problem with the following cdm:
$ ionic cordova build android --prod --release
(without --prod it is ok)
I Obtain:
[WARN] Error occurred during command execution from a CLI plugin (@ionic/cli-plugin-cordova).
Error: Uglify failed: Unexpected token: name (User) in undefined at line undefined, col undefined, pos undefined
My package.json:
{
"name": "test",
"version": "0.0.1",
"author": "test",
"homepage": "xxxxx",
"private": true,
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
"dependencies": {
"@angular/common": "4.1.3",
"@angular/compiler": "4.1.3",
"@angular/compiler-cli": "4.1.3",
"@angular/core": "4.1.3",
"@angular/forms": "4.1.3",
"@angular/http": "4.1.3",
"@angular/platform-browser": "4.1.3",
"@angular/platform-browser-dynamic": "4.1.3",
"@ionic-native/app-minimize": "^4.1.0",
"@ionic-native/app-version": "^4.0.1",
"@ionic-native/barcode-scanner": "^4.1.0",
"@ionic-native/core": "3.12.1",
"@ionic-native/native-storage": "^4.1.0",
"@ionic-native/qr-scanner": "^4.1.0",
"@ionic-native/splash-screen": "3.12.1",
"@ionic-native/sqlite": "^4.1.0",
"@ionic-native/status-bar": "3.12.1",
"@ionic/storage": "2.0.1",
"@ngx-translate/core": "^7.1.0",
"@ngx-translate/http-loader": "^0.1.0",
"@types/node": "^8.0.14",
"datepicker-ionic2": "^2.5.0",
"ionic-angular": "3.5.3",
"ionicons": "3.0.0",
"rxjs": "5.4.0",
"sw-toolbox": "3.6.0",
"zone.js": "0.8.12"
},
"devDependencies": {
"@ionic/app-scripts": "2.0.2",
"@ionic/cli-plugin-cordova": "1.5.0",
"@ionic/cli-plugin-ionic-angular": "1.4.0",
"ionic": "3.6.0",
"typescript": "2.3.4"
},
"description": "An Ionic project"
}
if it helps:
i posted some of my observations on this here: https://github.com/ionic-team/ionic-cli/issues/2618
TLDR:
--prod basicly is a shortcut for
--aot --minifyjs --minifycss --optimizejs
you can just skip --minifyjs and it will work like:
ionic build --aot --minifycss --optimizejs
or with cordova:
ionic cordova build --aot --minifycss --optimizejs
if you run ionic build --minifyjs you will get the error but it will also say
[1] 29875 segmentation fault ionic build --minifyjs
whatever that means :)
https://github.com/ionic-team/ionic-app-scripts/issues/1027
seems to be related
latest version of ionic(and evertyhing is updated, win10) & similar problem, last time it worked, must look on all the changes i've done since latest deploy to device.
But error is ..nice:
Error: Uglify failed: Unexpected token name (MyPageModuleInjector) in undefined at line undefined, col undefined, pos undefined
I've found the issue, in tsconfig.json target was set to "es2015" - that was causing an error.
Replaced with target:"es5" - everything is ok now!
@vhb56 that fixed it for me
Sorry for my late response. I probably wont be able to validate this since we're in the middle of development. If the development slows down, I will at least try to validate that it doesn't crash anymore with the latest version.
Running npm install @ionic/app-scripts@latest --save-dev worked for me.
Having similar issue even after using the latest app-scripts
Error :
[20:33:31] ionic-app-script task: "minify"
[20:33:31] Error: Cannot read property 'filter' of undefined in undefined at line undefined, col undefined, pos
undefined
Error: Cannot read property 'filter' of undefined in undefined at line undefined, col undefined, pos undefined
at BuildError.Error (native)
Package.json
"@ionic/app-scripts": "^3.1.7",
TsConfig:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"target": "es5",
"types": [
"node"
],
"typeRoots": [
"node_modules/@types"
]
},
"exclude": [
"node_modules",
"e2e",
"generator"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
Fixed with "npm install @ionic/app-scripts@latest --save-dev" , as suggested above
updating scripts did nothing for me (was on 3.2.0, updated to 3.2.1) and my target was already es5
Most helpful comment
Running
npm install @ionic/app-scripts@latest --save-devworked for me.