Open rolinger opened 6 years ago
I was adding the plugins folder to be compressed and started facing the same issue and I'm not on Windows like you @rolinger
one of the plugins JavaScript file is turned into "undefined": This file from this plugin to be more precise: https://github.com/pushandplay/cordova-plugin-apprate/blob/master/www/AppRate.js
Ok, I tracked it down:
As stated in uglify-js
:
* uglify-js only supports JavaScript (ECMAScript 5).
* To minify ECMAScript 2015 or above, transpile using tools like Babel.
The file I mentioned above uses const
in which is part of ES6.
I found it out trying to uglify this file directly and getting the following output:
Parse error at AppRate.js:300,2
const dateTimestamp = date.getTime();
^
ERROR: Unexpected token: keyword «const»
After changing const
to var
and uglifying again it works.
Is there any kind of parser that error checks before attempting to uglify? When I did this time it royally hosed my entire project. I couldn't undo things and I basically had to reinstall my entire project from scratch. I have avoided it since because of this...though I want minify and uglify applied to my project, I can't do it until I know what in my project is breaking things.
@rolinger yes there is.
I used es-check
: https://github.com/dollarshaveclub/es-check
If anyone has time this package could be used to check the files before uglifying until we have ES6 support...
also, IDK how you hosed your project but I was also messing with some files earlier and kinda doing the same so here goes 2 tips:
cordova platform rm android && cordova platform add android
.js
then order them by size and the undefined
ones should be the smallest with 9 bytes only....coming back to this. uglify-js
doesn't support ES6.
I'm now using Terser 5 as an alternative. outputs a few errors but works.
I know this there is an open issue on this thread already, however, most of the info on that thread is about deploying from a windows machine.
I am having problems with 'cordova-uglify' on my windows machine deploying my project for Android, but now I am having the same problem on my mac deploying for iOS.
The current version of
cordova-uglify
is causing 3 files on my windows -> android deploying to beundefined
, and 9 files on my mac->iOS to beundefined
. Can't use this plugin anywhere.