Skip to content

Commit 5072973

Browse files
committed
docs: typo
1 parent 513009c commit 5072973

File tree

3 files changed

+46
-45
lines changed

3 files changed

+46
-45
lines changed

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

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,49 @@
33
import { Badge } from '@theme';
44
import Collapse from '@components/Collapse'
55

6-
If the build plugin is used, an MF instance will be automatically created and stored in memory when the project starts. You can directly call methods of the MF instance via the <Badge>API</Badge>.
6+
If the build plugin is used, an MF instance will be automatically created and stored in memory when the project starts. You can directly call methods of the MF instance via the .
77

88
If the build plugin is not used, you need to manually create an MF instance before calling the corresponding API.
99

10-
## ModuleFederation <Badge type='info'>Class</Badge>
11-
12-
In addition to exposing APIs, the Runtime also provides the ModuleFederation class, which you can use to create ModuleFederation instance.
13-
1410
* What is a `ModuleFederation` instance?
1511

1612
A `ModuleFederation` instance is an instance of the `ModuleFederation` class, which contains all the functionality of the `ModuleFederation` runtime.
1713

1814
> You can enter `__FEDERATION__.__INSTANCES__` in the console to view the created instances.
1915
20-
* When to use `ModuleFederation` class?
16+
## createInstance
17+
18+
In addition to exposing APIs, the Runtime also provides the `createInstance`, which you can use to create ModuleFederation instance.
19+
20+
* When to use `createInstance`?
2121

2222
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/enhanced/runtime` package and inherently understand what application container they are attached to.
2323

24-
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.
24+
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 [createInstance](#createinstance) to create a new one.
2525

2626
```ts
2727
import { createInstance } from '@module-federation/enhanced/runtime';
2828

2929
const mf = createInstance({
30-
name: '@demo/host',
30+
name: 'host',
3131
remotes: [
3232
{
33-
name: '@demo/sub1',
34-
entry: 'http://localhost:8080/vmok-manifest.json'
33+
name: 'sub1',
34+
entry: 'http://localhost:8080/mf-manifest.json'
3535
}
3636
]
3737
});
3838

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

42-
## init <Badge>API</Badge> <Badge type='danger'>Deprecated</Badge>
42+
## init <Badge type='danger'>Deprecated</Badge>
4343

4444
:::warning Warning
4545

