Revert lazy loading of modules.

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

Branch: refs/heads/no-lazy-load
Commit: 133d8d196b8dbdb4a612a464873ab8851fd6f9b3
Parents: e69b9e4
Author: filmaj <maj....@gmail.com>
Authored: Wed Jun 7 14:43:29 2017 -0500
Committer: filmaj <maj....@gmail.com>
Committed: Fri Jun 9 08:58:46 2017 -0500

----------------------------------------------------------------------
 cordova-lib.js         | 32 ++++++++------------------------
 src/plugman/plugman.js | 19 +++++--------------
 2 files changed, 13 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/133d8d19/cordova-lib.js
----------------------------------------------------------------------
diff --git a/cordova-lib.js b/cordova-lib.js
index 1252412..7a51ed7 100644
--- a/cordova-lib.js
+++ b/cordova-lib.js
@@ -17,21 +17,7 @@
     under the License.
 */
 
-// For now expose plugman and cordova just as they were in the old repos
-
-
-function addProperty(obj, property, modulePath) {
-    // Add properties as getter to delay load the modules on first invocation
-    Object.defineProperty(obj, property, {
-        configurable: true,
-        get: function () {
-            var module = require(modulePath);
-            // We do not need the getter any more
-            obj[property] = module;
-            return module;
-        }
-    });
-}
+var common = require('cordova-common');
 
 exports = module.exports = {
     set binname(name) {
@@ -40,13 +26,11 @@ exports = module.exports = {
     get binname() {
         return this.cordova.binname;
     },
-    get events() { return require('cordova-common').events },
-    get configparser() { return require('cordova-common').ConfigParser },
-    get PluginInfo() { return require('cordova-common').PluginInfo },
-    get CordovaError() { return require('cordova-common').CordovaError }
-
+    events: common.events,
+    configparser: common.ConfigParser,
+    PluginInfo: common.PluginInfo,
+    CordovaError: common.CordovaError,
+    plugman: require('./src/plugman/plugman'),
+    cordova: require('./src/cordova/cordova'),
+    cordova_platforms: require('./src/platforms/platforms')
 };
-
-addProperty(module.exports, 'plugman', './src/plugman/plugman');
-addProperty(module.exports, 'cordova', './src/cordova/cordova');
-addProperty(module.exports, 'cordova_platforms', './src/platforms/platforms');
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/133d8d19/src/plugman/plugman.js
----------------------------------------------------------------------
diff --git a/src/plugman/plugman.js b/src/plugman/plugman.js
index 3a97824..63102a4 100644
--- a/src/plugman/plugman.js
+++ b/src/plugman/plugman.js
@@ -23,35 +23,26 @@ var events = require('cordova-common').events;
 var Q = require('q');
 
 function addProperty(o, symbol, modulePath, doWrap) {
-    var val = null;
+    var modewl = require(modulePath);
 
     if (doWrap) {
         o[symbol] = function() {
-            val = val || require(modulePath);
             if (arguments.length && typeof arguments[arguments.length - 1] === 
'function') {
                 // If args exist and the last one is a function, it's the 
callback.
                 var args = Array.prototype.slice.call(arguments);
                 var cb = args.pop();
-                val.apply(o, args).done(function(result) {cb(undefined, 
result);}, cb);
+                modewl.apply(o, args).done(function(result) {cb(undefined, 
result);}, cb);
             } else {
-                val.apply(o, arguments).done(null, function(err){ throw err; 
});
+                modewl.apply(o, arguments).done(null, function(err){ throw 
err; });
             }
         };
     } else {
         // The top-level plugman.foo
-        Object.defineProperty(o, symbol, {
-            configurable: true,
-            get : function() { val = val || require(modulePath); return val; },
-            set : function(v) { val = v; }
-        });
+        o[symbol] = modewl;
     }
 
     // The plugman.raw.foo
-    Object.defineProperty(o.raw, symbol, {
-        configurable: true,
-        get : function() { val = val || require(modulePath); return val; },
-        set : function(v) { val = v; }
-    });
+    o.raw[symbol] = modewl;
 }
 
 var plugman = {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org

Reply via email to