@softarc/native-federation-orchestrator 4.3.1 → 4.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/fesm2022/@softarc/native-federation-orchestrator.mjs +20 -10
- package/fesm2022/@softarc/native-federation-orchestrator.mjs.map +3 -3
- package/fesm2022/module-federation.mjs +56 -0
- package/fesm2022/module-federation.mjs.map +7 -0
- package/fesm2022/node.mjs +19 -9
- package/fesm2022/node.mjs.map +3 -3
- package/package.json +5 -1
- package/quickstart.mjs +11 -11
- package/types/lib/core/2.app/config/mode.contract.d.ts +1 -0
- package/types/lib/core/2.app/driver-ports/init/for-committing-changes.port.d.ts +5 -1
- package/types/lib/module-federation/get-shared.d.ts +7 -0
- package/types/lib/module-federation/share-infos.contract.d.ts +45 -0
- package/types/lib/module-federation.index.d.ts +2 -0
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ Get up and running in under 2 minutes:
|
|
|
70
70
|
</script>
|
|
71
71
|
|
|
72
72
|
<!-- Include the orchestrator runtime -->
|
|
73
|
-
<script src="https://unpkg.com/@softarc/native-federation-orchestrator@4.
|
|
73
|
+
<script src="https://unpkg.com/@softarc/native-federation-orchestrator@4.4.1/quickstart.mjs"></script>
|
|
74
74
|
</head>
|
|
75
75
|
<body>
|
|
76
76
|
<!-- Use your loaded components -->
|
|
@@ -88,7 +88,7 @@ Your micro frontends are now loaded and ready to use. The runtime handles the wh
|
|
|
88
88
|
|
|
89
89
|
```html
|
|
90
90
|
<!-- Development and quick testing -->
|
|
91
|
-
<script src="https://unpkg.com/@softarc/native-federation-orchestrator@4.
|
|
91
|
+
<script src="https://unpkg.com/@softarc/native-federation-orchestrator@4.4.1/quickstart.mjs"></script>
|
|
92
92
|
```
|
|
93
93
|
|
|
94
94
|
## Advanced Usage
|
|
@@ -132,6 +132,7 @@ const HeaderComponent = await loadRemoteModule('team/mfe2', './Header');
|
|
|
132
132
|
| [📡 Event Registry](https://github.com/native-federation/orchestrator/blob/main/docs/event-registry.md) | In-page event bus for cross-MFE communication |
|
|
133
133
|
| [🔄 Version Resolution](https://github.com/native-federation/orchestrator/blob/main/docs/version-resolver.md) | How dependency conflicts are resolved |
|
|
134
134
|
| [🔒 Security & Trusted Types](https://github.com/native-federation/orchestrator/blob/main/docs/security.md) | CSP setup and the built-in Trusted Types policy |
|
|
135
|
+
| [🌉 Module Federation](https://github.com/native-federation/orchestrator/blob/main/docs/module-federation.md) | Share singletons with webpack Module Federation |
|
|
135
136
|
|
|
136
137
|
## Example repositories
|
|
137
138
|
|
|
@@ -1283,7 +1283,7 @@ var createInitFlow = ({
|
|
|
1283
1283
|
adapters,
|
|
1284
1284
|
config
|
|
1285
1285
|
}) => {
|
|
1286
|
-
return (remotesOrManifestUrl) => flow.getRemoteEntries(remotesOrManifestUrl).then(flow.processRemoteEntries).then(flow.determineSharedExternals).then(flow.generateImportMap).then(flow.commitChanges).then(flow.exposeModuleLoader).then((loadRemoteModule) => ({
|
|
1286
|
+
return (remotesOrManifestUrl) => flow.getRemoteEntries(remotesOrManifestUrl).then(flow.processRemoteEntries).then(flow.determineSharedExternals).then(flow.generateImportMap).then((importMap) => flow.commitChanges(importMap, { override: true })).then(flow.exposeModuleLoader).then((loadRemoteModule) => ({
|
|
1287
1287
|
config,
|
|
1288
1288
|
adapters,
|
|
1289
1289
|
loadRemoteModule
|
|
@@ -1335,16 +1335,25 @@ function createGetRemoteEntries(config, ports) {
|
|
|
1335
1335
|
};
|
|
1336
1336
|
function addHostRemoteEntry(manifest) {
|
|
1337
1337
|
if (!config.hostRemoteEntry) return manifest;
|
|
1338
|
-
const { name, url,
|
|
1339
|
-
const urlWithCache = cacheTag ? `${url}?cacheTag=${cacheTag}` : url;
|
|
1338
|
+
const { name, url, integrity } = config.hostRemoteEntry;
|
|
1340
1339
|
return {
|
|
1341
1340
|
...manifest,
|
|
1342
|
-
[name]: integrity ? { url
|
|
1341
|
+
[name]: integrity ? { url, integrity } : url
|
|
1343
1342
|
};
|
|
1344
1343
|
}
|
|
1345
1344
|
function normalizeEntry(descriptor) {
|
|
1346
1345
|
return typeof descriptor === "string" ? { url: descriptor } : descriptor;
|
|
1347
1346
|
}
|
|
1347
|
+
function withCacheTag(url, cacheTag) {
|
|
1348
|
+
if (!cacheTag) return url;
|
|
1349
|
+
return `${url}${url.includes("?") ? "&" : "?"}cacheTag=${cacheTag}`;
|
|
1350
|
+
}
|
|
1351
|
+
function resolveCacheTag(remoteName) {
|
|
1352
|
+
if (config.hostRemoteEntry && remoteName === config.hostRemoteEntry.name && config.hostRemoteEntry.cacheTag) {
|
|
1353
|
+
return config.hostRemoteEntry.cacheTag;
|
|
1354
|
+
}
|
|
1355
|
+
return config.profile.cacheTag;
|
|
1356
|
+
}
|
|
1348
1357
|
async function fetchRemoteEntries(manifest) {
|
|
1349
1358
|
const fetchPromises = Object.entries(manifest).map(
|
|
1350
1359
|
([remoteName, descriptor]) => fetchRemoteEntry(remoteName, descriptor)
|
|
@@ -1365,8 +1374,9 @@ function createGetRemoteEntries(config, ports) {
|
|
|
1365
1374
|
}
|
|
1366
1375
|
});
|
|
1367
1376
|
if (skip) return false;
|
|
1377
|
+
const fetchUrl = withCacheTag(remoteEntryUrl, resolveCacheTag(remoteName));
|
|
1368
1378
|
try {
|
|
1369
|
-
const remoteEntry = integrity ? await ports.remoteEntryProvider.provide(
|
|
1379
|
+
const remoteEntry = integrity ? await ports.remoteEntryProvider.provide(fetchUrl, { integrity }) : await ports.remoteEntryProvider.provide(fetchUrl);
|
|
1370
1380
|
config.log.debug(
|
|
1371
1381
|
1,
|
|
1372
1382
|
`Fetched '${remoteEntry.name}' from '${remoteEntry.url}', exposing: ${JSON.stringify(remoteEntry.exposes)}`
|
|
@@ -1643,7 +1653,7 @@ function createDetermineSharedExternals(config, ports) {
|
|
|
1643
1653
|
}
|
|
1644
1654
|
}
|
|
1645
1655
|
|
|
1646
|
-
// node_modules/.pnpm/@softarc+native-federation@4.2.
|
|
1656
|
+
// node_modules/.pnpm/@softarc+native-federation@4.2.1_typescript@6.0.3/node_modules/@softarc/native-federation/dist/lib/domain/core/build-notification-options.contract.js
|
|
1647
1657
|
var BuildNotificationType = /* @__PURE__ */ ((BuildNotificationType2) => {
|
|
1648
1658
|
BuildNotificationType2["COMPLETED"] = "federation-rebuild-complete";
|
|
1649
1659
|
BuildNotificationType2["ERROR"] = "federation-rebuild-error";
|
|
@@ -1651,7 +1661,7 @@ var BuildNotificationType = /* @__PURE__ */ ((BuildNotificationType2) => {
|
|
|
1651
1661
|
return BuildNotificationType2;
|
|
1652
1662
|
})(BuildNotificationType || {});
|
|
1653
1663
|
|
|
1654
|
-
// node_modules/.pnpm/@softarc+native-federation@4.2.
|
|
1664
|
+
// node_modules/.pnpm/@softarc+native-federation@4.2.1_typescript@6.0.3/node_modules/@softarc/native-federation/dist/lib/domain/core/chunk.js
|
|
1655
1665
|
var CHUNK_PREFIX = "@nf-internal";
|
|
1656
1666
|
function toChunkImport(fileName) {
|
|
1657
1667
|
if (fileName.startsWith("./")) {
|
|
@@ -1902,9 +1912,9 @@ function createGenerateImportMap(config, ports) {
|
|
|
1902
1912
|
|
|
1903
1913
|
// src/lib/core/2.app/steps/commit-changes.ts
|
|
1904
1914
|
function createCommitChanges(config, ports) {
|
|
1905
|
-
return (importMap) => Promise.resolve(importMap).then(addToBrowser).then(persistRepositoryChanges);
|
|
1906
|
-
function addToBrowser(importMap) {
|
|
1907
|
-
ports.browser.setImportMapFn(importMap);
|
|
1915
|
+
return (importMap, opts = {}) => Promise.resolve(importMap).then((map) => addToBrowser(map, opts)).then(persistRepositoryChanges);
|
|
1916
|
+
function addToBrowser(importMap, opts) {
|
|
1917
|
+
ports.browser.setImportMapFn(importMap, opts);
|
|
1908
1918
|
config.log.debug(5, "Added import map to browser.", importMap);
|
|
1909
1919
|
return importMap;
|
|
1910
1920
|
}
|