cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject js commit: moving to TreeTransformer and adding a quick substitution for Android navigator.app clobber
Date Wed, 14 May 2014 21:55:43 GMT
Repository: cordova-js
Updated Branches:
  refs/heads/master 7e845f3b8 -> fbe1b731f


moving to TreeTransformer and adding a quick substitution for Android navigator.app clobber


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/fbe1b731
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/fbe1b731
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/fbe1b731

Branch: refs/heads/master
Commit: fbe1b731f639f64b27fb05c97d32c1e56ac747a0
Parents: 7e845f3
Author: Anis Kadri <anis@apache.org>
Authored: Wed May 14 14:55:37 2014 -0700
Committer: Anis Kadri <anis@apache.org>
Committed: Wed May 14 14:55:37 2014 -0700

----------------------------------------------------------------------
 tasks/lib/require-tr.js | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/fbe1b731/tasks/lib/require-tr.js
----------------------------------------------------------------------
diff --git a/tasks/lib/require-tr.js b/tasks/lib/require-tr.js
index 8964aee..2c417b4 100644
--- a/tasks/lib/require-tr.js
+++ b/tasks/lib/require-tr.js
@@ -26,6 +26,7 @@
 
 var fs = require('fs');
 var path = require('path');
+var util = require('util');
 var through = require('through');
 var UglifyJS = require('uglify-js');
 var root = fs.realpathSync(path.join(__dirname, '..', '..'));
@@ -42,9 +43,10 @@ var requireTr = {
 
     function end() {
       // getting rid of define and require properties of cordova
-     // if(file.match(/cordova.js$/)) {
-     //   data = data.replace(/ *(define:define|require:require),\n/, '');
-     // }
+      if(file.match(/android\/platform.js$/)) {
+        data = data.replace(/modulemapper\.clobbers.*\n/,
+                            util.format('navigator.app = require("%s/src/android/plugin/android/app")',
root));
+      }
       this.queue(_updateRequires(data));
       this.queue(null);
     }
@@ -72,7 +74,7 @@ function _updateRequires(code) {
   
   var ast = UglifyJS.parse(code);
 
-  var walker = new UglifyJS.TreeWalker(function(node) {
+  var before = new UglifyJS.TreeTransformer(function(node, descend) {
 
     // check all function calls
     if(node instanceof UglifyJS.AST_Call) {
@@ -117,11 +119,13 @@ function _updateRequires(code) {
             }
           }
         }
+        descend(node, this);
+        return node;
       }
     }
   });
 
-  ast.walk(walker);
+  ast.transform(before, null);
 
   var stream = UglifyJS.OutputStream({beautify:true});
 


Mime
View raw message