cordova-uglify: js files have content undefined

Hi, when I try uglify, it overwrites all .js files, but they contet is only one single word “undefined”.

image

stripped debug log: cordova -d prepare

No scripts found for hook "before_prepare".
Checking config.xml and package.json for saved platforms that haven't been added to the project
Config.xml and package.json platforms are the same. No pkg.json modification.
Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
Failed to require PlatformApi instance for platform "browser". Using polyfill instead.
Checking config.xml for saved plugins that haven't been added to the project
Checking for any plugins added to the project that have not been installed in browser platform
No differences found between plugins added to project and installed in browser platform. Continuing...
Generating config.xml from defaults for platform "browser"
Executing script found in hooks directory for hook "after_prepare": hooks\after_prepare\uglify.js
Running command: "C:\Program Files\nodejs\node.exe" D:\NetBeansProjects\ReturnReporting\hooks\after_prepare\uglify.js D:\NetBeansProjects\ReturnReporting
processFiles err: Error: ENOENT: no such file or directory, scandir 'D:\NetBeansProjects\ReturnReporting\platforms\browser\www\module'
uglifying js file D:\NetBeansProjects\ReturnReporting\platforms\browser\www\controller\BaseController.js
uglifying js file D:\NetBeansProjects\ReturnReporting\platforms\browser\www\controller\Home.controller.js
uglifying js file D:\NetBeansProjects\ReturnReporting\platforms\browser\www\controller\Login.controller.js
uglifying js file D:\NetBeansProjects\ReturnReporting\platforms\browser\www\controller\Settings.controller.js
minifying css file D:\NetBeansProjects\ReturnReporting\platforms\browser\www\css\style.css
uglifying js file D:\NetBeansProjects\ReturnReporting\platforms\browser\www\Component.js
encountered a .xml file, not compressing it
uglifying js file D:\NetBeansProjects\ReturnReporting\platforms\browser\www\confighelper.js
uglifying js file D:\NetBeansProjects\ReturnReporting\platforms\browser\www\controller\App.controller.js
uglifying js file D:\NetBeansProjects\ReturnReporting\platforms\browser\www\cordova.js
uglifying js file D:\NetBeansProjects\ReturnReporting\platforms\browser\www\exec.js
encountered a .html file, not compressing it
encountered a .json file, not compressing it

full debug log: uglify_debug.txt

uglify installed from npm

{ name: 'cordova-uglify',
 description: 'Cordova hook that allows you to uglify or minify your apps JavaScript and CSS.',
 'dist-tags': { latest: '0.2.8' },
 versions: 
  [ '0.0.1',
    '0.0.2',
    '0.0.3',
    '0.0.4',
    '0.0.5',
    '0.0.6',
    '0.0.7',
    '0.0.8',
    '0.0.9',
    '0.1.0',
    '0.1.1',
    '0.1.2',
    '0.1.3',
    '0.1.4',
    '0.1.5',
    '0.1.6',
    '0.1.7',
    '0.1.8',
    '0.1.9',
    '0.2.0',
    '0.2.1',
    '0.2.2',
    '0.2.3',
    '0.2.4',
    '0.2.5',
    '0.2.6',
    '0.2.7',
    '0.2.8' ],
 maintainers: [ 'rossmartin <rmartin311@gmail.com>' ],
 time: 
  { modified: '2017-01-19T15:51:35.841Z',
    created: '2014-06-18T03:56:05.284Z',
    '0.0.1': '2014-06-18T03:56:05.284Z',
    '0.0.2': '2014-06-18T05:35:27.107Z',
    '0.0.3': '2014-06-18T05:42:27.368Z',
    '0.0.4': '2014-06-18T05:49:43.994Z',
    '0.0.5': '2014-06-18T05:52:58.761Z',
    '0.0.6': '2014-06-19T05:21:03.197Z',
    '0.0.7': '2014-06-22T22:23:42.514Z',
    '0.0.8': '2014-06-23T00:22:46.231Z',
    '0.0.9': '2014-11-12T05:09:29.435Z',
    '0.1.0': '2014-11-12T05:14:26.594Z',
    '0.1.1': '2014-11-12T05:24:53.626Z',
    '0.1.2': '2014-12-19T15:56:15.972Z',
    '0.1.3': '2014-12-19T16:12:12.345Z',
    '0.1.4': '2015-01-12T22:09:19.752Z',
    '0.1.5': '2015-04-09T20:55:45.840Z',
    '0.1.6': '2015-06-22T14:47:17.993Z',
    '0.1.7': '2015-07-11T02:08:10.764Z',
    '0.1.8': '2015-07-11T02:31:39.325Z',
    '0.1.9': '2015-08-03T21:01:21.157Z',
    '0.2.0': '2015-09-30T13:38:50.084Z',
    '0.2.1': '2015-10-03T16:06:54.283Z',
    '0.2.2': '2015-12-13T22:54:54.170Z',
    '0.2.3': '2015-12-16T01:08:51.901Z',
    '0.2.4': '2016-07-15T15:12:03.110Z',
    '0.2.5': '2016-09-11T17:32:27.083Z',
    '0.2.6': '2016-10-24T14:35:28.131Z',
    '0.2.7': '2016-11-27T04:43:01.635Z',
    '0.2.8': '2017-01-19T15:51:35.841Z' },
 homepage: 'https://github.com/rossmartin/cordova-uglify',
 keywords: [ 'cordova', 'uglify', 'minify', 'hook', 'hooks' ],
 author: 'Ross Martin',
 bugs: { url: 'https://github.com/rossmartin/cordova-uglify/issues' },
 license: 'MIT',
 readmeFilename: 'README.md',
 repository: 
  { type: 'git',
    url: 'git+https://github.com/rossmartin/cordova-uglify.git' },
 users: 
  { okmogwai: true,
    batosai: true,
    cnring18: true,
    gdevise: true,
    ebbm: true },
 version: '0.2.8',
 dependencies: 
  { 'clean-css': '3.4.8',
    'ng-annotate': '0.15.4',
    shelljs: '^0.7.0',
    'uglify-js': '2.4.14' },
 scripts: 
  { postinstall: 'node scripts/install.js',
    postuninstall: 'node scripts/uninstall.js' },
 gitHead: '395775651d1b3a5f3625e4fa3d3ec2ca823664b1',
 dist: 
  { shasum: '5aa9f69797da4c9d51c2f5184f4dcf0510d1b327',
    tarball: 'https://registry.npmjs.org/cordova-uglify/-/cordova-uglify-0.2.8.tgz' },
 directories: {} }

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Comments: 26 (11 by maintainers)

Most upvoted comments

I’m trying https://github.com/mishoo/UglifyJS2/tree/harmony

And it seems to solve the issue.

In uglify hook I changed this line: var UglifyJS = require(path.join(dependencyPath, ‘uglify-js’)); to var UglifyJS = require(path.join(dependencyPath, ‘uglify-es’));

So far seems ok, will test more extensively

This same issue is happening to me too, however its only happening to three files, all three files are 9 bytes and all say undefined.

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:

Cordova CLI: 8.0.0
Gulp version:  CLI version 3.9.1
Gulp local:   Local version 3.9.1
Ionic Version: 1.3.4
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
OS: Windows 7 SP1
Node Version: v6.10.3

Cordova-android: 7.1.1

@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: "uglifyJsOptions": { "fromString": true }