Skip to content

Commit 663cf11

Browse files
committed
Step 2 - Configure routes: two routes in host-application, update mf1-application for dependency-free build.
1 parent 10b85e0 commit 663cf11

24 files changed

+114
-12
lines changed

apps/host-application/project.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
"mf": {
1616
"externalList": "build-external-list.json",
1717
"skipList": "build-skip-list.json",
18-
"esPlugins": ["tools/esbuild-plugin/test-external-plugin.ts"]
18+
"esPlugins": ["tools/esbuild-plugin/test-external-plugin.ts"],
19+
"remoteEntry": {
20+
"firstRemote": "http://localhost:4201/"
21+
}
1922
},
2023
"outputPath": "dist/apps/host-application",
2124
"index": "apps/host-application/src/index.html",
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
<app-nx-welcome></app-nx-welcome>
21
<router-outlet></router-outlet>

apps/host-application/src/app/app.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { Component } from '@angular/core';
22
import { RouterModule } from '@angular/router';
3-
import { NxWelcomeComponent } from './nx-welcome.component';
43

54
@Component({
6-
imports: [NxWelcomeComponent, RouterModule],
5+
imports: [RouterModule],
76
selector: 'app-root',
87
templateUrl: './app.component.html',
98
styleUrl: './app.component.css',

apps/host-application/src/app/app.routes.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { RenderMode, ServerRoute } from '@angular/ssr';
33
export const serverRoutes: ServerRoute[] = [
44
{
55
path: '**',
6-
renderMode: RenderMode.Prerender,
6+
renderMode: RenderMode.Server,
77
},
88
];
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
import { Route } from '@angular/router';
22

3-
export const appRoutes: Route[] = [];
3+
export const appRoutes: Route[] = [{
4+
path: '',
5+
loadComponent: () => import('./nx-welcome.component').then(r => r.NxWelcomeComponent)
6+
}];

apps/mf1-application/project.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111
"executor": "./dist/libs/nx-angular-mf:build",
1212
"outputs": ["{options.outputPath}"],
1313
"options": {
14+
"mf": {
15+
"externalList": "build-external-list.json",
16+
"skipList": "build-skip-list.json",
17+
"esPlugins": ["tools/esbuild-plugin/test-external-plugin.ts"],
18+
"exposes": {
19+
"FirstRemoteRoute": "/apps/mf1-application/src/app/remote/first/index.ts",
20+
"SecondRemoteRoute": "/apps/mf1-application/src/app/remote/second/index.ts"
21+
}
22+
},
1423
"outputPath": "dist/apps/mf1-application",
1524
"index": "apps/mf1-application/src/index.html",
1625
"browser": "apps/mf1-application/src/main.ts",
@@ -52,6 +61,9 @@
5261
"serve": {
5362
"dependsOn": ["^build"],
5463
"executor": "./dist/libs/nx-angular-mf:serve",
64+
"options": {
65+
"port": 4201
66+
},
5567
"configurations": {
5668
"production": {
5769
"buildTarget": "mf1-application:build:production"
@@ -81,6 +93,7 @@
8193
"serve-static": {
8294
"executor": "@nx/web:file-server",
8395
"options": {
96+
"port": 4001,
8497
"buildTarget": "mf1-application:build",
8598
"staticFilePath": "dist/apps/mf1-application/browser",
8699
"spa": true
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
<app-nx-welcome></app-nx-welcome>
21
<router-outlet></router-outlet>

apps/mf1-application/src/app/app.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { Component } from '@angular/core';
22
import { RouterModule } from '@angular/router';
3-
import { NxWelcomeComponent } from './nx-welcome.component';
43

54
@Component({
6-
imports: [NxWelcomeComponent, RouterModule],
5+
imports: [RouterModule],
76
selector: 'app-root',
87
templateUrl: './app.component.html',
98
styleUrl: './app.component.css',
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
import { Route } from '@angular/router';
2+
import { NxWelcomeComponent } from './nx-welcome.component';
23

3-
export const appRoutes: Route[] = [];
4+
export const appRoutes: Route[] = [
5+
{
6+
path: '',
7+
component: NxWelcomeComponent,
8+
},
9+
{
10+
path: 'first',
11+
loadChildren: () => import('./remote/first').then((r) => r.firstRoutes),
12+
},
13+
];

apps/mf1-application/src/app/remote/first/first.component.css

Whitespace-only changes.

0 commit comments

Comments
 (0)