cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jasongin <...@git.apache.org>
Subject [GitHub] cordova-lib pull request: CB-11194 Improve cordova load time
Date Tue, 03 May 2016 16:35:51 GMT
Github user jasongin commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/434#discussion_r61912923
  
    --- Diff: cordova-common/cordova-common.js ---
    @@ -17,26 +17,40 @@
         under the License.
     */
     
    -exports = module.exports = {
    -    events: require('./src/events'),
    -    superspawn: require('./src/superspawn'),
    -
    -    ActionStack: require('./src/ActionStack'),
    -    CordovaError: require('./src/CordovaError/CordovaError'),
    -    CordovaLogger: require('./src/CordovaLogger'),
    -    CordovaExternalToolErrorContext: require('./src/CordovaError/CordovaExternalToolErrorContext'),
    -    PlatformJson: require('./src/PlatformJson'),
    -    ConfigParser: require('./src/ConfigParser/ConfigParser.js'),
    -
    -    PluginInfo: require('./src/PluginInfo/PluginInfo.js'),
    -    PluginInfoProvider: require('./src/PluginInfo/PluginInfoProvider.js'),
    -    
    -    PluginManager: require('./src/PluginManager'),
    -
    -    ConfigChanges: require('./src/ConfigChanges/ConfigChanges.js'),
    -    ConfigKeeper: require('./src/ConfigChanges/ConfigKeeper.js'),
    -    ConfigFile: require('./src/ConfigChanges/ConfigFile.js'),
    -    mungeUtil: require('./src/ConfigChanges/munge-util.js'),
    -
    -    xmlHelpers: require('./src/util/xml-helpers')
    -};
    +function addProperty(obj, property, modulePath) {
    +    var val = null;
    +
    +    // Add properties as getter to delay load the modules on first invocation
    +    Object.defineProperty(obj, property, {
    +        configurable: true,
    +        get: function () {
    +            val = val || require(modulePath);
    +            ob[property] = val;
    --- End diff --
    
    Also, there should be no need to use the 'val' cache if you are overwriting obj[property].


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message