Skip to content

Commit 0b0ebf1

Browse files
committed
update to angular 14 and mf 14.3
1 parent 2045067 commit 0b0ebf1

14 files changed

Lines changed: 113 additions & 118 deletions

package-lock.json

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"private": true,
2020
"dependencies": {
21-
"@angular-architects/module-federation": "^14.3.2",
21+
"@angular-architects/module-federation": "^14.3.3",
2222
"@angular/animations": "^14.0.0",
2323
"@angular/common": "^14.0.0",
2424
"@angular/compiler": "^14.0.0",

projects/shell/src/app/app.component.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
<ul>
22
<li><img src="../assets/angular.png" width="50"></li>
33
<li><a routerLink="/">Home</a></li>
4-
<li><a routerLink="/flights">Flights</a></li>
5-
<li><a routerLink="/bookings">Bookings</a></li>
6-
7-
<!-- <li *ngFor="let mfe of microfrontends"><a [routerLink]="mfe.routePath">{{mfe.displayName}}</a></li> -->
8-
<!-- <li><a routerLink="/config">Config</a></li> -->
4+
<li *ngFor="let remote of remotes"><a [routerLink]="remote.routePath">{{remote.displayName}}</a></li>
5+
<li><a routerLink="/config">Config</a></li>
96
</ul>
107

118
<router-outlet></router-outlet>
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
1+
import { getManifest, Manifest } from '@angular-architects/module-federation';
12
import { Component, OnInit } from '@angular/core';
23
import { Router } from '@angular/router';
3-
import { buildRoutes } from '../menu-utils';
4+
import { CustomManifest, CustomRemoteConfig } from './utils/config';
5+
import { buildRoutes } from './utils/routes';
46

57
@Component({
68
selector: 'app-root',
79
templateUrl: './app.component.html'
810
})
911
export class AppComponent implements OnInit {
1012

13+
remotes: CustomRemoteConfig[] = [];
14+
1115
constructor(
1216
private router: Router) {
1317
}
1418

1519
async ngOnInit(): Promise<void> {
16-
// const routes = buildRoutes(this.microfrontends);
17-
// this.router.resetConfig(routes);
20+
const manifest = getManifest() as CustomManifest;
21+
22+
// Hint: Move this to an APP_INITIALIZER
23+
// to avoid issues with deep linking
24+
const routes = buildRoutes(manifest);
25+
this.router.resetConfig(routes);
26+
27+
this.remotes = Object.values(manifest);
1828
}
1929
}
2030

projects/shell/src/app/app.routes.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ export const APP_ROUTES: Routes = [
1313
path: 'config',
1414
component: ConfigComponent
1515
},
16-
{
17-
path: 'flights',
18-
loadChildren: () => loadRemoteModule({
19-
type: 'manifest',
20-
remoteName: 'mfe1',
21-
exposedModule: './Module'
22-
})
23-
.then(m => m.FlightsModule)
24-
},
25-
{
26-
path: 'bookings',
27-
loadChildren: () => loadRemoteModule({
28-
type: 'manifest',
29-
remoteName: 'mfe2',
30-
exposedModule: './Module'
31-
})
32-
.then(m => m.BookingsModule)
33-
},
16+
// {
17+
// path: 'flights',
18+
// loadChildren: () => loadRemoteModule({
19+
// type: 'manifest',
20+
// remoteName: 'mfe1',
21+
// exposedModule: './Module'
22+
// })
23+
// .then(m => m.FlightsModule)
24+
// },
25+
// {
26+
// path: 'bookings',
27+
// loadChildren: () => loadRemoteModule({
28+
// type: 'manifest',
29+
// remoteName: 'mfe2',
30+
// exposedModule: './Module'
31+
// })
32+
// .then(m => m.BookingsModule)
33+
// },
3434
];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<h1>Config</h1>
22

3-
<pre style="font-size:20px">{{ config | json }}</pre>
3+
<pre style="font-size:20px; background-color: whitesmoke;">{{ manifest | json }}</pre>
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1+
import { getManifest } from '@angular-architects/module-federation';
12
import { Component, OnInit } from '@angular/core';
2-
import { LookupService } from '../microfrontends/lookup.service';
3-
import { Microfrontend } from '../microfrontends/microfrontend';
3+
import { CustomManifest } from '../utils/config';
44

55
@Component({
66
selector: 'app-config',
77
templateUrl: './config.component.html'
88
})
9-
export class ConfigComponent implements OnInit {
9+
export class ConfigComponent {
1010

11-
constructor(private lookupService: LookupService) { }
12-
13-
config: Microfrontend[];
14-
15-
async ngOnInit() {
16-
this.config = await this.lookupService.lookup();
17-
}
11+
manifest = getManifest() as CustomManifest;
1812

1913
}

projects/shell/src/app/microfrontends/lookup.service.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

projects/shell/src/app/microfrontends/microfrontend.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Manifest, RemoteConfig } from "@angular-architects/module-federation";
2+
3+
export type CustomRemoteConfig = RemoteConfig & {
4+
exposedModule: string;
5+
displayName: string;
6+
routePath: string;
7+
ngModuleName: string;
8+
};
9+
10+
export type CustomManifest = Manifest<CustomRemoteConfig>;

0 commit comments

Comments
 (0)