-
Notifications
You must be signed in to change notification settings - Fork 15
Server side layer expansion
Server-side layer expansion is enabled by specifying the serverExpandLayers
loader extension config parameter.
When server-side layer expansion is enabled, the Aggregator will expand the layers for loader requested modules to include nested dependencies. The expanded dependencies will be added to the loader's module cache, which means that they will not be defined in the loader until either explicitly required, or until they are needed to resolve the dependencies of another module that is being defined.
Module dependencies that use a loader plugin will be included in server-expanded layers only if the plugin is the text plugin, or if the plugin delegates to the text plugin (i.e. it is listed in the textPluginDelegators
server-side AMC config property) or it delegates to the JavaScript module loader (i.e. it is listed in the jsPluginDelegators
server-side AMD config property). If the dependency is conditionalized by use of a has!
loader plugin, then the dependency will be included if the specified condition is satisfied using the features provided in the request (undefined features are treated as false).
Loader initiated requests for server-expanded layers include a URL parameter specifying the list of modules that have previously been requested so that those modules (and their expanded dependencies) may be omitted from the response. In order to keep the size of the list manageable, the list includes only those modules that have previously been requested explicitly. It does not include the expanded dependencies that were previously delivered to the client but not requested. The Aggregator calculates the expanded dependencies of the previously requested modules and excludes them from the expanded dependencies of the currently requested modules to determine which expanded dependencies will be included in the response layer. This can lead to inconsistencies when there are conditional dependencies specified using a has!
loader plugin and the defined features change between requests, leading to extra requests to load all the required dependencies. This situation is most likely to occur in conjunction with the application generated request for the initial bootstrap layer, before the code used to define features has been loaded and executed. To avoid this pitfall, it is recommended that you try to avoid conditional dependencies in your bootstrap layer as much as possible, and that you provide values in the request (using the has
URL parameter) for features that are needed to resolve those conditional dependencies that must exist in the bootstrap layer.
Server-side layer expansion and Require list expansion are different ways of achieving the same goal. Namely, to reduce or eliminate the cascade of requests resulting from dependency discovery that you get without any kind of dependency expansion. These two approaches are mutually exclusive. If both are specified, then server-side layer expansion will prevail.
This feature is new in version 1.2.2