Skip to content

Commit 9761791

Browse files
author
Alain Sollberger
committed
feat(nf-runtime): added cacheTag option to bust the remoteEntry file cache
- upgraded nx to the latest
1 parent a63cfab commit 9761791

File tree

11 files changed

+14566
-12662
lines changed

11 files changed

+14566
-12662
lines changed

.eslintrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
"files": "*.json",
3939
"parser": "jsonc-eslint-parser",
4040
"rules": {}
41+
},
42+
{
43+
"files": ["*.ts"],
44+
"rules": {
45+
"@angular-eslint/prefer-standalone": "off"
46+
}
4147
}
4248
],
4349
"extends": ["./.eslintrc.base.json"]

apps/mfe1/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"prefix": "angular-architects",
2525
"style": "kebab-case"
2626
}
27-
]
27+
],
28+
"@angular-eslint/prefer-standalone": "off"
2829
}
2930
},
3031
{

apps/mfe2/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"prefix": "angular-architects",
2525
"style": "kebab-case"
2626
}
27-
]
27+
],
28+
"@angular-eslint/prefer-standalone": "off"
2829
}
2930
},
3031
{

apps/playground/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"prefix": "angular-architects",
2525
"style": "kebab-case"
2626
}
27-
]
27+
],
28+
"@angular-eslint/prefer-standalone": "off"
2829
}
2930
},
3031
{

libs/mf-runtime/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"prefix": "angular-architects",
2525
"style": "kebab-case"
2626
}
27-
]
27+
],
28+
"@angular-eslint/prefer-standalone": "off"
2829
}
2930
},
3031
{

libs/mf-tools/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"prefix": "angular-architects",
2525
"style": "kebab-case"
2626
}
27-
]
27+
],
28+
"@angular-eslint/prefer-standalone": "off"
2829
}
2930
},
3031
{

libs/native-federation-runtime/src/lib/init-federation.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,30 @@ import { getExternalUrl, setExternalUrl } from './model/externals';
88
import { joinPaths, getDirectory } from './utils/path-utils';
99
import { addRemote } from './model/remotes';
1010
import { appendImportMap } from './utils/add-import-map';
11-
import { FederationInfo } from './model/federation-info';
12-
11+
import {
12+
FederationInfo,
13+
InitFederationOptions,
14+
ProcessRemoteInfoOptions,
15+
} from './model/federation-info';
16+
17+
/**
18+
* Initialize the federation runtime
19+
* @param remotesOrManifestUrl
20+
* @param options The cacheTag allows you to invalidate the cache of the remoteEntry.json files, pass a new value with every release (f.ex. the version number)
21+
*/
1322
export async function initFederation(
14-
remotesOrManifestUrl: Record<string, string> | string = {}
23+
remotesOrManifestUrl: Record<string, string> | string = {},
24+
options?: InitFederationOptions
1525
): Promise<ImportMap> {
1626
const remotes =
1727
typeof remotesOrManifestUrl === 'string'
1828
? await loadManifest(remotesOrManifestUrl)
1929
: remotesOrManifestUrl;
2030

21-
const hostInfo = await loadFederationInfo('./remoteEntry.json');
31+
const url = `./remoteEntry.json${
32+
options?.cacheTag ? `?t=${options.cacheTag}` : ''
33+
}`;
34+
const hostInfo = await loadFederationInfo(url);
2235
const hostImportMap = await processHostInfo(hostInfo);
2336
const remotesImportMap = await processRemoteInfos(remotes);
2437

@@ -34,12 +47,17 @@ async function loadManifest(remotes: string): Promise<Record<string, string>> {
3447

3548
export async function processRemoteInfos(
3649
remotes: Record<string, string>,
37-
options: { throwIfRemoteNotFound: boolean } = { throwIfRemoteNotFound: false }
50+
options: ProcessRemoteInfoOptions = { throwIfRemoteNotFound: false }
3851
): Promise<ImportMap> {
3952
const processRemoteInfoPromises = Object.keys(remotes).map(
4053
async (remoteName) => {
4154
try {
42-
const url = remotes[remoteName];
55+
let url = remotes[remoteName];
56+
if (options.cacheTag) {
57+
const addAppend = remotes[remoteName].includes('?') ? '&' : '?';
58+
url += `${addAppend}t=${options.cacheTag}`;
59+
}
60+
4361
return await processRemoteInfo(url, remoteName);
4462
} catch (e) {
4563
const error = `Error loading remote entry for ${remoteName} from file ${remotes[remoteName]}`;

libs/native-federation-runtime/src/lib/model/federation-info.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ export interface FederationInfo {
2323
exposes: ExposesInfo[];
2424
shared: SharedInfo[];
2525
}
26+
27+
export interface InitFederationOptions {
28+
cacheTag?: string;
29+
}
30+
31+
export interface ProcessRemoteInfoOptions extends InitFederationOptions {
32+
throwIfRemoteNotFound: boolean;
33+
}

libs/playground-lib/.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"prefix": "angular-architects",
2525
"style": "kebab-case"
2626
}
27-
]
27+
],
28+
"@angular-eslint/prefer-standalone": "off"
2829
}
2930
},
3031
{

0 commit comments

Comments
 (0)