ocombe / ocLazyLoad

Lazy load modules & components in AngularJS
https://oclazyload.readme.io
MIT License
2.63k stars 510 forks source link

Fixes hot reloading via systemjs-hot-reloader #291

Closed circlingthesun closed 8 years ago

circlingthesun commented 8 years ago

JSPM/SystemJS allows for hot module reloads via https://github.com/capaj/systemjs-hot-reloader. To get angular to see any module changes angular needs to be bootstrapped again. This can be achieved by save a copy of the original bootstrapped element before bootstrapping occurred. The current bootstrapped element then needs to be removed and replaced with another copy of the original. Once a fresh element is in place, angular.bootstrap can be called again and all changes should show.

When using ocLazyLoad to wire up modules loaded by JSPM this approach doesn't work. The reason is that ocLazyLoad keeps track of what angular modules have already been loaded and prevents them from being loaded again. This PR resets this state every time angular is bootstrapped so that modules will be wired up again after bootstrapping angular for a 2nd time.

kination commented 8 years ago

+1 It looks good. How do you think @ocombe? Test/examples are running clearly.

ocombe commented 8 years ago

yes, it won't hurt anything anyway :)

ocombe commented 7 years ago

I just released 1.1.0 with this, I think I did it right, I haven't published a new version on this repo for ages, let me know if it works