Repository navigation
Expand file tree
/
Copy pathfederation-base.js
More file actions
67 lines (61 loc) · 2.09 KB
/
Copy pathfederation-base.js
File metadata and controls
67 lines (61 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Shared federation config helpers for the host shell + any future remote
// bundles authored in this repo.
//
// The host's federation.config.js used to inline the same shareAll args and
// skip list every other HugMesh repo carries. Centralising them here means
// the federation surface (singletons, strictVersion, the RxJS skip list) lives
// in ONE place — so a drift between host and remotes (e.g. one bundle sharing a
// different RxJS subpath) can't quietly produce a "shared is not a function"
// runtime failure. Mirrors hugmesh.games/frontend/federation-base.js.
//
// Used by:
// - ./federation.config.js (this host)
const { withNativeFederation, shareAll } = require('@angular-architects/native-federation/config');
// RxJS subpaths the native-federation builder can't resolve as ESM —
// shareAll would otherwise pull them in and the runtime fails to wire.
// (Default native-federation guidance.)
const STD_SKIP = [
'rxjs/ajax',
'rxjs/fetch',
'rxjs/testing',
'rxjs/webSocket',
];
const STD_SHARED = shareAll({
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
});
/**
* Federation config for a remote bundle. `exposes` is the public surface the
* host's loadRemoteModule({ remoteName, exposedModule }) consumes.
*
* `extraSkip` lets a specific remote tack on its own skip entries without
* losing the standard list.
*/
function hugmeshRemote({ name, exposes, extraSkip = [] }) {
return withNativeFederation({
name,
exposes,
shared: { ...STD_SHARED },
skip: [...STD_SKIP, ...extraSkip],
});
}
/**
* Federation config for the host shell. The host has no `exposes` block (it's a
* consumer, not a provider), only a shared-deps surface and the skip list.
* Naming the host explicitly keeps the convention shared across HugMesh
* repos; a host carries no manifest self-row requirement.
*/
function hugmeshHost({ name = 'hugmesh-host', extraSkip = [] } = {}) {
return withNativeFederation({
name,
shared: { ...STD_SHARED },
skip: [...STD_SKIP, ...extraSkip],
});
}
module.exports = {
hugmeshRemote,
hugmeshHost,
STD_SKIP,
STD_SHARED,
};