4646
This API will be deprecated. If you need to get an existing instance, you can use [getInstance](#getinstance) to retrieve the created instance.
4747

48-
If you need to create a new instance, please use the [ModuleFederation](#modulefederation) class.
48+
If you need to create a new instance, please use the [createInstance](#createinstance).
4949

5050
:::
5151

@@ -138,7 +138,7 @@ init({
138138
```
139139
</Collapse>
140140

141-
## getInstance <Badge>API</Badge>
141+
## getInstance
142142

143143
- Type: `getInstance(): ModuleFederation`
144144
- Retrieves the `ModuleFederation` instance created by the build plugin
@@ -152,9 +152,9 @@ const mfInstance = getInstance();
152152
mfInstance.loadRemote('remote/util');
153153
```
154154

155-
If the build plugin is not used, calling `getInstance` will throw an exception. In this case, you need to use the [ModuleFederation](#modulefederation) class to create a new instance.
155+
If the build plugin is not used, calling `getInstance` will throw an exception. In this case, you need to use the [createInstance](#createinstance) to create a new instance.
156156

157-
## registerRemotes <Badge>API</Badge>
157+
## registerRemotes
158158

159159
<Collapse>
160160

@@ -196,22 +196,23 @@ If use build plugin:
196196
```ts
197197
import { registerRemotes } from '@module-federation/enhanced/runtime';
198198

199-
// Add a new remote @demo/sub2
199+
// Add a new remote sub2
200200
registerRemotes([
201201
{
202202
name: 'sub2',
203203
entry: 'http://localhost:2002/mf-manifest.json',
204204
}
205205
]);
206206

207-
// Overwrite the previous remote @demo/sub1
207+
// Overwrite the previous remote sub1
208208
registerRemotes([
209209
{
210210
name: 'sub1',
211211
entry: 'http://localhost:2003/mf-manifest.json',
212212
}
213213
],{ force:true });
214214
```
215+
215216
If not use build plugin:
216217

217218

@@ -228,15 +229,15 @@ const mf = createInstance({
228229
]
229230
});
230231

231-
// Add a new remote @demo/sub2
232+
// Add a new remote sub2
232233
mf.registerRemotes([
233234
{
234235
name: 'sub2',
235236
entry: 'http://localhost:2002/mf-manifest.json',
236237
}
237238
]);
238239

239-
// Overwrite the previous remote @demo/sub1
240+
// Overwrite the previous remote sub1
240241
mf.registerRemotes([
241242
{
242243
name: 'sub1',
@@ -245,7 +246,7 @@ mf.registerRemotes([
245246
],{ force:true });
246247
```
247248

248-
## registerPlugins <Badge>API</Badge>
249+
## registerPlugins
249250

250251
- type
251252

@@ -289,7 +290,7 @@ registerPlugins([
289290
]);
290291
```
291292

292-
## registerShared <Badge>API</Badge>
293+
## registerShared
293294

294295
<Collapse>
295296

@@ -353,7 +354,7 @@ registerShared({
353354
});
354355
```
355356

356-
## loadRemote <Badge>API</Badge>
357+
## loadRemote
357358

358359
- Type: `loadRemote(id: string)`
359360
- Loads a remote module.
@@ -369,7 +370,7 @@ loadRemote("remote/util").then((m)=> m.add(1,2,3));
369370
loadRemote("app1/util").then((m)=> m.add(1,2,3));
370371
```
371372

372-
## loadShare <Badge>API</Badge>
373+
## loadShare
373374

374375
- Type: `loadShare(pkgName: string, extraOptions?: { customShareInfo?: Partial<Shared>;resolver?: (sharedOptions: ShareInfos[string]) => Shared;})`
375376
- Gets a `share` dependency. When there is a `share` dependency in the global environment that meets the requirements of the current `host`, the existing dependency that meets the `share` conditions will be reused first. Otherwise, its own dependency will be loaded and stored in the global cache.
@@ -426,7 +427,7 @@ loadShare('react', {
426427
});
427428
```
428429

429-
## preloadRemote <Badge>API</Badge>
430+
## preloadRemote
430431

431432
<Collapse>
432433

@@ -486,9 +487,9 @@ registerRemotes([
486487
},
487488
]);
488489

489-
// Preload the @demo/sub1 module
490+
// Preload the sub1 module
490491
// Filter resource information that contains 'ignore' in the resource name
491-
// Only preload the sub-dependency @demo/sub1-button module
492+
// Only preload the sub-dependency sub1-button module
492493
preloadRemote([
493494
{
494495
nameOrAlias: 'sub1',
@@ -500,17 +501,17 @@ preloadRemote([
500501
]);
501502

502503

503-
// Preload the @demo/sub2 module
504-
// Preload all exposes under @demo/sub2
505-
// Preload the synchronous and asynchronous resources of @demo/sub2
504+
// Preload the sub2 module
505+
// Preload all exposes under sub2
506+
// Preload the synchronous and asynchronous resources of sub2
506507
preloadRemote([
507508
{
508509
nameOrAlias: 'sub2',
509510
resourceCategory: 'all',
510511
},
511512
]);
512513

513-
// Preload the add expose of the @demo/sub3 module
514+
// Preload the add expose of the sub3 module
514515
preloadRemote([
515516
{
516517
nameOrAlias: 'sub3',

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import { PackageManagerTabs } from '@theme';
6262
If use build plugin, you can directly register modules using `registerRemotes`.
6363

6464
```ts
65-
import { init, loadRemote } from '@module-federation/enhanced/runtime';
65+
import { registerRemotes } from '@module-federation/enhanced/runtime';
6666

6767
registerRemotes([
6868
{

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const mf = createInstance({
3636
]
3737
});
3838

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

4242
## init <Badge type='danger'>废弃</Badge>
@@ -45,7 +45,7 @@ mf.loadRemote('@demo/sub1/util').then((m) => m.add(1, 2, 3));
4545

4646
此 API 将被废弃。如果需要获取已创建的实例,可以使用 [getInstance](#getinstance) 获取已创建的实例。
4747

48-
如果需要创建新的实例,请使用 [createInstance](#createinstance) class
48+
如果需要创建新的实例,请使用 [createInstance](#createinstance)
4949

5050
:::
5151

@@ -152,7 +152,7 @@ const mfInstance = getInstance();
152152
mfInstance.loadRemote('remote/util');
153153
```
154154

155-
如果没有使用构建插件,调用 `getInstance` 会抛出异常,此时你需要使用 [ModuleFederation](#modulefederation) class 来创建一个新的实例。
155+
如果没有使用构建插件,调用 `getInstance` 会抛出异常,此时你需要使用 [createInstance](#createinstance) 来创建一个新的实例。
156156

157157
## registerRemotes
158158

@@ -196,15 +196,15 @@ interface RemoteWithVersion {
196196
```ts
197197
import { registerRemotes } from '@module-federation/enhanced/runtime';
198198

199-
// 增加新的 remote @demo/sub2
199+
// 增加新的 remote sub2
200200
registerRemotes([
201201
{
202202
name: 'sub2',
203203
entry: 'http://localhost:2002/mf-manifest.json',
204204
}
205205
]);
206206

207-
// 覆盖之前的 remote @demo/sub1
207+
// 覆盖之前的 remote sub1
208208
registerRemotes([
209209
{
210210
name: 'sub1',
@@ -228,15 +228,15 @@ const mf = createInstance({
228228
]
229229
});
230230

231-
// 增加新的 remote @demo/sub2
231+
// 增加新的 remote sub2
232232
mf.registerRemotes([
233233
{
234234
name: 'sub2',
235235
entry: 'http://localhost:2002/mf-manifest.json',
236236
}
237237
]);
238238

239-
// 覆盖之前的 remote @demo/sub1
239+
// 覆盖之前的 remote sub1
240240
mf.registerRemotes([
241241
{
242242
name: 'sub1',
@@ -487,9 +487,9 @@ registerRemotes([
487487
},
488488
]);
489489

490-
// 预加载 @demo/sub1 模块
490+
// 预加载 sub1 模块
491491
// 过滤资源名称中携带 ignore 的资源信息
492-
// 只预加载子依赖的 @demo/sub1-button 模块
492+
// 只预加载子依赖的 sub1-button 模块
493493
preloadRemote([
494494
{
495495
nameOrAlias: 'sub1',
@@ -501,17 +501,17 @@ preloadRemote([
501501
]);
502502

503503

504-
// 预加载 @demo/sub2 模块
505-
// 预加载 @demo/sub2 下的所有 expose
506-
// 预加载 @demo/sub2 的同步资源和异步资源
504+
// 预加载 sub2 模块
505+
// 预加载 sub2 下的所有 expose
506+
// 预加载 sub2 的同步资源和异步资源
507507
preloadRemote([
508508
{
509509
nameOrAlias: 'sub2',
510510
resourceCategory: 'all',
511511
},
512512
]);
513513

514-
// 预加载 @demo/sub3 模块的 add expose
514+
// 预加载 sub3 模块的 add expose
515515
preloadRemote([
516516
{
517517
nameOrAlias: 'sub3',

0 commit comments

Comments
 (0)