Skip to content

Commit

Permalink
Configure routing
Browse files Browse the repository at this point in the history
  • Loading branch information
jogelin committed Mar 2, 2024
1 parent 0b6fa13 commit f1fec04
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 21 deletions.
32 changes: 30 additions & 2 deletions apps/host/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,36 @@ import { NxWelcomeComponent } from './nx-welcome.component';
standalone: true,
imports: [NxWelcomeComponent, RouterModule],
selector: 'nx-nf-root',
template: `<nx-nf-nx-welcome></nx-nf-nx-welcome>
<router-outlet></router-outlet>`,
template: `
<header class="bg-white">
<nav
class="mx-auto flex max-w-7xl items-center justify-between p-6 lg:px-8"
aria-label="Global"
>
<div class="hidden lg:flex lg:gap-x-12">
<a
routerLink="/home"
class="text-sm font-semibold leading-6 text-gray-900"
>Home</a
>
<a
routerLink="/my-account"
class="text-sm font-semibold leading-6 text-gray-900"
>My Account</a
>
</div>
<div class="hidden lg:flex lg:flex-1 lg:justify-end">
<a
routerLink="/login"
class="text-sm font-semibold leading-6 text-gray-900"
>Log in <span aria-hidden="true">&rarr;</span></a
>
</div>
</nav>
</header>
<router-outlet></router-outlet>
`,
styles: ``,
})
export class AppComponent {
Expand Down
28 changes: 27 additions & 1 deletion apps/host/src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
import { Route } from '@angular/router';
import { loadRemoteModule } from '@angular-architects/native-federation';

export const appRoutes: Route[] = [];
export const appRoutes: Route[] = [
{
path: '',
redirectTo: 'home',
pathMatch: 'full',
},
{
path: 'home',
loadChildren: () =>
loadRemoteModule('mfHome', './routes').then(({ appRoutes }) => appRoutes),
},
{
path: 'login',
loadChildren: () =>
loadRemoteModule('mfLogin', './routes').then(
({ appRoutes }) => appRoutes
),
},
{
path: 'my-account',
loadChildren: () =>
loadRemoteModule('mfAccount', './routes').then(
({ appRoutes }) => appRoutes
),
},
];
16 changes: 11 additions & 5 deletions apps/mf-account/federation.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
const { withNativeFederation, shareAll } = require('@angular-architects/native-federation/config');
const {
withNativeFederation,
shareAll,
} = require('@angular-architects/native-federation/config');

module.exports = withNativeFederation({

name: 'mf-account',

exposes: {
'./routes': './apps/mf-account/src/app/app.routes.ts',
'./Component': './apps/mf-account/src/app/app.component.ts',
},

shared: {
...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
...shareAll({
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
}),
},

skip: [
Expand All @@ -18,6 +25,5 @@ module.exports = withNativeFederation({
'rxjs/testing',
'rxjs/webSocket',
// Add further packages you don't need at runtime
]

],
});
8 changes: 7 additions & 1 deletion apps/mf-account/src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { Route } from '@angular/router';

export const appRoutes: Route[] = [];
export const appRoutes: Route[] = [
{
path: '',
loadComponent: () =>
import('./app.component').then(({ AppComponent }) => AppComponent),
},
];
16 changes: 11 additions & 5 deletions apps/mf-home/federation.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
const { withNativeFederation, shareAll } = require('@angular-architects/native-federation/config');
const {
withNativeFederation,
shareAll,
} = require('@angular-architects/native-federation/config');

module.exports = withNativeFederation({

name: 'mf-home',

exposes: {
'./routes': './apps/mf-home/src/app/app.routes.ts',
'./Component': './apps/mf-home/src/app/app.component.ts',
},

shared: {
...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
...shareAll({
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
}),
},

skip: [
Expand All @@ -18,6 +25,5 @@ module.exports = withNativeFederation({
'rxjs/testing',
'rxjs/webSocket',
// Add further packages you don't need at runtime
]

],
});
8 changes: 7 additions & 1 deletion apps/mf-home/src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { Route } from '@angular/router';

export const appRoutes: Route[] = [];
export const appRoutes: Route[] = [
{
path: '',
loadComponent: () =>
import('./app.component').then(({ AppComponent }) => AppComponent),
},
];
16 changes: 11 additions & 5 deletions apps/mf-login/federation.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
const { withNativeFederation, shareAll } = require('@angular-architects/native-federation/config');
const {
withNativeFederation,
shareAll,
} = require('@angular-architects/native-federation/config');

module.exports = withNativeFederation({

name: 'mf-login',

exposes: {
'./routes': './apps/mf-login/src/app/app.routes.ts',
'./Component': './apps/mf-login/src/app/app.component.ts',
},

shared: {
...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
...shareAll({
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
}),
},

skip: [
Expand All @@ -18,6 +25,5 @@ module.exports = withNativeFederation({
'rxjs/testing',
'rxjs/webSocket',
// Add further packages you don't need at runtime
]

],
});
8 changes: 7 additions & 1 deletion apps/mf-login/src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { Route } from '@angular/router';

export const appRoutes: Route[] = [];
export const appRoutes: Route[] = [
{
path: '',
loadComponent: () =>
import('./app.component').then(({ AppComponent }) => AppComponent),
},
];

0 comments on commit f1fec04

Please sign in to comment.