0

I'm trying to obfuscate my Ionic code. Every question or post about uglifying angular.js code, tells that you should use annotated syntax for dependency injection, something that after obfuscation looks like this:

angular.module('App')
.controller('MyCtrl', ['$scope', '$state', function(a,b) { ...}])

But I'd like to experiment with not using this approach and still obfuscating the code by including angular.js in the obfuscation phase, so that angular providers would also be mangled and the code would look like this:

angular.module('App')
    .controller('MyCtrl', function(aX,bZ) { ...}])

Where (following the first example) aX is the mangled name for $scope and bZ correspond to the $state provider.

This approach would make it harder for someone who knows AngularJS trying to understand your code, since angular.js is also obfuscated (I mean, providers lost their original meaningfull names).

I have joined ionic.js + angular.js + myfiles.js and passed that thru Uglify2, but only got errors on running the app, mostly related to the angular injector service, but also about window been undefined and the like.

Has anyone done that before? Any working examples?

Fernando Fabreti
  • 4,277
  • 3
  • 32
  • 33
  • Well, for now, I don't know, but the documentation already said if you plan to minify your code, the `Implicit Annotation` method will break https://docs.angularjs.org/guide/di. – Olatunde Garuba Aug 10 '15 at 00:02
  • Documentation doesn't take into account obfuscation. It should not break if provider names were to be minified together with your code, I mean, names, here and there, would still be the same, just mangled. – Fernando Fabreti Aug 10 '15 at 10:47
  • You can check the documentation for version 1.2.26, the 'minifiers/obfuscators' was mentioned under the `Implicit Dependencies`. – Olatunde Garuba Aug 10 '15 at 11:21

0 Answers0