Skip to content

Commit 2b7ce75

Browse files
committed
docs: add createInstance desc
1 parent a944c2d commit 2b7ce75

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ This singleton pattern works for most scenarios, but in the following cases, you
2020
- Multiple ModuleFederation instances need to be created with different configurations for each instance
2121
- You want to use ModuleFederation's partitioning feature to encapsulate corresponding APIs for use in other projects
2222

23+
* `createInstance` will not overwrite an existing instance. Each call will create a new instance.
24+
2325
```ts
2426
import { createInstance } from '@module-federation/enhanced/runtime';
2527

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ import Runtime from '@components/zh/runtime/index';
1212

1313
* 什么时候使用 `createInstance`
1414

15-
为了保证 `ModuleFederation` 实例的唯一性,我们在构建插件创建实例后,会将其存储到内存中,导出的 API 都是先从内存中获取 `ModuleFederation` 实例,然后再调用 `ModuleFederation` 实例的 API。这也是为什么 `loadRemote` 等 API 可以直接使用的原因。
15+
为了保证 `ModuleFederation` 实例的唯一性,我们在构建插件创建实例后,会将其存储到内存中,导出的 API 都是先从内存中获取 `ModuleFederation` 实例,然后再调用 `ModuleFederation` 实例的 API。这也是为什么 `loadRemote` 等 API 可以直接使用的原因。
1616

17-
这种单例模式适用于大多数场景,但如果在以下场景,你需要使用 `createInstance`
17+
这种单例模式适用于大多数场景,但如果在以下场景,你需要使用 `createInstance`
1818

19-
- 没有使用构建插件(纯运行时场景)
20-
- 需要创建多个 ModuleFederation 实例,每个实例的配置不同
21-
- 希望使用 ModuleFederation 分治特性,封装相应的 API 提供给其他项目使用
19+
- 没有使用构建插件(纯运行时场景)
20+
- 需要创建多个 ModuleFederation 实例,每个实例的配置不同
21+
- 希望使用 ModuleFederation 分治特性,封装相应的 API 提供给其他项目使用
22+
23+
24+
* `createInstance` 不会对已存在的实例进行覆盖,每次调用都会创建一个新的实例。
2225

2326
```ts
2427
import { createInstance } from '@module-federation/enhanced/runtime';

0 commit comments

Comments
 (0)