From 5962041e6aff37df57881b233357ac2c2c441d51 Mon Sep 17 00:00:00 2001 From: Wouter van Kuipers Date: Wed, 11 Feb 2026 16:56:54 +0100 Subject: [PATCH] feat: provide an option to load the `remoteEntry.json` via a deploy url --- .../src/lib/init-federation.ts | 12 ++++++++++-- .../src/lib/model/federation-info.ts | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libs/native-federation-runtime/src/lib/init-federation.ts b/libs/native-federation-runtime/src/lib/init-federation.ts index 0f473ee7..f7e78932 100644 --- a/libs/native-federation-runtime/src/lib/init-federation.ts +++ b/libs/native-federation-runtime/src/lib/init-federation.ts @@ -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 * @@ -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 diff --git a/libs/native-federation-runtime/src/lib/model/federation-info.ts b/libs/native-federation-runtime/src/lib/model/federation-info.ts index f3396387..913f76d7 100644 --- a/libs/native-federation-runtime/src/lib/model/federation-info.ts +++ b/libs/native-federation-runtime/src/lib/model/federation-info.ts @@ -27,6 +27,7 @@ export interface FederationInfo { export interface InitFederationOptions { cacheTag?: string; + deployUrl?: string; } export interface ProcessRemoteInfoOptions extends InitFederationOptions {