You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SinceVersion12.4.0ofthisplugin, we support the new _jsdom_-based Angular Universal API for Server Side Rendering (SSR). Please note that SSR *only* makes sense in specific scenarios, e. g. for customer-facing apps that need SEO.
284
+
285
+
To make use of SSR, you should enable SSR for **all** of your federation projects (e. g. theshellandthemicrofrontends).
286
+
287
+
#### Adding Angular Universal BEFORE adding Module Federation
288
+
289
+
If you start with a new project, you should add Angular Universal BEFORE adding Module Federation:
290
+
291
+
```
292
+
ng add @nguniversal/common --project yourProject
293
+
ng add @angular-architects/module-federation --project yourProject
294
+
```
295
+
296
+
Then, adjust the port in the generated ``server.ts``:
297
+
298
+
```typescript
299
+
const PORT = 5000;
300
+
```
301
+
302
+
Afterthis, you can compile and run your application:
npm i @angular-architects/module-federation@latest
317
+
```
318
+
319
+
2.Now, we need to disable asynchronous bootstrapping temporarily. While it's needed for Module Federation, the schematics provided by Angular Universal assume that Angular is bootstrapped in an traditional (synchronous) way. After using these Schematics, we have to enable asynchronous bootstrapping again:
320
+
321
+
```
322
+
ng g @angular-architects/module-federation:boot-async false --project yourProject
323
+
324
+
ng add @nguniversal/common --project yourProject
325
+
326
+
ng g @angular-architects/module-federation:boot-async true --project yourProject
327
+
```
328
+
329
+
3. As now we have both, Module Federation and Angular Universal, in place, we can integrate them with each other:
330
+
331
+
```
332
+
ng g @angular-architects/module-federation:nguniversal --project yourProject
Totryitout, you can checkout the ``main`` branch of our [example](https://github.com/manfredsteyer/module-federation-plugin-example). After installing the dependencies (``npm i``), you can repeat the steps for adding Angular Universal to an existing Module Federation project described above twice: Once for the _project shell and the port 5000_ and one more time for the _project mfe1 and port 3000_.
0 commit comments