Skip to content

Commit ce166e0

Browse files
author
Heiner Pöpping
committed
🏷️ Add types and documentation for initModuleFederationSharing
1 parent f5a6961 commit ce166e0

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/util/initModuleFederationSharing.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import type { ModuleFederation } from '@module-federation/enhanced/runtime';
3+
import type { ModuleFederation, ModuleFederationRuntimePlugin } from '@module-federation/enhanced/runtime';
44
import { SequentialLoadPlugin } from '../plugins/SequentialLoadPlugin';
55

66
let ReactDOMClient;
@@ -10,7 +10,20 @@ try {
1010
// do nothing
1111
}
1212

13-
export const initModuleFederationSharing = ({ name, plugins = [] }) => {
13+
export const initModuleFederationSharing = ({ scope, name, plugins = [] }: {
14+
/**
15+
* Module Federation scope; should be identical to the package name in package.json, formatted in snake_case.
16+
*/
17+
scope: string,
18+
/**
19+
* @deprecated use `scope` instead
20+
*/
21+
name?: string,
22+
/**
23+
* Additional runtime plugins
24+
*/
25+
plugins: ModuleFederationRuntimePlugin[]
26+
}) => {
1427
// forces single instance of module federation runtime
1528
if (globalThis.moduleFederationScopes) {
1629
return;
@@ -39,7 +52,7 @@ export const initModuleFederationSharing = ({ name, plugins = [] }) => {
3952
}
4053

4154
const instance: ModuleFederation = createInstance({
42-
name: name ?? '',
55+
name: scope ?? name ?? '',
4356
remotes: [],
4457
shared,
4558
plugins: [SequentialLoadPlugin(), ...plugins],

0 commit comments

Comments
 (0)