0

so I'm a little bit confused about the sequence of actions during build, specifically Angular's AOT compiler and how/where/what it does in the CSR process and which steps happens at the build/server/client.. This is how I understood it so far:

1- Build phase (when ng build): AOT compiler will compile the Angular app into a js code that will be used to render app later by the client and store it (with a copy of the index.html) in the dist/ folder.

2- When the client sends the request, server will simply just send it the contents of /dist that was generated at step 1 as it is.

3- Client will use the js code to render the app (generate page dynamically in index.html, whether eager or lazy etc) at runtime.

So, is my understanding correct? So a new code is basically generated twice (first the renderer is generated at build (as js code) then the actual code?

  • AOT is not about typescript. AOT is compiling your html to JS. And what is CSR? – Petr Averyanov Nov 12 '22 at 14:52
  • @PetrAveryanov Hi. I meant compiling the Angular app in general including the ts and html in a browser-friendly javascript code, based on [this](https://angular.io/guide/aot-compiler) article. CSR is Client Side Rendering – Heila Al-Mogren Nov 12 '22 at 15:01
  • @HeilaAl-Mogren you're almost right about everything but just want to point out that code is not generated twice, it only happens at build time, I'm not sure what you mean by "renderer is generated at build then the actual code", all the code to render components wiil be in your shipped js code and will be executed by browser. – Yogi Nov 15 '22 at 11:35

0 Answers0