Skip to content

Commit 490fc78

Browse files
author
Alain BOUDARD
committed
fix: add core library for shared access purpose
1 parent 5fe0813 commit 490fc78

File tree

20 files changed

+302
-131
lines changed

20 files changed

+302
-131
lines changed

application/ng-shell/package-lock.json

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

application/ng-shell/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
"@angular/platform-browser": "^14.2.0",
2121
"@angular/platform-browser-dynamic": "^14.2.0",
2222
"@angular/router": "^14.2.0",
23+
"@ngrx/store": "^14.3.3",
24+
"@ngrx/store-devtools": "^14.3.3",
25+
"core": "0.0.2",
2326
"rxjs": "~7.5.0",
2427
"tslib": "^2.3.0",
2528
"zone.js": "~0.11.4"

application/ng-shell/src/app/app.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<h1>{{title}}</h1>
22
<ul>
3+
<li class="user">## {{(user$ | async)?.name}} ##</li>
34
<li><a routerLink="/">Home</a></li>
45
<li><a routerLink="users">Users</a></li>
56
<li *ngFor="let remote of remotes">
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
li.user {
2+
color: crimson;
3+
}

application/ng-shell/src/app/app.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Component, OnInit } from '@angular/core';
22
import { Router } from '@angular/router';
3+
import { Store } from '@ngrx/store';
4+
import { getUser } from 'core';
35
import { CustomManifest, CustomRemoteConfig } from './utils/config';
46
import { getManifest, loadManifest } from '@angular-architects/module-federation';
57
import { buildRoutes } from './utils/routes';
@@ -10,11 +12,15 @@ import { buildRoutes } from './utils/routes';
1012
styleUrls: ['./app.component.scss']
1113
})
1214
export class AppComponent implements OnInit {
15+
1316
title = 'ng-shell';
1417
remotes: CustomRemoteConfig[] = [];
18+
user$ = this.store.select(getUser);
1519

1620
constructor(
17-
private router: Router) {
21+
private router: Router,
22+
private store: Store
23+
) {
1824
}
1925

2026
async ngOnInit() {

application/ng-shell/src/app/app.module.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { HttpClientModule } from '@angular/common/http';
22
import { NgModule } from '@angular/core';
33
import { BrowserModule } from '@angular/platform-browser';
4+
import { CoreModule } from 'core';
45

56
import { AppRoutingModule } from './app-routing.module';
67
import { AppComponent } from './app.component';
8+
import { StoreModule } from '@ngrx/store';
9+
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
10+
import { environment } from '../environments/environment';
11+
import { reducers, metaReducers } from './store';
712

813
@NgModule({
914
declarations: [
@@ -12,7 +17,10 @@ import { AppComponent } from './app.component';
1217
imports: [
1318
BrowserModule,
1419
HttpClientModule,
15-
AppRoutingModule
20+
AppRoutingModule,
21+
StoreModule.forRoot(reducers, { metaReducers }),
22+
CoreModule,
23+
!environment.production ? StoreDevtoolsModule.instrument() : []
1624
],
1725
providers: [],
1826
bootstrap: [AppComponent]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {
2+
ActionReducer,
3+
ActionReducerMap,
4+
createFeatureSelector,
5+
createSelector,
6+
MetaReducer
7+
} from '@ngrx/store';
8+
import { environment } from '../../environments/environment';
9+
10+
11+
export interface State {
12+
13+
}
14+
15+
export const reducers: ActionReducerMap<State> = {
16+
17+
};
18+
19+
20+
export const metaReducers: MetaReducer<State>[] = !environment.production ? [] : [];
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
const { shareAll, withModuleFederationPlugin } = require('@angular-architects/module-federation/webpack');
1+
const { share, withModuleFederationPlugin } = require('@angular-architects/module-federation/webpack');
22

33
module.exports = withModuleFederationPlugin({
44

5-
shared: {
6-
...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
7-
},
5+
// Explicitly share packages:
6+
shared: share({
7+
"@angular/core": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
8+
"@angular/common": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
9+
"@angular/common/http": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
10+
"@angular/router": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
11+
"@ngrx/store": { singleton: true, strictVersion: true, requiredVersion: 'auto' },
12+
})
813

914
});

application/src/main/java/com/cit/application/controllers/HelloController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ public String index() {
3333
}
3434

3535
@GetMapping("/api/manifest")
36-
public EmptyObject microfontend() {
36+
/*public EmptyObject microfontend() {
3737
return new EmptyObject();
38-
}
39-
/*public MicroFrontend microfontend() {
38+
}*/
39+
public MicroFrontend microfontend() {
4040
Manifest mfe1 = new Manifest(remoteEntry, exposedModule, displayName, routePath, ngModuleName, type);
4141
return new MicroFrontend(mfe1);
42-
}*/
42+
}
4343

4444
public static class MicroFrontend {
4545
private Manifest mfe1;

0 commit comments

Comments
 (0)