-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
js files have content undefined #35
Comments
Sorry for the late response. Can you please provide the contents of your |
Hello,
|
It is odd that it is modifying files outside of your |
I'm not sure this is the same problem, but it may help: I had the same problem, ie .js files with 'undefined' content. After debugging uglify.js, the following line an overview before correction: result = UglifyJS.minify(res.src, hookConfig.uglifyJsOptions);
console.log('result.code ' + result.code);
fs.writeFileSync(file, result.code, 'utf8'); // overwrite the original unminified file
break;` Correction of the line (removed parameter "hookConfig.uglifyJsOptions" ,fast correction, there is surely better) result = UglifyJS.minify(res.src);
console.log('result.code ' + result.code);
fs.writeFileSync(file, result.code, 'utf8'); // overwrite the original unminified file
break; Why? ps: no more time to spend on this project, it works! |
@jeromeXoo Thank you for providing this info. I had some time this evening to look into this issue and it appears that the last PR introduced a few problems. I thought I had tested it after I merged but apparently I didn't have the latest commit. I've fixed the issue and published a new version (0.2.9) to npm. Let me know if you are still having issues. |
Hi,
my config:
cordova uglify installed today by npm
|
@rchovan Thanks for reporting the issue. I have a theatre PC with Windows on it I'll try it this weekend. I'm not experiencing any issues on Ubuntu or Mac OS. I wonder if the issue is because the project is on a separate drive than node/windows. |
@rossmartin I'm experiencing the same issue where the JS output files only contain "undefined". I am running the latest version of cordova-uglify 0.3.0 as reported by npm and node v8.9.1 on Windows 10. |
@koga73 Thanks for letting me know. Unfortunately my theatre PC that had Windows 10 on it died! Bad motherboard or power supply I think but I don't plan on reviving it. Recently I installed 2 Windows VMs to an external HDD on my Macbook for my day job to test IE11 issues. I'll have to use a VM to test this out and get it fixed. I haven't forgotten about this just haven't had time - it's frustrating because it works fine on Linux and Mac OS. |
@rossmartin Did some digging. Turns out your plugin is fine. Issue is we had an old uglify-config.json. Specifically this line was causing it: |
@koga73 Thanks a bunch for letting me know. I wonder if this is the issue you are having @rchovan ? Can you try it with the options from the readme? "uglifyJsOptions": {
"compress": {
"drop_console": true
},
"mangle": false,
"output": {
"code": true
}
} I could update the install script to overwrite the |
I have this error too. Using default options from README doesn't help. |
Hi all, BackgroundGeolocation.on('location', (location) => { If I remove it then it works properly I'm not sure though what should I change... Suggestions? |
Running uglijs manually, I get BackgroundGeolocation.on('location', (position) => { How could I fix it considering is legitimate js code? Thanks |
I'm trying And it seems to solve the issue. In uglify hook I changed this line: So far seems ok, will test more extensively |
@luigi37 I think you may have revealed why others are experiencing this same issue. uglify-js does not work with ES6. I think most transpile their "modern" JS to ES5 before feeding it to uglify-js. It appears that uglify-es might be the way to go moving forward to handle minifying code if it is ES6. There is also this interesting compress option with uglify-es -
Thanks for bringing this up @luigi37. I'm going to give it a go and see how it works out. If it works with the old and new stuff I'll publish a new version today. |
Cool, thanks! |
@luigi37 I published a new version (0.3.1) that uses I'll be leaving this issue open for now. |
@rossmartin thank you. I'm not familiar with ES6 enough to confirm if transpiling back to ES5 can affect the functionality. |
@luigi37 if you use babel to transpile your ES6 to ES5 it won't affect functionality. Not all mobile device webviews support ES6 so it would be much safer to transpile. |
Thank you. |
@luigi37 That would be a nice feature to have if you're using something like framework 7 & react without using react-scripts. Those that use Ionic it won't be of any benefit. I'll think about it - this may be a better candidate for a separate hook. |
Thanks Ross, |
This same issue is happening to me too, however its only happening to three files, all three files are 9 bytes and all say I am running an Ionic v1 app, so no Ionic v2 or ES issues to worry about. Just straight old AngularJS and JS. My system information:
|
I'm having the same issue, 1 file only has "undefined" |
Hi,
when I try uglify, it overwrites all .js files, but they contet is only one single word "undefined".
stripped debug log: cordova -d prepare
full debug log: uglify_debug.txt
uglify installed from npm
The text was updated successfully, but these errors were encountered: