Skip to content

Commit 6444f44

Browse files
committed
chore: rename FederationHost to ModuleFederation
1 parent b7862af commit 6444f44

File tree

41 files changed

+271
-260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+271
-260
lines changed

.changeset/poor-pillows-study.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@module-federation/webpack-bundler-runtime': patch
3+
'@module-federation/bridge-react': patch
4+
'@module-federation/data-prefetch': patch
5+
'@module-federation/runtime-core': patch
6+
'@module-federation/modern-js': patch
7+
'@module-federation/runtime': patch
8+
'@module-federation/node': patch
9+
---
10+
11+
chore: rename FederationHost to ModuleFederation

apps/website-new/docs/en/guide/basic/runtime/runtime-api.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -416,26 +416,26 @@ registerPlugins([
416416
]);
417417
```
418418
419-
## FederationConstructor
419+
## ModuleFederation
420420
421-
In addition to exposing APIs, the Federation Runtime also provides a FederationConstructor class, which you can use to create Federation instance.
421+
In addition to exposing APIs, the Runtime also provides the ModuleFederation class, which you can use to create ModuleFederation instance.
422422
423-
* What is a `Federation` instance?
423+
* What is a `ModuleFederation` instance?
424424
425-
A `Federation` instance is an instance of the `FederationConstructor` class, which contains all the functionality of the `Federation` runtime.
425+
A `ModuleFederation` instance is an instance of the `ModuleFederation` class, which contains all the functionality of the `ModuleFederation` runtime.
426426
427427
> You can enter `__FEDERATION__.__INSTANCES__` in the console to view the created instances.
428428
429-
* When to use `FederationConstructor`?
429+
* When to use `ModuleFederation` class?
430430
431-
To ensure the uniqueness of the FederationHost instance, after the build plugin creates an instance, it will be stored in memory. The exported APIs all first obtain the FederationHost instance from memory and then call the APIs of the FederationHost instance. This is also why APIs like loadRemote can be used directly from the `module-federation/runtime` package and inherently understand what application container they are attached to.
431+
To ensure the uniqueness of the ModuleFederation instance, after the build plugin creates an instance, it will be stored in memory. The exported APIs all first obtain the ModuleFederation instance from memory and then call the APIs of the ModuleFederation instance. This is also why APIs like loadRemote can be used directly from the `module-federation/runtime` package and inherently understand what application container they are attached to.
432432
433-
However, this singleton pattern also limits the ability to create multiple instances, as it assumes that there is only one instance per bundle. Therefore, if you need to create a new instance , you can use the FederationHost class to create a new one.
433+
However, this singleton pattern also limits the ability to create multiple instances, as it assumes that there is only one instance per bundle. Therefore, if you need to create a new instance , you can use the ModuleFederation class to create a new one.
434434
435435
```ts
436-
import { FederationConstructor } from '@vmok/kit/runtime';
436+
import { ModuleFederation } from '@module-federation/enhanced/runtime';
437437

