marclaval / optimize-angular-app

Let's optimize an Angular application for production
http://mlaval.github.io/optimize-angular-app/
MIT License
57 stars 6 forks source link

What does build_closure_modules.js do exactly? #6

Closed steveblue closed 7 years ago

steveblue commented 7 years ago

Hey @mlaval thank you for such an excellent repo. This is a support request since you seem to be one of the few, if not only engineer who has cracked how to lazyload Angular NgModule with ClosureCompiler.

What are the problems that you are solving with this particular build script? optimize-angular-app/scripts/build_closure_modules.js

It seems like you are removing duplicate imports from the Manifests of the main and lazy loaded bundles and then building a new Manifest. Then you are writing custom exports. Can you please explain what the (self['_S']=self['_S']||[]) is for? I understand that it relates to the source maps and how System.JS is loading the bundles, not not sure exactly how.

I'm just looking for more clarification as I begin to write similar logic.

marclaval commented 7 years ago

Hi, there are some details in this issue: https://github.com/mlaval/optimize-angular-app/issues/2#issuecomment-284421250

optimize-angular-app/blob/master/scripts/build_closure_lazy.sh orchestrates steps 3, 4 and 5. optimize-angular-app/scripts/build_closure_modules.js implements step 4.

If you need more information, please let me know.

steveblue commented 7 years ago

I am still a little fuzzy on the SystemJS part. What problem does the polyfill solve and why do the source maps for each bundle need to be modified for the polyfill?