Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the main purpose of platform-server module in Angular 2?

When looking AOT (ahead of time compilation) docs https://angular.io/docs/ts/latest/cookbook/aot-compiler.html#!#compile , there is a dependency on platform-server , what is the purpose of it ? seems only compiler-cli required to run the compiler tool

like image 965
asotog Avatar asked Oct 24 '16 16:10

asotog


2 Answers

The @angular/platform-server provides the server platform that supports the runtime compiler and it only as a dependency of compiler-cli. In the future, we will be installing compiler-cli that don't need it as here.

like image 177
Ha Hoang Avatar answered Nov 18 '22 07:11

Ha Hoang


This question is related to Angular V2 but now Angular V4.0.0 Almost release (in the time of writing it is in RC-3) and @Angular/platform-server changed a lot

So Just for the reference

based on this link: https://github.com/angular/angular/issues/13822

some part of Angular Universal(API part) is merged to @angular/Core some another part is now rewritten with the name of @angular/platform-server

an as @mikezks mentioned on that topic https://github.com/angular/angular/issues/13822#issuecomment-286742244 all the magic is renderModuleFactory (that is the whole magic behind SSR).

so from now: @angular/platfomr-server is for server side rendering of Angular and generating HTML pages(in NodeJS)

like image 38
Mahmood Sajjadi Avatar answered Nov 18 '22 05:11

Mahmood Sajjadi