Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion website/docs/en/plugins/webpack/entry-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,21 @@ type EntryOptions =

If `options` is a string, its value will be used as `name`.

Please refer to [Entry Description Object](/config/entry#entry-description-object) for all available options.
Refer to [Entry description object](/config/entry#entry-description-object) for all available options.

## Global entry

When the plugin's `name` option is set to `undefined`, the entry is treated as a global entry. It's automatically injected into:

1. All regular entry chunks
2. All asynchronous entries (for example, worker chunks created with `new Worker()`)

This allows you to inject global runtime code, such as the dev server's HMR runtime or the initialization logic for module federation.

```js
new rspack.EntryPlugin(
context,
'./global-runtime.js',
{ name: undefined }
);
```
17 changes: 17 additions & 0 deletions website/docs/zh/plugins/webpack/entry-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,20 @@ type EntryOptions =
当 `options` 为字符串时,它的值会被作为 `name` 使用。

请参考 [入口描述对象](/config/entry#入口描述对象) 了解所有可用的选项。

## 全局入口

当插件的 `name` 选项为 `undefined` 时,该入口被视为全局入口,它会自动注入到:

1. 所有常规入口 chunk
2. 所有异步入口(例如通过 `new Worker()` 创建的 worker chunk)

这可以用于注入一段全局代码,例如 dev server 的热更新运行时代码,或是模块联邦的初始化逻辑。

```js
new rspack.EntryPlugin(
context,
'./global-runtime.js',
{ name: undefined }
);
```
Loading