@softarc/native-federation-runtime 3.5.0 → 3.5.2
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.
|
@@ -1,11 +1,50 @@
|
|
|
1
|
+
const defaultShareOptions = {
|
|
2
|
+
singleton: false,
|
|
3
|
+
requiredVersionPrefix: '',
|
|
4
|
+
};
|
|
5
|
+
function getShared(options = defaultShareOptions) {
|
|
6
|
+
const nfc = window;
|
|
7
|
+
const externals = nfc.__NATIVE_FEDERATION__.externals;
|
|
8
|
+
const shared = {};
|
|
9
|
+
const allKeys = [...externals.keys()];
|
|
10
|
+
const keys = allKeys
|
|
11
|
+
.filter((k) => !k.startsWith('/@id/') &&
|
|
12
|
+
!k.startsWith('@angular-architects/module-federation') &&
|
|
13
|
+
!k.endsWith('@'))
|
|
14
|
+
.sort();
|
|
15
|
+
for (const key of keys) {
|
|
16
|
+
const idx = key.lastIndexOf('@');
|
|
17
|
+
const pkgName = key.substring(0, idx);
|
|
18
|
+
const version = key.substring(idx + 1);
|
|
19
|
+
const path = externals.get(key) ?? '';
|
|
20
|
+
const shareObj = {
|
|
21
|
+
version,
|
|
22
|
+
get: async () => {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
const lib = await window.importShim(path);
|
|
25
|
+
return () => lib;
|
|
26
|
+
},
|
|
27
|
+
shareConfig: {
|
|
28
|
+
singleton: options.singleton,
|
|
29
|
+
requiredVersion: options.requiredVersionPrefix + version,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
if (!shared[pkgName]) {
|
|
33
|
+
shared[pkgName] = [];
|
|
34
|
+
}
|
|
35
|
+
shared[pkgName].push(shareObj);
|
|
36
|
+
}
|
|
37
|
+
return shared;
|
|
38
|
+
}
|
|
39
|
+
|
|
1
40
|
const nfNamespace = '__NATIVE_FEDERATION__';
|
|
2
|
-
const global = globalThis;
|
|
3
|
-
global[nfNamespace] ??= {
|
|
41
|
+
const global$1 = globalThis;
|
|
42
|
+
global$1[nfNamespace] ??= {
|
|
4
43
|
externals: new Map(),
|
|
5
44
|
remoteNamesToRemote: new Map(),
|
|
6
45
|
baseUrlToRemoteNames: new Map(),
|
|
7
46
|
};
|
|
8
|
-
const globalCache = global[nfNamespace];
|
|
47
|
+
const globalCache = global$1[nfNamespace];
|
|
9
48
|
|
|
10
49
|
const externals = globalCache.externals;
|
|
11
50
|
function getExternalKey(shared) {
|
|
@@ -46,10 +85,34 @@ function hasRemote(remoteName) {
|
|
|
46
85
|
return remoteNamesToRemote.has(remoteName);
|
|
47
86
|
}
|
|
48
87
|
|
|
88
|
+
const global = globalThis;
|
|
89
|
+
let policy;
|
|
90
|
+
function createPolicy() {
|
|
91
|
+
if (policy === undefined) {
|
|
92
|
+
policy = null;
|
|
93
|
+
if (global.trustedTypes) {
|
|
94
|
+
try {
|
|
95
|
+
policy = global.trustedTypes.createPolicy('native-federation', {
|
|
96
|
+
createHTML: (html) => html,
|
|
97
|
+
createScript: (script) => script,
|
|
98
|
+
createScriptURL: (url) => url,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// trustedTypes.createPolicy may throw an exception if called with a name that is already registered, even in report-only mode.
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return policy;
|
|
107
|
+
}
|
|
108
|
+
function tryCreateTrustedScript(script) {
|
|
109
|
+
return createPolicy()?.createScript(script) ?? script;
|
|
110
|
+
}
|
|
111
|
+
|
|
49
112
|
function appendImportMap(importMap) {
|
|
50
113
|
document.head.appendChild(Object.assign(document.createElement('script'), {
|
|
51
|
-
type: 'importmap-shim',
|
|
52
|
-
|
|
114
|
+
type: tryCreateTrustedScript('importmap-shim'),
|
|
115
|
+
textContent: tryCreateTrustedScript(JSON.stringify(importMap)),
|
|
53
116
|
}));
|
|
54
117
|
}
|
|
55
118
|
|
|
@@ -147,7 +210,7 @@ async function initFederation(remotesOrManifestUrl = {}, options) {
|
|
|
147
210
|
// Each remote contributes:
|
|
148
211
|
// - Exposed modules to root imports
|
|
149
212
|
// - Shared dependencies to scoped imports
|
|
150
|
-
const remotesImportMap = await
|
|
213
|
+
const remotesImportMap = await processRemoteInfos(normalizedRemotes, {
|
|
151
214
|
throwIfRemoteNotFound: false,
|
|
152
215
|
...options,
|
|
153
216
|
});
|
|
@@ -211,7 +274,7 @@ function handleRemoteLoadError(remoteName, remoteUrl, options, originalError) {
|
|
|
211
274
|
* @returns Merged import map containing all remotes' contributions
|
|
212
275
|
*
|
|
213
276
|
*/
|
|
214
|
-
async function
|
|
277
|
+
async function processRemoteInfos(remotes, options = { throwIfRemoteNotFound: false }) {
|
|
215
278
|
// Each promise will independently fetch and process its remoteEntry.json
|
|
216
279
|
const fetchAndRegisterRemotePromises = Object.entries(remotes).map(async ([remoteName, remoteUrl]) => {
|
|
217
280
|
try {
|
|
@@ -564,5 +627,5 @@ function logClientError(error) {
|
|
|
564
627
|
* Generated bundle index. Do not edit.
|
|
565
628
|
*/
|
|
566
629
|
|
|
567
|
-
export { BUILD_NOTIFICATIONS_ENDPOINT, BuildNotificationType, fetchAndRegisterRemote,
|
|
630
|
+
export { BUILD_NOTIFICATIONS_ENDPOINT, BuildNotificationType, fetchAndRegisterRemote, getShared, initFederation, loadRemoteModule, mergeImportMaps, processHostInfo, processRemoteInfos };
|
|
568
631
|
//# sourceMappingURL=softarc-native-federation-runtime.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"softarc-native-federation-runtime.mjs","sources":["../../../../libs/native-federation-runtime/src/lib/model/global-cache.ts","../../../../libs/native-federation-runtime/src/lib/model/externals.ts","../../../../libs/native-federation-runtime/src/lib/model/import-map.ts","../../../../libs/native-federation-runtime/src/lib/model/remotes.ts","../../../../libs/native-federation-runtime/src/lib/utils/add-import-map.ts","../../../../libs/native-federation-runtime/src/lib/utils/path-utils.ts","../../../../libs/native-federation-runtime/src/lib/model/build-notifications-options.ts","../../../../libs/native-federation-runtime/src/lib/watch-federation-build.ts","../../../../libs/native-federation-runtime/src/lib/init-federation.ts","../../../../libs/native-federation-runtime/src/lib/load-remote-module.ts","../../../../libs/native-federation-runtime/src/softarc-native-federation-runtime.ts"],"sourcesContent":["import { Remote } from './remotes';\n\nexport const nfNamespace = '__NATIVE_FEDERATION__';\n\nexport type NfCache = {\n externals: Map<string, string>;\n remoteNamesToRemote: Map<string, Remote>;\n baseUrlToRemoteNames: Map<string, string>;\n};\n\nexport type Global = {\n [nfNamespace]: NfCache;\n};\n\nconst global = globalThis as unknown as Global;\n\nglobal[nfNamespace] ??= {\n externals: new Map<string, string>(),\n remoteNamesToRemote: new Map<string, Remote>(),\n baseUrlToRemoteNames: new Map<string, string>(),\n};\n\nexport const globalCache = global[nfNamespace];\n","import { SharedInfo } from './federation-info';\nimport { globalCache } from './global-cache';\n\nconst externals = globalCache.externals;\n\nfunction getExternalKey(shared: SharedInfo) {\n return `${shared.packageName}@${shared.version}`;\n}\n\nexport function getExternalUrl(shared: SharedInfo): string | undefined {\n const packageKey = getExternalKey(shared);\n return externals.get(packageKey);\n}\n\nexport function setExternalUrl(shared: SharedInfo, url: string): void {\n const packageKey = getExternalKey(shared);\n externals.set(packageKey, url);\n}\n","export type Imports = Record<string, string>;\n\nexport type Scopes = Record<string, Imports>;\n\nexport type ImportMap = {\n imports: Imports;\n scopes: Scopes;\n};\n\nexport function mergeImportMaps(map1: ImportMap, map2: ImportMap): ImportMap {\n return {\n imports: { ...map1.imports, ...map2.imports },\n scopes: { ...map1.scopes, ...map2.scopes },\n };\n}\n","import { FederationInfo } from './federation-info';\nimport { globalCache } from './global-cache';\n\nexport type Remote = FederationInfo & {\n baseUrl: string;\n};\n\nconst remoteNamesToRemote = globalCache.remoteNamesToRemote;\nconst baseUrlToRemoteNames = globalCache.baseUrlToRemoteNames;\n\nexport function addRemote(remoteName: string, remote: Remote): void {\n remoteNamesToRemote.set(remoteName, remote);\n baseUrlToRemoteNames.set(remote.baseUrl, remoteName);\n}\n\nexport function getRemoteNameByBaseUrl(baseUrl: string): string | undefined {\n return baseUrlToRemoteNames.get(baseUrl);\n}\n\nexport function isRemoteInitialized(baseUrl: string): boolean {\n return baseUrlToRemoteNames.has(baseUrl);\n}\n\nexport function getRemote(remoteName: string): Remote | undefined {\n return remoteNamesToRemote.get(remoteName);\n}\n\nexport function hasRemote(remoteName: string): boolean {\n return remoteNamesToRemote.has(remoteName);\n}\n","import { ImportMap } from '../model/import-map';\n\nexport function appendImportMap(importMap: ImportMap) {\n document.head.appendChild(\n Object.assign(document.createElement('script'), {\n type: 'importmap-shim',\n innerHTML: JSON.stringify(importMap),\n }),\n );\n}\n","/**\n * Returns the full directory of a given path.\n * @param url - The path to get the directory of.\n * @returns The full directory of the path.\n */\nexport function getDirectory(url: string) {\n const parts = url.split('/');\n parts.pop();\n return parts.join('/');\n}\n\n/**\n * Joins two paths together taking into account trailing slashes and \"./\" prefixes.\n * @param path1 - The first path to join.\n * @param path2 - The second path to join.\n * @returns The joined path.\n */\nexport function joinPaths(path1: string, path2: string) {\n while (path1.endsWith('/')) {\n path1 = path1.substring(0, path1.length - 1);\n }\n if (path2.startsWith('./')) {\n path2 = path2.substring(2, path2.length);\n }\n\n return `${path1}/${path2}`;\n}\n","export interface BuildNotificationOptions {\n enable: boolean;\n endpoint: string;\n}\n\nexport const BUILD_NOTIFICATIONS_ENDPOINT =\n '/@angular-architects/native-federation:build-notifications';\n\nexport enum BuildNotificationType {\n COMPLETED = 'federation-rebuild-complete',\n ERROR = 'federation-rebuild-error',\n CANCELLED = 'federation-rebuild-cancelled',\n}\n","import { BuildNotificationType } from './model/build-notifications-options';\n\n/**\n * Watches for federation build completion events and automatically reloads the page.\n *\n * This function establishes a Server-Sent Events (SSE) connection to listen for\n * 'federation-rebuild-complete' notifications. When a build completes successfully,\n * it triggers a page reload to reflect the latest changes.\n * @param endpoint - The SSE endpoint URL to watch for build notifications.\n */\nexport function watchFederationBuildCompletion(endpoint: string) {\n const eventSource = new EventSource(endpoint);\n\n eventSource.onmessage = function (event) {\n const data = JSON.parse(event.data);\n if (data.type === BuildNotificationType.COMPLETED) {\n console.log('[Federation] Rebuild completed, reloading...');\n window.location.reload();\n }\n };\n\n eventSource.onerror = function (event) {\n console.warn('[Federation] SSE connection error:', event);\n };\n}\n","import { getExternalUrl, setExternalUrl } from './model/externals';\nimport {\n FederationInfo,\n InitFederationOptions,\n ProcessRemoteInfoOptions,\n} from './model/federation-info';\nimport {\n ImportMap,\n Imports,\n mergeImportMaps,\n Scopes,\n} from './model/import-map';\nimport { addRemote } from './model/remotes';\nimport { appendImportMap } from './utils/add-import-map';\nimport { getDirectory, joinPaths } from './utils/path-utils';\nimport { watchFederationBuildCompletion } from './watch-federation-build';\n\n/**\n * Initializes the Native Federation runtime for the host application.\n *\n * This is the main entry point for setting up federation. It performs the following:\n * 1. Loads the host's remoteEntry.json to discover shared dependencies\n * 2. Loads each remote's remoteEntry.json to discover exposed modules\n * 3. Creates an ES Module import map with proper scoping\n * 4. Injects the import map into the DOM as a <script type=\"importmap-shim\">\n *\n * The import map allows dynamic imports to resolve correctly:\n * - Host shared deps go in root imports (e.g., \"angular\": \"./angular.js\")\n * - Remote exposed modules go in root imports (e.g., \"mfe1/Component\": \"http://...\")\n * - Remote shared deps go in scoped imports for proper resolution\n *\n * @param remotesOrManifestUrl - Either:\n * - A record of remote names to their remoteEntry.json URLs\n * Example: { mfe1: 'http://localhost:3000/remoteEntry.json' }\n * - A URL to a manifest.json that contains the remotes record\n * Example: 'http://localhost:3000/federation-manifest.json'\n *\n * @param options - Configuration options:\n * - cacheTag: A version string to append as query param for cache busting\n * Example: { cacheTag: 'v1.0.0' } results in '?t=v1.0.0' on all requests\n *\n * @returns The final merged ImportMap that was injected into the DOM\n *\n */\nexport async function initFederation(\n remotesOrManifestUrl: Record<string, string> | string = {},\n options?: InitFederationOptions,\n): Promise<ImportMap> {\n const cacheTag = options?.cacheTag ? `?t=${options.cacheTag}` : '';\n\n const normalizedRemotes =\n typeof remotesOrManifestUrl === 'string'\n ? await loadManifest(remotesOrManifestUrl + cacheTag)\n : remotesOrManifestUrl;\n\n const hostInfo = await loadFederationInfo(`./remoteEntry.json${cacheTag}`);\n\n const hostImportMap = await processHostInfo(hostInfo);\n\n // Host application is fully loaded, now we can process the remotes\n\n // Each remote contributes:\n // - Exposed modules to root imports\n // - Shared dependencies to scoped imports\n const remotesImportMap = await fetchAndRegisterRemotes(normalizedRemotes, {\n throwIfRemoteNotFound: false,\n ...options,\n });\n\n const mergedImportMap = mergeImportMaps(hostImportMap, remotesImportMap);\n\n // Inject the final import map into the DOM with importmap-shim\n appendImportMap(mergedImportMap);\n\n return mergedImportMap;\n}\n\n/**\n * Loads a federation manifest file (JSON) from the given URL.\n *\n * The manifest should map remote names to their remoteEntry.json URLs.\n *\n * @param manifestUrl - The URL to the manifest.json file.\n * @returns A promise resolving to an object mapping remote names to their remoteEntry.json URLs.\n */\nasync function loadManifest(\n manifestUrl: string,\n): Promise<Record<string, string>> {\n const manifest = (await fetch(manifestUrl).then((r) => r.json())) as Record<\n string,\n string\n >;\n return manifest;\n}\n\n/**\n * Adds cache busting query parameter to a URL if cacheTag is provided.\n */\nfunction applyCacheTag(url: string, cacheTag?: string): string {\n if (!cacheTag) return url;\n\n const separator = url.includes('?') ? '&' : '?';\n return `${url}${separator}t=${cacheTag}`;\n}\n\n/**\n * Handles errors when loading a remote entry.\n * Either throws or logs based on options.\n */\nfunction handleRemoteLoadError(\n remoteName: string,\n remoteUrl: string,\n options: ProcessRemoteInfoOptions,\n originalError: Error,\n): null {\n const errorMessage = `Error loading remote entry for ${remoteName} from file ${remoteUrl}`;\n\n if (options.throwIfRemoteNotFound) {\n throw new Error(errorMessage);\n }\n\n console.error(errorMessage);\n console.error(originalError);\n return null;\n}\n\n/**\n * Fetches and registers multiple remote applications in parallel and merges their import maps.\n *\n * This function is the orchestrator for loading all remotes. It:\n * 1. Creates a promise for each remote to load its remoteEntry.json\n * 2. Applies cache busting to each remote URL\n * 3. Handles errors gracefully (logs or throws based on options)\n * 4. Merges all successful remote import maps into one\n *\n * Each remote contributes:\n * - Its exposed modules to the root imports\n * - Its shared dependencies to scoped imports\n *\n * @param remotes - Record of remote names to their remoteEntry.json URLs\n * @param options - Processing options including:\n * - throwIfRemoteNotFound: Whether to throw or log on remote load failure\n * - cacheTag: Cache busting tag to append to URLs\n *\n * @returns Merged import map containing all remotes' contributions\n *\n */\n\nexport async function fetchAndRegisterRemotes(\n remotes: Record<string, string>,\n options: ProcessRemoteInfoOptions = { throwIfRemoteNotFound: false },\n): Promise<ImportMap> {\n // Each promise will independently fetch and process its remoteEntry.json\n const fetchAndRegisterRemotePromises = Object.entries(remotes).map(\n async ([remoteName, remoteUrl]): Promise<ImportMap | null> => {\n try {\n const urlWithCache = applyCacheTag(remoteUrl, options.cacheTag);\n\n return await fetchAndRegisterRemote(urlWithCache, remoteName);\n } catch (e) {\n return handleRemoteLoadError(\n remoteName,\n remoteUrl,\n options,\n e as Error,\n );\n }\n },\n );\n\n const remoteImportMaps = await Promise.all(fetchAndRegisterRemotePromises);\n\n // Filter out failed remotes (null values) and merge successful ones\n const importMap = remoteImportMaps.reduce<ImportMap>(\n (acc, remoteImportMap) =>\n remoteImportMap ? mergeImportMaps(acc, remoteImportMap) : acc,\n { imports: {}, scopes: {} },\n );\n\n return importMap;\n}\n\n/**\n * Fetches a single remote application's remoteEntry.json file and registers it in the system (global registry).\n *\n * This function handles everything needed to integrate one remote:\n * 1. Fetches the remote's remoteEntry.json file\n * 2. Extracts the base URL from the remoteEntry path\n * 3. Creates import map entries for exposed modules and shared deps\n * 4. Registers the remote in the global remotes registry\n * 5. Sets up hot reload watching if configured (development mode)\n *\n * @param federationInfoUrl - Full URL to the remote's remoteEntry.json\n * @param remoteName - Name to use for this remote (optional, uses info.name if not provided)\n *\n * @returns Import map containing this remote's exposed modules and shared dependencies\n *\n * @example\n * ```typescript\n * const importMap = await fetchAndRegisterRemote(\n * 'http://localhost:3000/mfe1/remoteEntry.json',\n * 'mfe1'\n * );\n * // Result: {\n * // imports: { 'mfe1/Component': 'http://localhost:3000/mfe1/Component.js' },\n * // scopes: { 'http://localhost:3000/mfe1/': { 'lodash': '...' } }\n * // }\n * ```\n */\nexport async function fetchAndRegisterRemote(\n federationInfoUrl: string,\n remoteName?: string,\n): Promise<ImportMap> {\n const baseUrl = getDirectory(federationInfoUrl);\n\n const remoteInfo = await loadFederationInfo(federationInfoUrl);\n\n // Uses the name from the remote's remoteEntry.json if not explicitly provided\n if (!remoteName) {\n remoteName = remoteInfo.name;\n }\n\n // Setup hot reload watching for development mode and in case it has a build notifications endpoint\n if (remoteInfo.buildNotificationsEndpoint) {\n watchFederationBuildCompletion(\n baseUrl + remoteInfo.buildNotificationsEndpoint,\n );\n }\n\n const importMap = createRemoteImportMap(remoteInfo, remoteName, baseUrl);\n\n // Register this remote in the global registry\n addRemote(remoteName, { ...remoteInfo, baseUrl });\n\n return importMap;\n}\n\n/**\n * Creates an import map for a remote application.\n *\n * The import map has two parts:\n * 1. Imports (root level): Maps remote's exposed modules\n * Example: \"mfe1/Component\" -> \"http://localhost:3000/mfe1/Component.js\"\n *\n * 2. Scopes: Maps remote's shared dependencies within its scope\n * Example: \"http://localhost:3000/mfe1/\": { \"lodash\": \"http://localhost:3000/mfe1/lodash.js\" }\n *\n * Scoping ensures that when a module from this remote imports 'lodash',\n * it gets the version from this remote's bundle, not another version.\n *\n * @param remoteInfo - Federation info from the remote's remoteEntry.json\n * @param remoteName - Name used to prefix exposed module keys\n * @param baseUrl - Base URL where the remote is hosted\n *\n * @returns Import map with imports and scopes for this remote\n */\nfunction createRemoteImportMap(\n remoteInfo: FederationInfo,\n remoteName: string,\n baseUrl: string,\n): ImportMap {\n const imports = processExposed(remoteInfo, remoteName, baseUrl);\n const scopes = processRemoteImports(remoteInfo, baseUrl);\n\n return { imports, scopes };\n}\n\n/**\n * Fetches and parses a remoteEntry.json file.\n *\n * The remoteEntry.json contains metadata about a federated module:\n * - name: The application name\n * - exposes: Array of modules this app exposes to others\n * - shared: Array of dependencies this app shares\n * - buildNotificationsEndpoint: Optional SSE endpoint for hot reload (development mode)\n *\n * @param remoteEntryUrl - URL to the remoteEntry.json file (can be relative or absolute)\n * @returns Parsed federation info object\n */\nasync function loadFederationInfo(\n remoteEntryUrl: string,\n): Promise<FederationInfo> {\n const info = (await fetch(remoteEntryUrl).then((r) =>\n r.json(),\n )) as FederationInfo;\n return info;\n}\n\n/**\n * Processes a remote's shared dependencies into scoped import map entries.\n *\n * Shared dependencies need to be scoped to avoid version conflicts.\n * When a module from \"http://localhost:3000/mfe1/\" imports \"lodash\",\n * the import map scope ensures it gets the correct version.\n *\n * Scope structure:\n * {\n * \"http://localhost:3000/mfe1/\": {\n * \"lodash\": \"http://localhost:3000/mfe1/lodash.js\",\n * \"rxjs\": \"http://localhost:3000/mfe1/rxjs.js\"\n * }\n * }\n *\n * This function also manages external URLs - if a shared dependency\n * has already been loaded from another location, it can reuse that URL.\n *\n * @param remoteInfo - Federation info containing shared dependencies\n * @param baseUrl - Base URL of the remote (used as the scope key)\n *\n * @returns Scopes object mapping baseUrl to its shared dependencies\n */\nfunction processRemoteImports(\n remoteInfo: FederationInfo,\n baseUrl: string,\n): Scopes {\n const scopes: Scopes = {};\n const scopedImports: Imports = {};\n\n for (const shared of remoteInfo.shared) {\n // Check if this dependency already has an external URL registered\n // If not, construct the URL from the base path and output filename\n const outFileName =\n getExternalUrl(shared) ?? joinPaths(baseUrl, shared.outFileName);\n\n // Register this URL as the external location for this shared dependency\n // This allows other remotes to potentially reuse this version\n setExternalUrl(shared, outFileName);\n\n // Add to the scoped imports: package name -> full URL\n scopedImports[shared.packageName] = outFileName;\n }\n\n scopes[baseUrl + '/'] = scopedImports;\n\n return scopes;\n}\n\n/**\n * Processes a remote's exposed modules into root-level import map entries.\n *\n * Exposed modules are what the remote makes available to other applications.\n * They go in the root imports (not scoped) so any app can import them.\n *\n * Example exposed module:\n * - Remote 'mfe1' exposes './Component' from file 'Component.js'\n * - Results in: \"mfe1/Component\" -> \"http://localhost:3000/mfe1/Component.js\"\n *\n * This allows other apps to do:\n * ```typescript\n * import { Component } from 'mfe1/Component';\n * ```\n *\n * @param remoteInfo - Federation info containing exposed modules\n * @param remoteName - Name to prefix the exposed keys with\n * @param baseUrl - Base URL where the remote's files are hosted\n *\n * @returns Imports object mapping remote module keys to their URLs\n */\nfunction processExposed(\n remoteInfo: FederationInfo,\n remoteName: string,\n baseUrl: string,\n): Imports {\n const imports: Imports = {};\n\n for (const exposed of remoteInfo.exposes) {\n // Create the import key by joining remote name with the exposed key\n // Example: 'mfe1' + './Component' -> 'mfe1/Component'\n const key = joinPaths(remoteName, exposed.key);\n\n // Create the full URL to the exposed module's output file\n // Example: 'http://localhost:3000/mfe1' + 'Component.js' -> 'http://localhost:3000/mfe1/Component.js'\n const value = joinPaths(baseUrl, exposed.outFileName);\n\n imports[key] = value;\n }\n\n return imports;\n}\n\n/**\n * Processes the host application's federation info into an import map.\n *\n * The host app typically doesn't expose modules (it's the consumer),\n * but it does share dependencies that should be available to remotes.\n *\n * Host shared dependencies go in root-level imports (not scoped) because:\n * 1. The host loads first and establishes the base environment\n * 2. Remotes should prefer host versions to avoid duplication\n *\n * @param hostInfo - Federation info from the host's remoteEntry.json\n * @param relBundlesPath - Relative path to the host's bundle directory (default: './')\n *\n * @returns Import map with host's shared dependencies in root imports\n */\nexport async function processHostInfo(\n hostInfo: FederationInfo,\n relBundlesPath = './',\n): Promise<ImportMap> {\n // Transform shared array into imports object\n const imports = hostInfo.shared.reduce(\n (acc, cur) => ({\n ...acc,\n [cur.packageName]: relBundlesPath + cur.outFileName,\n }),\n {},\n ) as Imports;\n\n // Register external URLs for host's shared dependencies\n // This allows remotes to discover and potentially reuse these versions\n for (const shared of hostInfo.shared) {\n setExternalUrl(shared, relBundlesPath + shared.outFileName);\n }\n\n // Host doesn't have scopes - its shared deps are at root level\n return { imports, scopes: {} };\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { fetchAndRegisterRemote } from './init-federation';\nimport {\n getRemote,\n getRemoteNameByBaseUrl,\n isRemoteInitialized,\n} from './model/remotes';\nimport { appendImportMap } from './utils/add-import-map';\nimport { getDirectory, joinPaths } from './utils/path-utils';\n\ndeclare function importShim<T>(url: string): T;\n\n/**\n * Options for loading a remote module.\n *\n * @template T - The expected type of the module's exports\n *\n * @property remoteEntry - Optional URL to the remote's remoteEntry.json file.\n * Used for lazy-loading remotes that weren't registered during initFederation\n * Example: 'http://localhost:3000/remoteEntry.json'\n *\n * @property remoteName - Optional name of the remote application.\n * Should match the name used during initFederation or the name in remoteEntry.json.\n * Example: 'mfe1'\n *\n * @property exposedModule - The key of the exposed module to load (required).\n * Must match the key defined in the remote's federation config.\n * Example: './Component' or './Dashboard'\n *\n * @property fallback - Optional fallback value to return if the remote or module cannot be loaded.\n * Prevents throwing errors and provides graceful degradation.\n * Example: A default component or null\n */\nexport type LoadRemoteModuleOptions<T = any> = {\n remoteEntry?: string;\n remoteName?: string;\n exposedModule: string;\n fallback?: T;\n};\n\n/**\n * Dynamically loads a remote module at runtime from a federated application.\n *\n * This is the primary API for consuming remote modules after federation has been initialized.\n * It supports two calling patterns:\n *\n * **Pattern 1: Using options object**\n * ```typescript\n * const module = await loadRemoteModule({\n * remoteName: 'mfe1',\n * exposedModule: './Component',\n * fallback: DefaultComponent\n * });\n * ```\n *\n * **Pattern 2: Using positional arguments**\n * ```typescript\n * const module = await loadRemoteModule('mfe1', './Component');\n * ```\n *\n * ## Loading Process\n *\n * 1. **Normalize Options**: Converts arguments into a standard options object\n * 2. **Ensure Remote Initialized**: If remoteEntry is provided and remote isn't loaded,\n * fetches and registers it dynamically\n * 3. **Resolve Remote Name**: Determines remote name from options or remoteEntry URL\n * 4. **Validate Remote**: Checks if remote exists in the registry\n * 5. **Validate Exposed Module**: Verifies the requested module is exposed by the remote\n * 6. **Import Module**: Uses dynamic import or import-shim to load the module\n * 7. **Handle Errors**: Returns fallback if provided, otherwise throws\n *\n * ## Lazy Loading Support\n *\n * If you provide a `remoteEntry` URL for a remote that wasn't initialized during\n * `initFederation()`, this function will automatically:\n * - Fetch the remote's remoteEntry.json\n * - Register it in the global registry\n * - Update the import map\n * - Then load the requested module\n *\n * This enables on-demand loading of remotes based on user interactions.\n *\n *\n * @template T - The expected type of the module's exports\n *\n * @param options - Configuration object for loading the remote module\n * @returns Promise resolving to the loaded module or fallback value\n *\n * @throws Error if remote is not found and no fallback is provided\n * @throws Error if exposed module doesn't exist and no fallback is provided\n * @throws Error if module import fails and no fallback is provided\n *\n */\nexport async function loadRemoteModule<T = any>(\n options: LoadRemoteModuleOptions,\n): Promise<T>;\nexport async function loadRemoteModule<T = any>(\n remoteName: string,\n exposedModule: string,\n): Promise<T>;\nexport async function loadRemoteModule<T = any>(\n optionsOrRemoteName: LoadRemoteModuleOptions<T> | string,\n exposedModule?: string,\n): Promise<T> {\n const options = normalizeOptions(optionsOrRemoteName, exposedModule);\n\n await ensureRemoteInitialized(options);\n\n const remoteName = getRemoteNameByOptions(options);\n\n const remote = getRemote(remoteName);\n const fallback = options.fallback;\n\n // Handles errors when the remote is missing\n const remoteError = !remote ? 'unknown remote ' + remoteName : '';\n if (!remote && !fallback) throw new Error(remoteError);\n if (!remote) {\n logClientError(remoteError);\n return Promise.resolve(fallback);\n }\n\n const exposedModuleInfo = remote.exposes.find(\n (e) => e.key === options.exposedModule,\n );\n\n // Handles errors when the exposed module is missing\n const exposedError = !exposedModuleInfo\n ? `Unknown exposed module ${options.exposedModule} in remote ${remoteName}`\n : '';\n if (!exposedModuleInfo && !fallback) throw new Error(exposedError);\n if (!exposedModuleInfo) {\n logClientError(exposedError);\n return Promise.resolve(fallback);\n }\n\n const moduleUrl = joinPaths(remote.baseUrl, exposedModuleInfo.outFileName);\n\n try {\n const module = _import<T>(moduleUrl);\n return module;\n } catch (e) {\n // Handles errors when the module import fails\n if (fallback) {\n console.error('error loading remote module', e);\n return fallback;\n }\n throw e;\n }\n}\n\n/**\n * Internal helper function to perform the dynamic import.\n *\n * @template T - The expected type of the module's exports\n * @param moduleUrl - Full URL to the module file to import\n * @returns Promise resolving to the imported module\n */\nfunction _import<T = any>(moduleUrl: string) {\n return typeof importShim !== 'undefined'\n ? importShim<T>(moduleUrl)\n : (import(/* @vite-ignore */ moduleUrl) as T);\n}\n\n/**\n * Resolves the remote name from the provided options.\n *\n * The remote name can be determined in two ways:\n * 1. If options.remoteName is provided, use it directly\n * 2. If only remoteEntry is provided, extract the baseUrl\n * and look up the remote name from the registry using that baseUrl\n *\n * @param options - Load options containing remoteName and/or remoteEntry\n * @returns The resolved remote name\n *\n * @throws Error if neither remoteName nor remoteEntry is provided\n * @throws Error if the remote name cannot be determined\n */\nfunction getRemoteNameByOptions(options: LoadRemoteModuleOptions) {\n let remoteName: string | undefined;\n\n if (options.remoteName) {\n remoteName = options.remoteName;\n } else if (options.remoteEntry) {\n const baseUrl = getDirectory(options.remoteEntry);\n remoteName = getRemoteNameByBaseUrl(baseUrl);\n } else {\n throw new Error(\n 'unexpected arguments: Please pass remoteName or remoteEntry',\n );\n }\n\n if (!remoteName) {\n throw new Error('unknown remoteName ' + remoteName);\n }\n return remoteName;\n}\n\n/**\n * Ensures that the remote is initialized before attempting to load a module from it.\n *\n * This function enables lazy-loading of remotes that weren't registered during\n * the initial `initFederation()` call. It checks if:\n * 1. A remoteEntry URL is provided in the options\n * 2. The remote at that URL hasn't been initialized yet\n *\n * If both conditions are true, it:\n * 1. Fetches the remote's remoteEntry.json file\n * 2. Registers the remote in the global registry\n * 3. Creates and appends the remote's import map to the DOM\n *\n * @param options - Load options containing optional remoteEntry URL\n * @returns Promise that resolves when the remote is initialized (or immediately if already initialized)\n *\n */\nasync function ensureRemoteInitialized(\n options: LoadRemoteModuleOptions,\n): Promise<void> {\n if (\n options.remoteEntry &&\n !isRemoteInitialized(getDirectory(options.remoteEntry))\n ) {\n const importMap = await fetchAndRegisterRemote(options.remoteEntry);\n appendImportMap(importMap);\n }\n}\n\n/**\n * Normalizes the function arguments into a standard LoadRemoteModuleOptions object.\n *\n * The function detects which pattern is being used and converts it to the\n * standard options object format for consistent internal processing.\n *\n * @param optionsOrRemoteName - Either an options object or the remote name string\n * @param exposedModule - The exposed module key\n * @returns Normalized options object\n *\n * @throws Error if arguments don't match either supported pattern\n */\nfunction normalizeOptions(\n optionsOrRemoteName: string | LoadRemoteModuleOptions,\n exposedModule: string | undefined,\n): LoadRemoteModuleOptions {\n let options: LoadRemoteModuleOptions;\n\n if (typeof optionsOrRemoteName === 'string' && exposedModule) {\n options = {\n remoteName: optionsOrRemoteName,\n exposedModule,\n };\n } else if (typeof optionsOrRemoteName === 'object' && !exposedModule) {\n options = optionsOrRemoteName;\n } else {\n throw new Error(\n 'unexpected arguments: please pass options or a remoteName/exposedModule-pair',\n );\n }\n return options;\n}\n\n/**\n * Logs an error message to the console, but only in browser environments.\n *\n * @param error - The error message to log\n *\n */\nfunction logClientError(error: string): void {\n if (typeof window !== 'undefined') {\n console.error(error);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAEO,MAAM,WAAW,GAAG,uBAAuB;AAYlD,MAAM,MAAM,GAAG,UAA+B;AAE9C,MAAM,CAAC,WAAW,CAAC,KAAK;IACtB,SAAS,EAAE,IAAI,GAAG,EAAkB;IACpC,mBAAmB,EAAE,IAAI,GAAG,EAAkB;IAC9C,oBAAoB,EAAE,IAAI,GAAG,EAAkB;CAChD;AAEM,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;;ACnB9C,MAAM,SAAS,GAAG,WAAW,CAAC,SAAS;AAEvC,SAAS,cAAc,CAAC,MAAkB,EAAA;IACxC,OAAO,CAAA,EAAG,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,OAAO,CAAA,CAAE;AAClD;AAEM,SAAU,cAAc,CAAC,MAAkB,EAAA;AAC/C,IAAA,MAAM,UAAU,GAAG,cAAc,CAAC,MAAM,CAAC;AACzC,IAAA,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AACjC,QAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;IACtB;AACF;;AC7QA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"softarc-native-federation-runtime.mjs","sources":["../../../../libs/native-federation-runtime/src/lib/get-shared.ts","../../../../libs/native-federation-runtime/src/lib/model/global-cache.ts","../../../../libs/native-federation-runtime/src/lib/model/externals.ts","../../../../libs/native-federation-runtime/src/lib/model/import-map.ts","../../../../libs/native-federation-runtime/src/lib/model/remotes.ts","../../../../libs/native-federation-runtime/src/lib/utils/trusted-types.ts","../../../../libs/native-federation-runtime/src/lib/utils/add-import-map.ts","../../../../libs/native-federation-runtime/src/lib/utils/path-utils.ts","../../../../libs/native-federation-runtime/src/lib/model/build-notifications-options.ts","../../../../libs/native-federation-runtime/src/lib/watch-federation-build.ts","../../../../libs/native-federation-runtime/src/lib/init-federation.ts","../../../../libs/native-federation-runtime/src/lib/load-remote-module.ts","../../../../libs/native-federation-runtime/src/softarc-native-federation-runtime.ts"],"sourcesContent":["type Type<T> = new () => T;\n\ntype NativeFederationContainer = {\n __NATIVE_FEDERATION__: {\n baseUrlToRemoteNames: Map<string, string>;\n externals: Map<string, string>;\n };\n};\n\nexport type ShareObject = {\n version: string;\n scope?: string;\n get: () => Promise<() => Type<unknown>>;\n shareConfig?: {\n singleton?: boolean;\n requiredVersion: string;\n };\n};\n\nexport type ShareConfig = {\n [pkgName: string]: Array<ShareObject>;\n};\n\nexport type ShareOptions = {\n singleton: boolean;\n requiredVersionPrefix: '^' | '~' | '>' | '>=' | '';\n};\n\nconst defaultShareOptions: ShareOptions = {\n singleton: false,\n requiredVersionPrefix: '',\n};\n\nexport function getShared(options = defaultShareOptions) {\n const nfc = window as unknown as NativeFederationContainer;\n const externals = nfc.__NATIVE_FEDERATION__.externals;\n const shared: ShareConfig = {};\n\n const allKeys = [...externals.keys()];\n const keys = allKeys\n .filter(\n (k) =>\n !k.startsWith('/@id/') &&\n !k.startsWith('@angular-architects/module-federation') &&\n !k.endsWith('@'),\n )\n .sort();\n\n for (const key of keys) {\n const idx = key.lastIndexOf('@');\n const pkgName = key.substring(0, idx);\n const version = key.substring(idx + 1);\n const path = externals.get(key) ?? '';\n\n const shareObj: ShareObject = {\n version,\n get: async () => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const lib = await (window as any).importShim(path);\n return () => lib;\n },\n shareConfig: {\n singleton: options.singleton,\n requiredVersion: options.requiredVersionPrefix + version,\n },\n };\n\n if (!shared[pkgName]) {\n shared[pkgName] = [];\n }\n\n shared[pkgName].push(shareObj);\n }\n return shared;\n}\n","import { Remote } from './remotes';\n\nexport const nfNamespace = '__NATIVE_FEDERATION__';\n\nexport type NfCache = {\n externals: Map<string, string>;\n remoteNamesToRemote: Map<string, Remote>;\n baseUrlToRemoteNames: Map<string, string>;\n};\n\nexport type Global = {\n [nfNamespace]: NfCache;\n};\n\nconst global = globalThis as unknown as Global;\n\nglobal[nfNamespace] ??= {\n externals: new Map<string, string>(),\n remoteNamesToRemote: new Map<string, Remote>(),\n baseUrlToRemoteNames: new Map<string, string>(),\n};\n\nexport const globalCache = global[nfNamespace];\n","import { SharedInfo } from './federation-info';\nimport { globalCache } from './global-cache';\n\nconst externals = globalCache.externals;\n\nfunction getExternalKey(shared: SharedInfo) {\n return `${shared.packageName}@${shared.version}`;\n}\n\nexport function getExternalUrl(shared: SharedInfo): string | undefined {\n const packageKey = getExternalKey(shared);\n return externals.get(packageKey);\n}\n\nexport function setExternalUrl(shared: SharedInfo, url: string): void {\n const packageKey = getExternalKey(shared);\n externals.set(packageKey, url);\n}\n","export type Imports = Record<string, string>;\n\nexport type Scopes = Record<string, Imports>;\n\nexport type ImportMap = {\n imports: Imports;\n scopes: Scopes;\n};\n\nexport function mergeImportMaps(map1: ImportMap, map2: ImportMap): ImportMap {\n return {\n imports: { ...map1.imports, ...map2.imports },\n scopes: { ...map1.scopes, ...map2.scopes },\n };\n}\n","import { FederationInfo } from './federation-info';\nimport { globalCache } from './global-cache';\n\nexport type Remote = FederationInfo & {\n baseUrl: string;\n};\n\nconst remoteNamesToRemote = globalCache.remoteNamesToRemote;\nconst baseUrlToRemoteNames = globalCache.baseUrlToRemoteNames;\n\nexport function addRemote(remoteName: string, remote: Remote): void {\n remoteNamesToRemote.set(remoteName, remote);\n baseUrlToRemoteNames.set(remote.baseUrl, remoteName);\n}\n\nexport function getRemoteNameByBaseUrl(baseUrl: string): string | undefined {\n return baseUrlToRemoteNames.get(baseUrl);\n}\n\nexport function isRemoteInitialized(baseUrl: string): boolean {\n return baseUrlToRemoteNames.has(baseUrl);\n}\n\nexport function getRemote(remoteName: string): Remote | undefined {\n return remoteNamesToRemote.get(remoteName);\n}\n\nexport function hasRemote(remoteName: string): boolean {\n return remoteNamesToRemote.has(remoteName);\n}\n","import { TrustedTypePolicy, TrustedTypePolicyFactory } from 'trusted-types';\n\nconst global: any = globalThis;\n\nlet policy: TrustedTypePolicy | null | undefined;\n\nfunction createPolicy(): TrustedTypePolicy | null {\n if (policy === undefined) {\n policy = null;\n if (global.trustedTypes) {\n try {\n policy = (global.trustedTypes as TrustedTypePolicyFactory).createPolicy(\n 'native-federation',\n {\n createHTML: (html: string) => html,\n createScript: (script: string) => script,\n createScriptURL: (url: string) => url,\n },\n );\n } catch {\n // trustedTypes.createPolicy may throw an exception if called with a name that is already registered, even in report-only mode.\n }\n }\n }\n return policy;\n}\n\nexport function tryCreateTrustedScript(script: string): string | TrustedScript {\n return createPolicy()?.createScript(script) ?? script;\n}\n","import { ImportMap } from '../model/import-map';\nimport { tryCreateTrustedScript } from './trusted-types';\n\nexport function appendImportMap(importMap: ImportMap) {\n document.head.appendChild(\n Object.assign(document.createElement('script'), {\n type: tryCreateTrustedScript('importmap-shim'),\n textContent: tryCreateTrustedScript(JSON.stringify(importMap)),\n }),\n );\n}\n","/**\n * Returns the full directory of a given path.\n * @param url - The path to get the directory of.\n * @returns The full directory of the path.\n */\nexport function getDirectory(url: string) {\n const parts = url.split('/');\n parts.pop();\n return parts.join('/');\n}\n\n/**\n * Joins two paths together taking into account trailing slashes and \"./\" prefixes.\n * @param path1 - The first path to join.\n * @param path2 - The second path to join.\n * @returns The joined path.\n */\nexport function joinPaths(path1: string, path2: string) {\n while (path1.endsWith('/')) {\n path1 = path1.substring(0, path1.length - 1);\n }\n if (path2.startsWith('./')) {\n path2 = path2.substring(2, path2.length);\n }\n\n return `${path1}/${path2}`;\n}\n","export interface BuildNotificationOptions {\n enable: boolean;\n endpoint: string;\n}\n\nexport const BUILD_NOTIFICATIONS_ENDPOINT =\n '/@angular-architects/native-federation:build-notifications';\n\nexport enum BuildNotificationType {\n COMPLETED = 'federation-rebuild-complete',\n ERROR = 'federation-rebuild-error',\n CANCELLED = 'federation-rebuild-cancelled',\n}\n","import { BuildNotificationType } from './model/build-notifications-options';\n\n/**\n * Watches for federation build completion events and automatically reloads the page.\n *\n * This function establishes a Server-Sent Events (SSE) connection to listen for\n * 'federation-rebuild-complete' notifications. When a build completes successfully,\n * it triggers a page reload to reflect the latest changes.\n * @param endpoint - The SSE endpoint URL to watch for build notifications.\n */\nexport function watchFederationBuildCompletion(endpoint: string) {\n const eventSource = new EventSource(endpoint);\n\n eventSource.onmessage = function (event) {\n const data = JSON.parse(event.data);\n if (data.type === BuildNotificationType.COMPLETED) {\n console.log('[Federation] Rebuild completed, reloading...');\n window.location.reload();\n }\n };\n\n eventSource.onerror = function (event) {\n console.warn('[Federation] SSE connection error:', event);\n };\n}\n","import { getExternalUrl, setExternalUrl } from './model/externals';\nimport {\n FederationInfo,\n InitFederationOptions,\n ProcessRemoteInfoOptions,\n} from './model/federation-info';\nimport {\n ImportMap,\n Imports,\n mergeImportMaps,\n Scopes,\n} from './model/import-map';\nimport { addRemote } from './model/remotes';\nimport { appendImportMap } from './utils/add-import-map';\nimport { getDirectory, joinPaths } from './utils/path-utils';\nimport { watchFederationBuildCompletion } from './watch-federation-build';\n\n/**\n * Initializes the Native Federation runtime for the host application.\n *\n * This is the main entry point for setting up federation. It performs the following:\n * 1. Loads the host's remoteEntry.json to discover shared dependencies\n * 2. Loads each remote's remoteEntry.json to discover exposed modules\n * 3. Creates an ES Module import map with proper scoping\n * 4. Injects the import map into the DOM as a <script type=\"importmap-shim\">\n *\n * The import map allows dynamic imports to resolve correctly:\n * - Host shared deps go in root imports (e.g., \"angular\": \"./angular.js\")\n * - Remote exposed modules go in root imports (e.g., \"mfe1/Component\": \"http://...\")\n * - Remote shared deps go in scoped imports for proper resolution\n *\n * @param remotesOrManifestUrl - Either:\n * - A record of remote names to their remoteEntry.json URLs\n * Example: { mfe1: 'http://localhost:3000/remoteEntry.json' }\n * - A URL to a manifest.json that contains the remotes record\n * Example: 'http://localhost:3000/federation-manifest.json'\n *\n * @param options - Configuration options:\n * - cacheTag: A version string to append as query param for cache busting\n * Example: { cacheTag: 'v1.0.0' } results in '?t=v1.0.0' on all requests\n *\n * @returns The final merged ImportMap that was injected into the DOM\n *\n */\nexport async function initFederation(\n remotesOrManifestUrl: Record<string, string> | string = {},\n options?: InitFederationOptions,\n): Promise<ImportMap> {\n const cacheTag = options?.cacheTag ? `?t=${options.cacheTag}` : '';\n\n const normalizedRemotes =\n typeof remotesOrManifestUrl === 'string'\n ? await loadManifest(remotesOrManifestUrl + cacheTag)\n : remotesOrManifestUrl;\n\n const hostInfo = await loadFederationInfo(`./remoteEntry.json${cacheTag}`);\n\n const hostImportMap = await processHostInfo(hostInfo);\n\n // Host application is fully loaded, now we can process the remotes\n\n // Each remote contributes:\n // - Exposed modules to root imports\n // - Shared dependencies to scoped imports\n const remotesImportMap = await processRemoteInfos(normalizedRemotes, {\n throwIfRemoteNotFound: false,\n ...options,\n });\n\n const mergedImportMap = mergeImportMaps(hostImportMap, remotesImportMap);\n\n // Inject the final import map into the DOM with importmap-shim\n appendImportMap(mergedImportMap);\n\n return mergedImportMap;\n}\n\n/**\n * Loads a federation manifest file (JSON) from the given URL.\n *\n * The manifest should map remote names to their remoteEntry.json URLs.\n *\n * @param manifestUrl - The URL to the manifest.json file.\n * @returns A promise resolving to an object mapping remote names to their remoteEntry.json URLs.\n */\nasync function loadManifest(\n manifestUrl: string,\n): Promise<Record<string, string>> {\n const manifest = (await fetch(manifestUrl).then((r) => r.json())) as Record<\n string,\n string\n >;\n return manifest;\n}\n\n/**\n * Adds cache busting query parameter to a URL if cacheTag is provided.\n */\nfunction applyCacheTag(url: string, cacheTag?: string): string {\n if (!cacheTag) return url;\n\n const separator = url.includes('?') ? '&' : '?';\n return `${url}${separator}t=${cacheTag}`;\n}\n\n/**\n * Handles errors when loading a remote entry.\n * Either throws or logs based on options.\n */\nfunction handleRemoteLoadError(\n remoteName: string,\n remoteUrl: string,\n options: ProcessRemoteInfoOptions,\n originalError: Error,\n): null {\n const errorMessage = `Error loading remote entry for ${remoteName} from file ${remoteUrl}`;\n\n if (options.throwIfRemoteNotFound) {\n throw new Error(errorMessage);\n }\n\n console.error(errorMessage);\n console.error(originalError);\n return null;\n}\n\n/**\n * Fetches and registers multiple remote applications in parallel and merges their import maps.\n *\n * This function is the orchestrator for loading all remotes. It:\n * 1. Creates a promise for each remote to load its remoteEntry.json\n * 2. Applies cache busting to each remote URL\n * 3. Handles errors gracefully (logs or throws based on options)\n * 4. Merges all successful remote import maps into one\n *\n * Each remote contributes:\n * - Its exposed modules to the root imports\n * - Its shared dependencies to scoped imports\n *\n * @param remotes - Record of remote names to their remoteEntry.json URLs\n * @param options - Processing options including:\n * - throwIfRemoteNotFound: Whether to throw or log on remote load failure\n * - cacheTag: Cache busting tag to append to URLs\n *\n * @returns Merged import map containing all remotes' contributions\n *\n */\n\nexport async function processRemoteInfos(\n remotes: Record<string, string>,\n options: ProcessRemoteInfoOptions = { throwIfRemoteNotFound: false },\n): Promise<ImportMap> {\n // Each promise will independently fetch and process its remoteEntry.json\n const fetchAndRegisterRemotePromises = Object.entries(remotes).map(\n async ([remoteName, remoteUrl]): Promise<ImportMap | null> => {\n try {\n const urlWithCache = applyCacheTag(remoteUrl, options.cacheTag);\n\n return await fetchAndRegisterRemote(urlWithCache, remoteName);\n } catch (e) {\n return handleRemoteLoadError(\n remoteName,\n remoteUrl,\n options,\n e as Error,\n );\n }\n },\n );\n\n const remoteImportMaps = await Promise.all(fetchAndRegisterRemotePromises);\n\n // Filter out failed remotes (null values) and merge successful ones\n const importMap = remoteImportMaps.reduce<ImportMap>(\n (acc, remoteImportMap) =>\n remoteImportMap ? mergeImportMaps(acc, remoteImportMap) : acc,\n { imports: {}, scopes: {} },\n );\n\n return importMap;\n}\n\n/**\n * Fetches a single remote application's remoteEntry.json file and registers it in the system (global registry).\n *\n * This function handles everything needed to integrate one remote:\n * 1. Fetches the remote's remoteEntry.json file\n * 2. Extracts the base URL from the remoteEntry path\n * 3. Creates import map entries for exposed modules and shared deps\n * 4. Registers the remote in the global remotes registry\n * 5. Sets up hot reload watching if configured (development mode)\n *\n * @param federationInfoUrl - Full URL to the remote's remoteEntry.json\n * @param remoteName - Name to use for this remote (optional, uses info.name if not provided)\n *\n * @returns Import map containing this remote's exposed modules and shared dependencies\n *\n * @example\n * ```typescript\n * const importMap = await fetchAndRegisterRemote(\n * 'http://localhost:3000/mfe1/remoteEntry.json',\n * 'mfe1'\n * );\n * // Result: {\n * // imports: { 'mfe1/Component': 'http://localhost:3000/mfe1/Component.js' },\n * // scopes: { 'http://localhost:3000/mfe1/': { 'lodash': '...' } }\n * // }\n * ```\n */\nexport async function fetchAndRegisterRemote(\n federationInfoUrl: string,\n remoteName?: string,\n): Promise<ImportMap> {\n const baseUrl = getDirectory(federationInfoUrl);\n\n const remoteInfo = await loadFederationInfo(federationInfoUrl);\n\n // Uses the name from the remote's remoteEntry.json if not explicitly provided\n if (!remoteName) {\n remoteName = remoteInfo.name;\n }\n\n // Setup hot reload watching for development mode and in case it has a build notifications endpoint\n if (remoteInfo.buildNotificationsEndpoint) {\n watchFederationBuildCompletion(\n baseUrl + remoteInfo.buildNotificationsEndpoint,\n );\n }\n\n const importMap = createRemoteImportMap(remoteInfo, remoteName, baseUrl);\n\n // Register this remote in the global registry\n addRemote(remoteName, { ...remoteInfo, baseUrl });\n\n return importMap;\n}\n\n/**\n * Creates an import map for a remote application.\n *\n * The import map has two parts:\n * 1. Imports (root level): Maps remote's exposed modules\n * Example: \"mfe1/Component\" -> \"http://localhost:3000/mfe1/Component.js\"\n *\n * 2. Scopes: Maps remote's shared dependencies within its scope\n * Example: \"http://localhost:3000/mfe1/\": { \"lodash\": \"http://localhost:3000/mfe1/lodash.js\" }\n *\n * Scoping ensures that when a module from this remote imports 'lodash',\n * it gets the version from this remote's bundle, not another version.\n *\n * @param remoteInfo - Federation info from the remote's remoteEntry.json\n * @param remoteName - Name used to prefix exposed module keys\n * @param baseUrl - Base URL where the remote is hosted\n *\n * @returns Import map with imports and scopes for this remote\n */\nfunction createRemoteImportMap(\n remoteInfo: FederationInfo,\n remoteName: string,\n baseUrl: string,\n): ImportMap {\n const imports = processExposed(remoteInfo, remoteName, baseUrl);\n const scopes = processRemoteImports(remoteInfo, baseUrl);\n\n return { imports, scopes };\n}\n\n/**\n * Fetches and parses a remoteEntry.json file.\n *\n * The remoteEntry.json contains metadata about a federated module:\n * - name: The application name\n * - exposes: Array of modules this app exposes to others\n * - shared: Array of dependencies this app shares\n * - buildNotificationsEndpoint: Optional SSE endpoint for hot reload (development mode)\n *\n * @param remoteEntryUrl - URL to the remoteEntry.json file (can be relative or absolute)\n * @returns Parsed federation info object\n */\nasync function loadFederationInfo(\n remoteEntryUrl: string,\n): Promise<FederationInfo> {\n const info = (await fetch(remoteEntryUrl).then((r) =>\n r.json(),\n )) as FederationInfo;\n return info;\n}\n\n/**\n * Processes a remote's shared dependencies into scoped import map entries.\n *\n * Shared dependencies need to be scoped to avoid version conflicts.\n * When a module from \"http://localhost:3000/mfe1/\" imports \"lodash\",\n * the import map scope ensures it gets the correct version.\n *\n * Scope structure:\n * {\n * \"http://localhost:3000/mfe1/\": {\n * \"lodash\": \"http://localhost:3000/mfe1/lodash.js\",\n * \"rxjs\": \"http://localhost:3000/mfe1/rxjs.js\"\n * }\n * }\n *\n * This function also manages external URLs - if a shared dependency\n * has already been loaded from another location, it can reuse that URL.\n *\n * @param remoteInfo - Federation info containing shared dependencies\n * @param baseUrl - Base URL of the remote (used as the scope key)\n *\n * @returns Scopes object mapping baseUrl to its shared dependencies\n */\nfunction processRemoteImports(\n remoteInfo: FederationInfo,\n baseUrl: string,\n): Scopes {\n const scopes: Scopes = {};\n const scopedImports: Imports = {};\n\n for (const shared of remoteInfo.shared) {\n // Check if this dependency already has an external URL registered\n // If not, construct the URL from the base path and output filename\n const outFileName =\n getExternalUrl(shared) ?? joinPaths(baseUrl, shared.outFileName);\n\n // Register this URL as the external location for this shared dependency\n // This allows other remotes to potentially reuse this version\n setExternalUrl(shared, outFileName);\n\n // Add to the scoped imports: package name -> full URL\n scopedImports[shared.packageName] = outFileName;\n }\n\n scopes[baseUrl + '/'] = scopedImports;\n\n return scopes;\n}\n\n/**\n * Processes a remote's exposed modules into root-level import map entries.\n *\n * Exposed modules are what the remote makes available to other applications.\n * They go in the root imports (not scoped) so any app can import them.\n *\n * Example exposed module:\n * - Remote 'mfe1' exposes './Component' from file 'Component.js'\n * - Results in: \"mfe1/Component\" -> \"http://localhost:3000/mfe1/Component.js\"\n *\n * This allows other apps to do:\n * ```typescript\n * import { Component } from 'mfe1/Component';\n * ```\n *\n * @param remoteInfo - Federation info containing exposed modules\n * @param remoteName - Name to prefix the exposed keys with\n * @param baseUrl - Base URL where the remote's files are hosted\n *\n * @returns Imports object mapping remote module keys to their URLs\n */\nfunction processExposed(\n remoteInfo: FederationInfo,\n remoteName: string,\n baseUrl: string,\n): Imports {\n const imports: Imports = {};\n\n for (const exposed of remoteInfo.exposes) {\n // Create the import key by joining remote name with the exposed key\n // Example: 'mfe1' + './Component' -> 'mfe1/Component'\n const key = joinPaths(remoteName, exposed.key);\n\n // Create the full URL to the exposed module's output file\n // Example: 'http://localhost:3000/mfe1' + 'Component.js' -> 'http://localhost:3000/mfe1/Component.js'\n const value = joinPaths(baseUrl, exposed.outFileName);\n\n imports[key] = value;\n }\n\n return imports;\n}\n\n/**\n * Processes the host application's federation info into an import map.\n *\n * The host app typically doesn't expose modules (it's the consumer),\n * but it does share dependencies that should be available to remotes.\n *\n * Host shared dependencies go in root-level imports (not scoped) because:\n * 1. The host loads first and establishes the base environment\n * 2. Remotes should prefer host versions to avoid duplication\n *\n * @param hostInfo - Federation info from the host's remoteEntry.json\n * @param relBundlesPath - Relative path to the host's bundle directory (default: './')\n *\n * @returns Import map with host's shared dependencies in root imports\n */\nexport async function processHostInfo(\n hostInfo: FederationInfo,\n relBundlesPath = './',\n): Promise<ImportMap> {\n // Transform shared array into imports object\n const imports = hostInfo.shared.reduce(\n (acc, cur) => ({\n ...acc,\n [cur.packageName]: relBundlesPath + cur.outFileName,\n }),\n {},\n ) as Imports;\n\n // Register external URLs for host's shared dependencies\n // This allows remotes to discover and potentially reuse these versions\n for (const shared of hostInfo.shared) {\n setExternalUrl(shared, relBundlesPath + shared.outFileName);\n }\n\n // Host doesn't have scopes - its shared deps are at root level\n return { imports, scopes: {} };\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { fetchAndRegisterRemote } from './init-federation';\nimport {\n getRemote,\n getRemoteNameByBaseUrl,\n isRemoteInitialized,\n} from './model/remotes';\nimport { appendImportMap } from './utils/add-import-map';\nimport { getDirectory, joinPaths } from './utils/path-utils';\n\ndeclare function importShim<T>(url: string): T;\n\n/**\n * Options for loading a remote module.\n *\n * @template T - The expected type of the module's exports\n *\n * @property remoteEntry - Optional URL to the remote's remoteEntry.json file.\n * Used for lazy-loading remotes that weren't registered during initFederation\n * Example: 'http://localhost:3000/remoteEntry.json'\n *\n * @property remoteName - Optional name of the remote application.\n * Should match the name used during initFederation or the name in remoteEntry.json.\n * Example: 'mfe1'\n *\n * @property exposedModule - The key of the exposed module to load (required).\n * Must match the key defined in the remote's federation config.\n * Example: './Component' or './Dashboard'\n *\n * @property fallback - Optional fallback value to return if the remote or module cannot be loaded.\n * Prevents throwing errors and provides graceful degradation.\n * Example: A default component or null\n */\nexport type LoadRemoteModuleOptions<T = any> = {\n remoteEntry?: string;\n remoteName?: string;\n exposedModule: string;\n fallback?: T;\n};\n\n/**\n * Dynamically loads a remote module at runtime from a federated application.\n *\n * This is the primary API for consuming remote modules after federation has been initialized.\n * It supports two calling patterns:\n *\n * **Pattern 1: Using options object**\n * ```typescript\n * const module = await loadRemoteModule({\n * remoteName: 'mfe1',\n * exposedModule: './Component',\n * fallback: DefaultComponent\n * });\n * ```\n *\n * **Pattern 2: Using positional arguments**\n * ```typescript\n * const module = await loadRemoteModule('mfe1', './Component');\n * ```\n *\n * ## Loading Process\n *\n * 1. **Normalize Options**: Converts arguments into a standard options object\n * 2. **Ensure Remote Initialized**: If remoteEntry is provided and remote isn't loaded,\n * fetches and registers it dynamically\n * 3. **Resolve Remote Name**: Determines remote name from options or remoteEntry URL\n * 4. **Validate Remote**: Checks if remote exists in the registry\n * 5. **Validate Exposed Module**: Verifies the requested module is exposed by the remote\n * 6. **Import Module**: Uses dynamic import or import-shim to load the module\n * 7. **Handle Errors**: Returns fallback if provided, otherwise throws\n *\n * ## Lazy Loading Support\n *\n * If you provide a `remoteEntry` URL for a remote that wasn't initialized during\n * `initFederation()`, this function will automatically:\n * - Fetch the remote's remoteEntry.json\n * - Register it in the global registry\n * - Update the import map\n * - Then load the requested module\n *\n * This enables on-demand loading of remotes based on user interactions.\n *\n *\n * @template T - The expected type of the module's exports\n *\n * @param options - Configuration object for loading the remote module\n * @returns Promise resolving to the loaded module or fallback value\n *\n * @throws Error if remote is not found and no fallback is provided\n * @throws Error if exposed module doesn't exist and no fallback is provided\n * @throws Error if module import fails and no fallback is provided\n *\n */\nexport async function loadRemoteModule<T = any>(\n options: LoadRemoteModuleOptions,\n): Promise<T>;\nexport async function loadRemoteModule<T = any>(\n remoteName: string,\n exposedModule: string,\n): Promise<T>;\nexport async function loadRemoteModule<T = any>(\n optionsOrRemoteName: LoadRemoteModuleOptions<T> | string,\n exposedModule?: string,\n): Promise<T> {\n const options = normalizeOptions(optionsOrRemoteName, exposedModule);\n\n await ensureRemoteInitialized(options);\n\n const remoteName = getRemoteNameByOptions(options);\n\n const remote = getRemote(remoteName);\n const fallback = options.fallback;\n\n // Handles errors when the remote is missing\n const remoteError = !remote ? 'unknown remote ' + remoteName : '';\n if (!remote && !fallback) throw new Error(remoteError);\n if (!remote) {\n logClientError(remoteError);\n return Promise.resolve(fallback);\n }\n\n const exposedModuleInfo = remote.exposes.find(\n (e) => e.key === options.exposedModule,\n );\n\n // Handles errors when the exposed module is missing\n const exposedError = !exposedModuleInfo\n ? `Unknown exposed module ${options.exposedModule} in remote ${remoteName}`\n : '';\n if (!exposedModuleInfo && !fallback) throw new Error(exposedError);\n if (!exposedModuleInfo) {\n logClientError(exposedError);\n return Promise.resolve(fallback);\n }\n\n const moduleUrl = joinPaths(remote.baseUrl, exposedModuleInfo.outFileName);\n\n try {\n const module = _import<T>(moduleUrl);\n return module;\n } catch (e) {\n // Handles errors when the module import fails\n if (fallback) {\n console.error('error loading remote module', e);\n return fallback;\n }\n throw e;\n }\n}\n\n/**\n * Internal helper function to perform the dynamic import.\n *\n * @template T - The expected type of the module's exports\n * @param moduleUrl - Full URL to the module file to import\n * @returns Promise resolving to the imported module\n */\nfunction _import<T = any>(moduleUrl: string) {\n return typeof importShim !== 'undefined'\n ? importShim<T>(moduleUrl)\n : (import(/* @vite-ignore */ moduleUrl) as T);\n}\n\n/**\n * Resolves the remote name from the provided options.\n *\n * The remote name can be determined in two ways:\n * 1. If options.remoteName is provided, use it directly\n * 2. If only remoteEntry is provided, extract the baseUrl\n * and look up the remote name from the registry using that baseUrl\n *\n * @param options - Load options containing remoteName and/or remoteEntry\n * @returns The resolved remote name\n *\n * @throws Error if neither remoteName nor remoteEntry is provided\n * @throws Error if the remote name cannot be determined\n */\nfunction getRemoteNameByOptions(options: LoadRemoteModuleOptions) {\n let remoteName: string | undefined;\n\n if (options.remoteName) {\n remoteName = options.remoteName;\n } else if (options.remoteEntry) {\n const baseUrl = getDirectory(options.remoteEntry);\n remoteName = getRemoteNameByBaseUrl(baseUrl);\n } else {\n throw new Error(\n 'unexpected arguments: Please pass remoteName or remoteEntry',\n );\n }\n\n if (!remoteName) {\n throw new Error('unknown remoteName ' + remoteName);\n }\n return remoteName;\n}\n\n/**\n * Ensures that the remote is initialized before attempting to load a module from it.\n *\n * This function enables lazy-loading of remotes that weren't registered during\n * the initial `initFederation()` call. It checks if:\n * 1. A remoteEntry URL is provided in the options\n * 2. The remote at that URL hasn't been initialized yet\n *\n * If both conditions are true, it:\n * 1. Fetches the remote's remoteEntry.json file\n * 2. Registers the remote in the global registry\n * 3. Creates and appends the remote's import map to the DOM\n *\n * @param options - Load options containing optional remoteEntry URL\n * @returns Promise that resolves when the remote is initialized (or immediately if already initialized)\n *\n */\nasync function ensureRemoteInitialized(\n options: LoadRemoteModuleOptions,\n): Promise<void> {\n if (\n options.remoteEntry &&\n !isRemoteInitialized(getDirectory(options.remoteEntry))\n ) {\n const importMap = await fetchAndRegisterRemote(options.remoteEntry);\n appendImportMap(importMap);\n }\n}\n\n/**\n * Normalizes the function arguments into a standard LoadRemoteModuleOptions object.\n *\n * The function detects which pattern is being used and converts it to the\n * standard options object format for consistent internal processing.\n *\n * @param optionsOrRemoteName - Either an options object or the remote name string\n * @param exposedModule - The exposed module key\n * @returns Normalized options object\n *\n * @throws Error if arguments don't match either supported pattern\n */\nfunction normalizeOptions(\n optionsOrRemoteName: string | LoadRemoteModuleOptions,\n exposedModule: string | undefined,\n): LoadRemoteModuleOptions {\n let options: LoadRemoteModuleOptions;\n\n if (typeof optionsOrRemoteName === 'string' && exposedModule) {\n options = {\n remoteName: optionsOrRemoteName,\n exposedModule,\n };\n } else if (typeof optionsOrRemoteName === 'object' && !exposedModule) {\n options = optionsOrRemoteName;\n } else {\n throw new Error(\n 'unexpected arguments: please pass options or a remoteName/exposedModule-pair',\n );\n }\n return options;\n}\n\n/**\n * Logs an error message to the console, but only in browser environments.\n *\n * @param error - The error message to log\n *\n */\nfunction logClientError(error: string): void {\n if (typeof window !== 'undefined') {\n console.error(error);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["global"],"mappings":"AA4BA,MAAM,mBAAmB,GAAiB;AACxC,IAAA,SAAS,EAAE,KAAK;AAChB,IAAA,qBAAqB,EAAE,EAAE;CAC1B;AAEK,SAAU,SAAS,CAAC,OAAO,GAAG,mBAAmB,EAAA;IACrD,MAAM,GAAG,GAAG,MAA8C;AAC1D,IAAA,MAAM,SAAS,GAAG,GAAG,CAAC,qBAAqB,CAAC,SAAS;IACrD,MAAM,MAAM,GAAgB,EAAE;IAE9B,MAAM,OAAO,GAAG,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;IACrC,MAAM,IAAI,GAAG;AACV,SAAA,MAAM,CACL,CAAC,CAAC,KACA,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC;AACtB,QAAA,CAAC,CAAC,CAAC,UAAU,CAAC,uCAAuC,CAAC;AACtD,QAAA,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC;AAEnB,SAAA,IAAI,EAAE;AAET,IAAA,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC;QAChC,MAAM,OAAO,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC;QACrC,MAAM,OAAO,GAAG,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,CAAC;QACtC,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE;AAErC,QAAA,MAAM,QAAQ,GAAgB;YAC5B,OAAO;YACP,GAAG,EAAE,YAAW;;gBAEd,MAAM,GAAG,GAAG,MAAO,MAAc,CAAC,UAAU,CAAC,IAAI,CAAC;AAClD,gBAAA,OAAO,MAAM,GAAG;YA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E,mBAAmB;YAC/B,aAAa;SACd;IACH;SAAO,IAAI,OAAO,mBAAmB,KAAK,QAAQ,IAAI,CAAC,aAAa,EAAE;QACpE,OAAO,GAAG,mBAAmB;IAC/B;SAAO;AACL,QAAA,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E;IACH;AACA,IAAA,OAAO,OAAO;AAChB;AAEA;;;;;AAKG;AACH,SAAS,cAAc,CAAC,KAAa,EAAA;AACnC,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AACjC,QAAA,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;IACtB;AACF;;AC7QA;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
type Type<T> = new () => T;
|
|
2
|
+
type ShareObject = {
|
|
3
|
+
version: string;
|
|
4
|
+
scope?: string;
|
|
5
|
+
get: () => Promise<() => Type<unknown>>;
|
|
6
|
+
shareConfig?: {
|
|
7
|
+
singleton?: boolean;
|
|
8
|
+
requiredVersion: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
type ShareConfig = {
|
|
12
|
+
[pkgName: string]: Array<ShareObject>;
|
|
13
|
+
};
|
|
14
|
+
type ShareOptions = {
|
|
15
|
+
singleton: boolean;
|
|
16
|
+
requiredVersionPrefix: '^' | '~' | '>' | '>=' | '';
|
|
17
|
+
};
|
|
18
|
+
declare function getShared(options?: ShareOptions): ShareConfig;
|
|
19
|
+
|
|
1
20
|
type SharedInfo = {
|
|
2
21
|
singleton: boolean;
|
|
3
22
|
strictVersion: boolean;
|
|
@@ -86,7 +105,7 @@ declare function initFederation(remotesOrManifestUrl?: Record<string, string> |
|
|
|
86
105
|
* @returns Merged import map containing all remotes' contributions
|
|
87
106
|
*
|
|
88
107
|
*/
|
|
89
|
-
declare function
|
|
108
|
+
declare function processRemoteInfos(remotes: Record<string, string>, options?: ProcessRemoteInfoOptions): Promise<ImportMap>;
|
|
90
109
|
/**
|
|
91
110
|
* Fetches a single remote application's remoteEntry.json file and registers it in the system (global registry).
|
|
92
111
|
*
|
|
@@ -226,5 +245,5 @@ declare enum BuildNotificationType {
|
|
|
226
245
|
CANCELLED = "federation-rebuild-cancelled"
|
|
227
246
|
}
|
|
228
247
|
|
|
229
|
-
export { BUILD_NOTIFICATIONS_ENDPOINT, BuildNotificationType, fetchAndRegisterRemote,
|
|
230
|
-
export type { BuildNotificationOptions, ExposesInfo, FederationInfo, ImportMap, Imports, InitFederationOptions, LoadRemoteModuleOptions, ProcessRemoteInfoOptions, Scopes, SharedInfo };
|
|
248
|
+
export { BUILD_NOTIFICATIONS_ENDPOINT, BuildNotificationType, fetchAndRegisterRemote, getShared, initFederation, loadRemoteModule, mergeImportMaps, processHostInfo, processRemoteInfos };
|
|
249
|
+
export type { BuildNotificationOptions, ExposesInfo, FederationInfo, ImportMap, Imports, InitFederationOptions, LoadRemoteModuleOptions, ProcessRemoteInfoOptions, Scopes, ShareConfig, ShareObject, ShareOptions, SharedInfo };
|