4 ms·
We use angular with RequireJS, though we don't (yet) load any Angular modules lazily because it is not supported by Angular. There are workarounds (like https:/
by SanderMak 12y ago
We use angular with RequireJS, though we don't (yet) load any Angular modules lazily because it is not supported by Angular. There are workarounds (like https://github.com/marcoslin/angularAMD https://github.com/marcoslin/angularAMD) which I have no experience with. We do load external libs (like MathJax, which is comparatively huge) lazily where possible.
Our AMD modules are actually TypeScript modules that generate the AMD wrapper. Works great, and makes for a very clean and modular codebase. In the end, we use r.js to concat and minify most of it (everything except the lazily loaded libs) down to a single file. Including Angular templates, using https://www.npmjs.org/package/gulp-angular-templatecache https://www.npmjs.org/package/gulp-angular-templatecache which can output the templates as initialization scripts inside and AMD wrapper as well.
- aikah 12y agoBut you're not using async (angular)module loading.Angular modules cannot be loaded async in.You might be able to inject services after the app is bootstrapped but it involves using global variables,which totally defeat the purpose of dependency injection.
- SanderMak 12y agoIndeed, that's what my first sentence implies. Note that this doesn't prevent you from lazily loading other JS libs when using them inside Angular modules.