Skip to content

Commit

Permalink
Add a define to module manager so that we can control module loading …
Browse files Browse the repository at this point in the history
…behaviors.

RELNOTES: Add a define to module manager so that we can control module loading behaviors.

PiperOrigin-RevId: 300805537
  • Loading branch information
Closure Team authored and 12wrigja committed Mar 14, 2020
1 parent 5845fb1 commit 49624ab
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions closure/goog/module/modulemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,27 @@ goog.module.ModuleManager.prototype.setAllModuleInfoString = function(
this.maybeFinishBaseLoad_();
};

/**
* @define {boolean} Whether subtractive module loading is enabled. The main
* difference is the module graph is no longer in the client, i.e.,
* setAllModuleInfoString is never been called. Instead, the module manager
* will keep track of the already loaded modules, and add them to the subsequent
* loader requests. The serving system is able to figure out the list of desired
* modules.
*
* The default is false, but new code is encouraged to use this.
* Search, Gmail, and many Google applications has been using subtractive
* module loading for years and see significantly performance benefits.
*/
goog.module.ModuleManager.SUBTRACTIVE_MODULE_LOADING =
goog.define('goog.module.ModuleManager.SUBTRACTIVE_MODULE_LOADING', false);

/** @override */
goog.module.ModuleManager.prototype.getModuleInfo = function(id) {
if (goog.module.ModuleManager.SUBTRACTIVE_MODULE_LOADING &&
!(id in this.moduleInfoMap)) {
this.moduleInfoMap[id] = new goog.module.ModuleInfo([], id);
}
return this.moduleInfoMap[id];
};

Expand Down

0 comments on commit 49624ab

Please sign in to comment.