Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions libs/native-federation-runtime/src/lib/init-federation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ import { watchFederationBuildCompletion } from './watch-federation-build';
* @param options - Configuration options:
* - cacheTag: A version string to append as query param for cache busting
* Example: { cacheTag: 'v1.0.0' } results in '?t=v1.0.0' on all requests
* - deployUrl: Base URL where the host's remoteEntry.json and bundles are located
* This is used to construct the URL for the host's remoteEntry.json and shared dependencies.
* Default is './' relative to the current page. If your host's remoteEntry.json is at a different location, specify it here.
* Example: { deployUrl: 'https://example.com' } results in 'https://example.com/remoteEntry.json'
*
* @returns The final merged ImportMap that was injected into the DOM
*
Expand All @@ -53,9 +57,13 @@ export async function initFederation(
? await loadManifest(remotesOrManifestUrl + cacheTag)
: remotesOrManifestUrl;

const hostInfo = await loadFederationInfo(`./remoteEntry.json${cacheTag}`);
const deployUrl = options?.deployUrl ? `${options.deployUrl}/` : './';

const hostImportMap = await processHostInfo(hostInfo);
const hostInfo = await loadFederationInfo(
`${deployUrl}remoteEntry.json${cacheTag}`,
);

const hostImportMap = await processHostInfo(hostInfo, deployUrl);

// Host application is fully loaded, now we can process the remotes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface FederationInfo {

export interface InitFederationOptions {
cacheTag?: string;
deployUrl?: string;
}

export interface ProcessRemoteInfoOptions extends InitFederationOptions {
Expand Down