438-
const host = new FederationConstructor({
438+
const mf = new ModuleFederation({
439439
name: '@demo/host',
440440
remotes: [
441441
{
@@ -445,5 +445,5 @@ const host = new FederationConstructor({
445445
]
446446
});
447447

448-
host.loadRemote('@demo/sub1/util').then((m) => m.add(1, 2, 3));
448+
mf.loadRemote('@demo/sub1/util').then((m) => m.add(1, 2, 3));
449449
```

apps/website-new/docs/en/guide/basic/runtime/runtime-hooks.mdx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ function beforeInit(args: BeforeInitOptions): BeforeInitOptions
1313

1414
type BeforeInitOptions ={
1515
userOptions: UserOptions;
16-
options: FederationRuntimeOptions;
17-
origin: FederationHost;
16+
options: ModuleFederationRuntimeOptions;
17+
origin: ModuleFederation;
1818
shareInfo: ShareInfos;
1919
}
2020

21-
interface FederationRuntimeOptions {
21+
interface ModuleFederationRuntimeOptions {
2222
id?: string;
2323
name: string;
2424
version?: string;
@@ -41,8 +41,8 @@ Called after the MF instance is initialized.
4141
function init(args: InitOptions): void
4242

4343
type InitOptions ={
44-
options: FederationRuntimeOptions;
45-
origin: FederationHost;
44+
options: ModuleFederationRuntimeOptions;
45+
origin: ModuleFederation;
4646
}
4747
```
4848
@@ -59,8 +59,8 @@ async function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestO
5959

6060
type BeforeRequestOptions ={
6161
id: string;
62-
options: FederationRuntimeOptions;
63-
origin: FederationHost;
62+
options: ModuleFederationRuntimeOptions;
63+
origin: ModuleFederation;
6464
}
6565
```
6666
@@ -80,8 +80,8 @@ type AfterResolveOptions ={
8080
pkgNameOrAlias: string;
8181
expose: string;
8282
remote: Remote;
83-
options: FederationRuntimeOptions;
84-
origin: FederationHost;
83+
options: ModuleFederationRuntimeOptions;
84+
origin: ModuleFederation;
8585
remoteInfo: RemoteInfo;
8686
remoteSnapshot?: ModuleInfo;
8787
}
@@ -104,15 +104,15 @@ type OnLoadOptions ={
104104
pkgNameOrAlias: string;
105105
remote: Remote;
106106
options: ModuleOptions;
107-
origin: FederationHost;
107+
origin: ModuleFederation;
108108
exposeModule: any;
109109
exposeModuleFactory: any;
110110
moduleInstance: Module;
111111
}
112112

113113
type ModuleOptions = {
114114
remoteInfo: RemoteInfo;
115-
host: FederationHost;
115+
host: ModuleFederation;
116116
}
117117

118118
interface RemoteInfo {
@@ -160,7 +160,7 @@ type ErrorLoadRemoteOptions ={
160160
id: string;
161161
error: unknown;
162162
from: 'build' | 'runtime';
163-
origin: FederationHost;
163+
origin: ModuleFederation;
164164
}
165165
```
166166
* example
@@ -214,7 +214,7 @@ type BeforeLoadShareOptions ={
214214
pkgName: string;
215215
shareInfo?: Shared;
216216
shared: Options['shared'];
217-
origin: FederationHost;
217+
origin: ModuleFederation;
218218
}
219219
```
220220
@@ -306,7 +306,7 @@ async function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePrel
306306
type BeforePreloadRemoteOptions ={
307307
preloadOps: Array<PreloadRemoteArgs>;
308308
options: Options;
309-
origin: FederationHost;
309+
origin: ModuleFederation;
310310
}
311311
```
312312
@@ -322,7 +322,7 @@ Used to control the generation of resources that need to be preloaded.
322322
async function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>
323323

324324
type GeneratePreloadAssetsOptions ={
325-
origin: FederationHost;
325+
origin: ModuleFederation;
326326
preloadOptions: PreloadOptions[number];
327327
remote: Remote;
328328
remoteInfo: RemoteInfo;

apps/website-new/docs/en/plugin/dev/index.mdx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ function beforeInit(args: BeforeInitOptions): BeforeInitOptions;
118118

119119
type BeforeInitOptions = {
120120
userOptions: UserOptions;
121-
options: FederationRuntimeOptions;
122-
origin: FederationHost;
121+
options: ModuleFederationRuntimeOptions;
122+
origin: ModuleFederation;
123123
shareInfo: ShareInfos;
124124
};
125125

126-
interface FederationRuntimeOptions {
126+
interface ModuleFederationRuntimeOptions {
127127
id?: string;
128128
name: string;
129129
version?: string;
@@ -146,8 +146,8 @@ Called during the initialization of the remote container.
146146
function init(args: InitOptions): void;
147147

148148
type InitOptions = {
149-
options: FederationRuntimeOptions;
150-
origin: FederationHost;
149+
options: ModuleFederationRuntimeOptions;
150+
origin: ModuleFederation;
151151
};
152152
```
153153

@@ -166,8 +166,8 @@ async function beforeRequest(
166166

167167
type BeforeRequestOptions = {
168168
id: string;
169-
options: FederationRuntimeOptions;
170-
origin: FederationHost;
169+
options: ModuleFederationRuntimeOptions;
170+
origin: ModuleFederation;
171171
};
172172
```
173173

@@ -189,8 +189,8 @@ type AfterResolveOptions = {
189189
pkgNameOrAlias: string;
190190
expose: string;
191191
remote: Remote;
192-
options: FederationRuntimeOptions;
193-
origin: FederationHost;
192+
options: ModuleFederationRuntimeOptions;
193+
origin: ModuleFederation;
194194
remoteInfo: RemoteInfo;
195195
remoteSnapshot?: ModuleInfo;
196196
};
@@ -213,15 +213,15 @@ type OnLoadOptions = {
213213
pkgNameOrAlias: string;
214214
remote: Remote;
215215
options: ModuleOptions;
216-
origin: FederationHost;
216+
origin: ModuleFederation;
217217
exposeModule: any;
218218
exposeModuleFactory: any;
219219
moduleInstance: Module;
220220
};
221221

222222
type ModuleOptions = {
223223
remoteInfo: RemoteInfo;
224-
host: FederationHost;
224+
host: ModuleFederation;
225225
};
226226

227227
interface RemoteInfo {
@@ -278,7 +278,7 @@ type ErrorLoadRemoteOptions = {
278278
options?: any;
279279
from: 'build' | 'runtime';
280280
lifecycle: 'onLoad' | 'beforeRequest';
281-
origin: FederationHost;
281+
origin: ModuleFederation;
282282
};
283283
```
284284

@@ -337,7 +337,7 @@ type BeforeLoadShareOptions = {
337337
pkgName: string;
338338
shareInfo?: Shared;
339339
shared: Options['shared'];
340-
origin: FederationHost;
340+
origin: ModuleFederation;
341341
};
342342
```
343343

@@ -440,7 +440,7 @@ async function beforePreloadRemote(
440440
type BeforePreloadRemoteOptions = {
441441
preloadOps: Array<PreloadRemoteArgs>;
442442
options: Options;
443-
origin: FederationHost;
443+
origin: ModuleFederation;
444444
};
445445
```
446446

@@ -458,7 +458,7 @@ async function generatePreloadAssets(
458458
): Promise<PreloadAssets>;
459459

460460
type GeneratePreloadAssetsOptions = {
461-
origin: FederationHost;
461+
origin: ModuleFederation;
462462
preloadOptions: PreloadOptions[number];
463463
remote: Remote;
464464
remoteInfo: RemoteInfo;

apps/website-new/docs/zh/guide/basic/runtime/runtime-api.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -416,26 +416,26 @@ registerPlugins([
416416
]);
417417
```
418418
419-
## FederationConstructor
419+
## ModuleFederation
420420
421-
`Federation Runtime` 除了暴露出 API 外,还提供了 `FederationConstructor` 类,你可以使用它来创建一个 `Federation` 实例。
421+
`Runtime` 除了暴露出 API 外,还提供了 `ModuleFederation` 类,你可以使用它来创建一个 `ModuleFederation` 实例。
422422
423-
* 什么是 `Federation` 实例 ?
423+
* 什么是 `ModuleFederation` 实例 ?
424424
425-
`Federation` 实例是 `FederationConstructor` 类的实例,它包含了 `Federation` 运行时的所有功能。
425+
`ModuleFederation` 实例是 `ModuleFederation` 类的实例,它包含了 `ModuleFederation` 运行时的所有功能。
426426
427427
> 你可以在控制台输入 `__FEDERATION__.__INSTANCES__` 来查看已经创建好的实例。
428428
429-
* 什么时候使用 `FederationConstructor`
429+
* 什么时候使用 `ModuleFederation` class
430430
431-
为了保证 `FederationConstructor` 实例的唯一性,我们在构建插件创建实例后,会将其存储到内存中,导出的 API 都是先从内存中获取 `FederationConstructor` 实例,然后再调用 `FederationConstructor` 实例的 API。这也是为什么 `loadRemote` 等 API 可以直接使用的原因。
431+
为了保证 `ModuleFederation` 实例的唯一性,我们在构建插件创建实例后,会将其存储到内存中,导出的 API 都是先从内存中获取 `ModuleFederation` 实例,然后再调用 `ModuleFederation` 实例的 API。这也是为什么 `loadRemote` 等 API 可以直接使用的原因。
432432
433-
但是这种单例模式同时也限制无法创建多份实例,因此如果你需要**创建新的 FederationConstructor 实例**,那么你可以使用 `FederationConstructor` 类来创建一个新的实例。
433+
但是这种单例模式同时也限制无法创建多份实例,因此如果你需要**创建新的 ModuleFederation 实例**,那么你可以使用 `ModuleFederation` 类来创建一个新的实例。
434434
435435
```ts
436-
import { FederationConstructor } from '@module-federation/enhanced/runtime';
436+
import { ModuleFederation } from '@module-federation/enhanced/runtime';
437437

438-
const host = new FederationConstructor({
438+
const mf = new ModuleFederation({
439439
name: 'host',
440440
remotes: [
441441
{

apps/website-new/docs/zh/guide/basic/runtime/runtime-hooks.mdx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ function beforeInit(args: BeforeInitOptions): BeforeInitOptions
1313

1414
type BeforeInitOptions ={
1515
userOptions: UserOptions;
16-
options: FederationRuntimeOptions;
17-
origin: FederationHost;
16+
options: ModuleFederationRuntimeOptions;
17+
origin: ModuleFederation;
1818
shareInfo: ShareInfos;
1919
}
2020

21-
interface FederationRuntimeOptions {
21+
interface ModuleFederationRuntimeOptions {
2222
id?: string;
2323
name: string;
2424
version?: string;
@@ -41,8 +41,8 @@ interface FederationRuntimeOptions {
4141
function init(args: InitOptions): void
4242

4343
type InitOptions ={
44-
options: FederationRuntimeOptions;
45-
origin: FederationHost;
44+
options: ModuleFederationRuntimeOptions;
45+
origin: ModuleFederation;
4646
}
4747
```
4848
@@ -59,8 +59,8 @@ async function beforeRequest(args: BeforeRequestOptions): Promise<BeforeRequestO
5959

6060
type BeforeRequestOptions ={
6161
id: string;
62-
options: FederationRuntimeOptions;
63-
origin: FederationHost;
62+
options: ModuleFederationRuntimeOptions;
63+
origin: ModuleFederation;
6464
}
6565
```
6666
@@ -80,8 +80,8 @@ type AfterResolveOptions ={
8080
pkgNameOrAlias: string;
8181
expose: string;
8282
remote: Remote;
83-
options: FederationRuntimeOptions;
84-
origin: FederationHost;
83+
options: ModuleFederationRuntimeOptions;
84+
origin: ModuleFederation;
8585
remoteInfo: RemoteInfo;
8686
remoteSnapshot?: ModuleInfo;
8787
}
@@ -106,15 +106,15 @@ type OnLoadOptions ={
106106
pkgNameOrAlias: string;
107107
remote: Remote;
108108
options: ModuleOptions;
109-
origin: FederationHost;
109+
origin: ModuleFederation;
110110
exposeModule: any;
111111
exposeModuleFactory: any;
112112
moduleInstance: Module;
113113
}
114114

115115
type ModuleOptions = {
116116
remoteInfo: RemoteInfo;
117-
host: FederationHost;
117+
host: ModuleFederation;
118118
}
119119

120120
interface RemoteInfo {
@@ -162,7 +162,7 @@ type ErrorLoadRemoteOptions ={
162162
id: string;
163163
error: unknown;
164164
from: 'build' | 'runtime';
165-
origin: FederationHost;
165+
origin: ModuleFederation;
166166
}
167167
```
168168
* example
@@ -216,7 +216,7 @@ type BeforeLoadShareOptions ={
216216
pkgName: string;
217217
shareInfo?: Shared;
218218
shared: Options['shared'];
219-
origin: FederationHost;
219+
origin: ModuleFederation;
220220
}
221221
```
222222
@@ -308,7 +308,7 @@ async function beforePreloadRemote(args: BeforePreloadRemoteOptions): BeforePrel
308308
type BeforePreloadRemoteOptions ={
309309
preloadOps: Array<PreloadRemoteArgs>;
310310
options: Options;
311-
origin: FederationHost;
311+
origin: ModuleFederation;
312312
}
313313
```
314314
@@ -324,7 +324,7 @@ type BeforePreloadRemoteOptions ={
324324
async function generatePreloadAssets(args: GeneratePreloadAssetsOptions): Promise<PreloadAssets>
325325

326326
type GeneratePreloadAssetsOptions ={
327-
origin: FederationHost;
327+
origin: ModuleFederation;
328328
preloadOptions: PreloadOptions[number];
329329
remote: Remote;
330330
remoteInfo: RemoteInfo;

0 commit comments

Comments
 (0)