Skip to content

Commit 48f63fa

Browse files
committed
feat: add static federation examples for comparison
- comment based
1 parent 6c1c178 commit 48f63fa

23 files changed

+8476
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
module.exports = {
22
name: 'host-example',
3+
4+
// DYNAMIC FEDERATION
35
remotes: [],
6+
7+
// STATIC FEDERATION
8+
// remotes: ['remote-a', 'remote-b'],
49
};

apps/host-example/src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/>
1010
</a>
1111
<span class="text-blue-700 text-2xl font-bold"
12-
>Module Federation Example</span
12+
>Module Federation Example 1</span
1313
>
1414
<span class="flex-1"></span>
1515
<a

apps/host-example/src/app/app.routes.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const appRoutes: Route[] = [
2121
'@angular-experts/host-example/feature/dashboard-with-subroutes'
2222
).then((m) => m.hostExampleFeatureDashboardWithSubroutesRoutes),
2323
},
24+
// DYNAMIC FEDERATION
2425
{
2526
path: 'remote-a',
2627
loadChildren: () =>
@@ -31,4 +32,16 @@ export const appRoutes: Route[] = [
3132
loadChildren: () =>
3233
loadRemoteModule('remote-b', './Routes').then((m) => m.remoteRoutes),
3334
},
35+
36+
// STATIC FEDERATION
37+
// {
38+
// path: 'remote-a',
39+
// loadChildren: () =>
40+
// import('@angular-experts/remote-a/feature/a').then((m) => m.remoteAFeatureARoutes),
41+
// },
42+
// {
43+
// path: 'remote-b',
44+
// loadChildren: () =>
45+
// import('@angular-experts/remote-b/feature/b').then((m) => m.remoteBFeatureBRoutes),
46+
// },
3447
];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"remote-a": "http://localhost:4201",
2+
"remote-a": "http://B:indetifier@version",
33
"remote-b": "http://localhost:4202"
44
}

apps/host-example/src/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
// STATIC FEDERATION
2+
// import'./bootstrap';
3+
4+
// DYNAMIC FEDERATION
15
import { setRemoteDefinitions } from '@nx/angular/mf';
26

37
fetch('/assets/module-federation.manifest.json')
48
.then((res) => res.json())
59
.then((definitions) => setRemoteDefinitions(definitions))
610
.then(() => import('./bootstrap').catch((err) => console.error(err)));
11+

libs/remote-a/feature/a/src/lib/remote-a-feature-a/remote-a-feature-a.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
21
import { CommonModule } from '@angular/common';
32
import { RouterModule } from '@angular/router';
3+
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
4+
5+
import { SharedUiDummyComponent } from '@angular-experts/shared/ui/dummy';
46

57
@Component({
68
selector: 'angular-experts-remote-a-feature-a',
79
standalone: true,
8-
imports: [CommonModule, RouterModule],
10+
imports: [CommonModule, RouterModule, SharedUiDummyComponent],
911
template: `
1012
<h1 class="title">remote-a-feature-a works!</h1>
1113
<div class="flex gap-4 my-8" *ngIf="withRouting">
@@ -15,6 +17,7 @@ import { RouterModule } from '@angular/router';
1517
>
1618
<a class="btn" routerLinkActive="btn-active" routerLink="child">Child</a>
1719
</div>
20+
<angular-experts-shared-ui-dummy />
1821
<router-outlet *ngIf="withRouting" />
1922
`,
2023
styles: [
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"extends": ["../../../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts"],
7+
"rules": {
8+
"@angular-eslint/directive-selector": [
9+
"error",
10+
{
11+
"type": "attribute",
12+
"prefix": "angularExperts",
13+
"style": "camelCase"
14+
}
15+
],
16+
"@angular-eslint/component-selector": [
17+
"error",
18+
{
19+
"type": "element",
20+
"prefix": "angular-experts",
21+
"style": "kebab-case"
22+
}
23+
]
24+
},
25+
"extends": [
26+
"plugin:@nx/angular",
27+
"plugin:@angular-eslint/template/process-inline-templates"
28+
]
29+
},
30+
{
31+
"files": ["*.html"],
32+
"extends": ["plugin:@nx/angular-template"],
33+
"rules": {}
34+
}
35+
]
36+
}

libs/shared/ui/dummy/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# shared-ui-dummy
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Running unit tests
6+
7+
Run `nx test shared-ui-dummy` to execute the unit tests.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'shared-ui-dummy',
4+
preset: '../../../../jest.preset.js',
5+
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
6+
coverageDirectory: '../../../../coverage/libs/shared/ui/dummy',
7+
transform: {
8+
'^.+\\.(ts|mjs|js|html)$': [
9+
'jest-preset-angular',
10+
{
11+
tsconfig: '<rootDir>/tsconfig.spec.json',
12+
stringifyContentPathRegex: '\\.(html|svg)$',
13+
},
14+
],
15+
},
16+
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
17+
snapshotSerializers: [
18+
'jest-preset-angular/build/serializers/no-ng-attributes',
19+
'jest-preset-angular/build/serializers/ng-snapshot',
20+
'jest-preset-angular/build/serializers/html-comment',
21+
],
22+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
3+
"dest": "../../../../dist/libs/shared/ui/dummy",
4+
"lib": {
5+
"entryFile": "src/index.ts"
6+
}
7+
}

0 commit comments

Comments
 (0)