Skip to content

Commit 12be835

Browse files
committed
docs(environment-api): clarify loadBundle behavior and usage
1 parent 3e068eb commit 12be835

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

website/docs/en/api/javascript-api/environment-api.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,9 @@ console.log(webStats.toJson({ all: false }));
261261

262262
### loadBundle
263263

264-
Load and execute the bundles on the server side. This method returns the exports of the entry module.
264+
Loads and executes the compiled bundle on the server. This method returns the exported content of the specified entry module and is typically used to run bundles generated by Rsbuild in a server-side environment.
265+
266+
`loadBundle` resolves only after the build process has finished and the [onAfterDevCompile](/plugins/dev/hooks#onafterdevcompile) hook has completed. As a result, it cannot be called within the `onAfterDevCompile` hook.
265267

266268
- **Type:**
267269

website/docs/zh/api/javascript-api/environment-api.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,9 @@ console.log(webStats.toJson({ all: false }));
262262

263263
### loadBundle
264264

265-
在服务端加载并执行构建产物。该方法会返回入口模块导出的内容。
265+
用于在服务端加载并执行构建产物。调用该方法后,会返回指定入口模块导出的内容,通常用于在服务端环境中运行由 Rsbuild 构建生成的产物。
266+
267+
`loadBundle` 会在构建完成且 [onAfterDevCompile](/plugins/dev/hooks#onafterdevcompile) hook 执行结束后返回结果。因此,无法在 `onAfterDevCompile` hook 内调用 `loadBundle`
266268

267269
- **类型:**
268270

0 commit comments

Comments
 (0)