/** * Options for loading a remote module. * * @template T - The expected type of the module's exports * * @property remoteEntry - Optional URL to the remote's remoteEntry.json file. * Used for lazy-loading remotes that weren't registered during initFederation * Example: 'http://localhost:3000/remoteEntry.json' * * @property remoteName - Optional name of the remote application. * Should match the name used during initFederation or the name in remoteEntry.json. * Example: 'mfe1' * * @property exposedModule - The key of the exposed module to load (required). * Must match the key defined in the remote's federation config. * Example: './Component' or './Dashboard' * * @property fallback - Optional fallback value to return if the remote or module cannot be loaded. * Prevents throwing errors and provides graceful degradation. * Example: A default component or null */ export type LoadRemoteModuleOptions = { remoteEntry?: string; remoteName?: string; exposedModule: string; fallback?: T; }; /** * Dynamically loads a remote module at runtime from a federated application. * * This is the primary API for consuming remote modules after federation has been initialized. * It supports two calling patterns: * * **Pattern 1: Using options object** * ```typescript * const module = await loadRemoteModule({ * remoteName: 'mfe1', * exposedModule: './Component', * fallback: DefaultComponent * }); * ``` * * **Pattern 2: Using positional arguments** * ```typescript * const module = await loadRemoteModule('mfe1', './Component'); * ``` * * ## Loading Process * * 1. **Normalize Options**: Converts arguments into a standard options object * 2. **Ensure Remote Initialized**: If remoteEntry is provided and remote isn't loaded, * fetches and registers it dynamically * 3. **Resolve Remote Name**: Determines remote name from options or remoteEntry URL * 4. **Validate Remote**: Checks if remote exists in the registry * 5. **Validate Exposed Module**: Verifies the requested module is exposed by the remote * 6. **Import Module**: Uses dynamic import or import-shim to load the module * 7. **Handle Errors**: Returns fallback if provided, otherwise throws * * ## Lazy Loading Support * * If you provide a `remoteEntry` URL for a remote that wasn't initialized during * `initFederation()`, this function will automatically: * - Fetch the remote's remoteEntry.json * - Register it in the global registry * - Update the import map * - Then load the requested module * * This enables on-demand loading of remotes based on user interactions. * * * @template T - The expected type of the module's exports * * @param options - Configuration object for loading the remote module * @returns Promise resolving to the loaded module or fallback value * * @throws Error if remote is not found and no fallback is provided * @throws Error if exposed module doesn't exist and no fallback is provided * @throws Error if module import fails and no fallback is provided * * @deprecated This package has reached end-of-life and is no longer maintained. * Please switch over to the @softarc/native-federation-orchestrator library. */ export declare function loadRemoteModule(options: LoadRemoteModuleOptions): Promise; /** * @deprecated This package has reached end-of-life and is no longer maintained. * Please switch over to the @softarc/native-federation-orchestrator library. */ export declare function loadRemoteModule(remoteName: string, exposedModule: string): Promise;