lazy angular w/ webpack

10
Lazy Angular with Webpack Rich Snapp < [email protected] >

Upload: rich-snapp

Post on 16-Jul-2015

1.199 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Lazy angular w/ webpack

Lazy Angular with

WebpackRich Snapp <[email protected]>

Page 2: Lazy angular w/ webpack

CommonJS require

Is easy

Page 3: Lazy angular w/ webpack

Async require

Is sometimes useful

Page 4: Lazy angular w/ webpack

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

Page 5: Lazy angular w/ webpack

Ways to use CommonJS with

Angular

1. require() a factory function

2. require() an angular module

3. require() javascript that extends an existing app

Page 6: Lazy angular w/ webpack

Ways to use CommonJS with

Angular

Page 7: Lazy angular w/ webpack

Extending an Angular app after

bootstrap for lazy-loading

Page 8: Lazy angular w/ webpack

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

Page 9: Lazy angular w/ webpack

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

Page 10: Lazy angular w/ webpack

Other mentions

https://github.com/ocombe/ocLazyLoad

https://github.com/petehunt/webpack-howto

How Instagram.com Works

https://www.youtube.com/watch?v=VkTCL6Nqm6Y