ng-module-federation
v12.1.3
Published
[](https://sonarcloud.io/dashboard?id=jtneal_ng-module-federation) [],
})
export class MfeRoutingModule { }// mfe.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MfeRoutingModule } from './mfe-routing.module';
import { Mfe1Component } from './mfe1/mfe1.component';
@NgModule({
declarations: [Mfe1Component],
imports: [
CommonModule,
MfeRoutingModule,
]
})
export class MfeModule { }Then, in your shell, you'll need to define your routes that point to the micro frontends:
// app-routing.module.ts
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { createMicroFrontendRoute } from 'ng-module-federation';
import { microFrontends } from '../micro-frontends';
const routes: Routes = [
...createMicroFrontendRoutes(microFrontends),
];
@NgModule({
exports: [RouterModule],
imports: [RouterModule.forRoot(routes)],
})
export class AppRoutingModule { }Lastly, simply create some navigation links that point to these routes:
<nav>
<ul>
<li><a routerLink="/mfe1">MFE1</a></li>
<li><a routerLink="/mfe2">MFE2</a></li>
<li><a routerLink="/mfe3">MFE3</a></li>
</ul>
</nav>Development
Build
Run npm run build to build the project and schematics.
Running unit tests
Run npm run test to execute the unit tests.
Running schematics tests
Run npm run test:schematics to execute the schematics tests.
Running end-to-end tests
Run npm run e2e to execute the end-to-end tests.
If you want to use a headless browser, use npm run e2e:headless instead.
Running the tester app
The workspace includes a tester application that can be used to test out features of the SDK. Run this using ng serve mfe-tester and browse to http://localhost:4200.
Contributing
We appreciate feedback and contribution to this repo! Feel free to submit a pull request and we will work with you to get it reviewed and merged.
Support + Feedback
For support or to provide feedback, please raise an issue on our issue tracker.
License
This project is licensed under the MIT license. See the LICENSE file for more info.
