4. Webpack
Allows us to use these modules in the browser
Supports both CommonJS and AMD
Supports loaders (load more than just Javascript)
http://webpack.github.io/docs/list-of-loaders.html
5. Ways to use CommonJS with
Angular
1. require() a factory function
2. require() an angular module
3. require() javascript that extends an existing app
8. Let’s see some demos
https://github.com/snapwich/lazy-angular-demo
checkout “sync” and “async” tags
https://github.com/snapwich/lazy-angular
a simple wrapper around angular.module
9. Code splitting
Happens automatically in Webpack with async requires
Most commonly implemented at client-side router but can
happen anywhere an async action can occur, such as in
event handlers or during directive life-cycles.
Can also be specified with multiple entry points
Can be optimized with additional Webpack plugins