mozilla-b2g/gaia-email-libs-and-more — pull request #151 by jrburke (2013-03-21 00:40:23+00:00)
Title: Bug 852710: defer loading protocol modules until first use

Since the dynamic load introduces a level of indent for some files, it may be easier to do the comparison online on github using the `?w=1` option to remove whitespace diffs. For example:
https://github.com/jrburke/gaia-email-libs-and-more/compare/onlinedelay?w=1

Notable changes:

* The activesync modules now lazy load wbxml and the activesync/protocol module via "lazyInit" wrapping functions for many of the methods. For activesync/codepages constant values, they now use the more granular activesync/codepages/* modules that were part of a [recent mozilla-b2g/jsas commit](https://github.com/mozilla-b2g/jsas/commit/d5370e2f555223834ab78abc54ce2201cf86e808) (and the deps/activesync submodule was updated to this version).
* mailapi/activesync/account now has a `withConnection` method that will dynamically create the connection when needed, and the `lazyInit` wrapper functions will call this once the activesync stuff has loaded.
* The imap and smtp modules were modified to dynamically load the protocol modules and chew modules just in the methods that needed them.
* mailchew-strings is a new module that handles receiving the i18n strings. This allowed delayed loading of mailchew.js since mailapi/mailbridge only needed the strings up front.
mailchew was modified to depend on mailchew-strings.
* alameda was updated to fix a bug to not fetch duplicate URLs.
* end.js was updated to point many modules to the same build layer. This allows the dependencies in the modules to stay granular but still result in layered loads.
* scripts/copy-to-gaia.js introduces about seven more build layers, so that loading can be done very granularly, but still in chunks to avoid too many individual script loads.

`make all-tests` still shows all tests passing with this change.