Ionic version:
[x] 4.x
Current behavior:
The problem occurs when executing the command "ionic cordova build android " with the flag --prod, if it runs without the flag, no error occurs.
Expected behavior:
The APK generate with success.
Steps to reproduce:
The error occurs when you run the following command:
ionic cordova build android --prod
.
Generates:
...
chunk {cordova} cordova.935a9f4e1f7afeca168d.js (cordova) 71.6 kB [entry] [rendered]
ERROR in common.00974306b5124fe008c9.js from Terser
TypeError: Cannot read property 'minify' of undefined
at minify (/home/vini/projects/minify-error/node_modules/terser-webpack-plugin/dist/minify.js:175:23)
at module.exports (/home/vini/projects/minify-error/node_modules/terser-webpack-plugin/dist/worker.js:13:40)
at handle (/home/vini/projects/minify-error/node_modules/worker-farm/lib/child/index.js:44:8)
at process.<anonymous> (/home/vini/projects/minify-error/node_modules/worker-farm/lib/child/index.js:51:3)
at process.emit (events.js:197:13)
at emit (internal/child_process.js:828:12)
at processTicksAndRejections (internal/process/next_tick.js:76:17)
...
Related code:
Repository with the code that generates the error:
https://github.com/H4ad/minify-errors/
Other information:
Ionic info:
Ionic:
ionic (Ionic CLI) : 4.6.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0
@angular-devkit/build-angular : 0.12.4
@angular-devkit/schematics : 7.2.4
@angular/cli : 7.2.4
@ionic/angular-toolkit : 1.3.0
Cordova:
cordova (Cordova CLI) : 8.1.2 ([email protected])
Cordova Platforms : android 7.1.4
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.1, (and 4 other plugins)
System:
Android SDK Tools : 26.1.1 (/home/vini/Android/Sdk/)
NodeJS : v11.8.0 (/usr/bin/node)
npm : 6.7.0
OS : Linux 4.15
Look at workarounds here:
https://github.com/terser-js/terser/pull/254#issuecomment-460008665
I fix the problem with:
https://github.com/webpack-contrib/terser-webpack-plugin/issues/66#issuecomment-460047754
The build command is from Angular, this seems to be a problem with the terser version. Here's an Angular CLI issue for it, please follow the bug here: https://github.com/angular/angular-cli/issues/13582.
I am going to close this as it looks like the linked issue has been fixed, thanks!
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Most helpful comment
I fix the problem with:
https://github.com/webpack-contrib/terser-webpack-plugin/issues/66#issuecomment-460047754