Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: hmr plugin docs #6284

Merged
merged 4 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions website/docs/en/plugins/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

Rspack enhances its compilation capabilities through a rich ecosystem of plugins. These plugins fall into the following three categories:

## Synchronized Built-in Plugins from webpack
## Webpack-aligned Built-in Plugins

To align with webpack's functionality, Rspack has replicated most of webpack's built-in plugins. They maintain the same naming and configuration parameters as closely as possible and provide the same features.

## Rspack's Unique Built-in Plugins
## Rspack-only Built-in Plugins

Combining its own implementation characteristics, Rspack offers several unique plugins as alternatives to corresponding plugins from the webpack ecosystem, aiming to deliver more efficient performance.

Expand Down
21 changes: 19 additions & 2 deletions website/docs/en/plugins/webpack/hot-module-replacement-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,25 @@ import { ApiMeta } from '../../../../components/ApiMeta.tsx';

<ApiMeta addedVersion={'0.3.3'} />

This plugin is used to add the Hot Module Replacement feature. When added, it will add the runtime modules required for the hot change to the runtime chunk.
Enables Hot Module Replacement.

:::warning
HMR should **never** be used in production.
:::

Enabling HMR is straightforward and in most cases no options are necessary.

```js
new rspack.HotModuleReplacementPlugin();
new rspack.HotModuleReplacementPlugin({
// Options...
});
```

## Options

### strictModuleErrorHandling

Handle error in module loading as per EcmaScript Modules spec at a performance cost.
Boshen marked this conversation as resolved.
Show resolved Hide resolved

- **Type:** `boolean`
- **Default:** `false`
2 changes: 1 addition & 1 deletion website/docs/en/plugins/webpack/index.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Table } from '@builtIns';
import { PluginSupportStatusTable } from '../../../../components/PluginSupportStatusTable';

# Synchronized Built-in Plugins from webpack
# Webpack-aligned Built-in Plugins

The table below shows the support status of Rspack for the built-in plugins in webpack. If you are interested in participating in the development of plugins or features that have not yet been implemented, we would be very happy to have you join us.

Expand Down
21 changes: 19 additions & 2 deletions website/docs/zh/plugins/webpack/hot-module-replacement-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,25 @@ import { ApiMeta } from '../../../../components/ApiMeta.tsx';

<ApiMeta addedVersion={'0.3.3'} />

此插件用来添加热模块更新功能,添加后会在产物中加入热更所需的运行时模块。
此插件用于实现 HMR(Hot Module Replacement)。

:::warning 警告
HMR **绝对不能**被用在生产环境。
:::

启用 HMR 很容易,且在大多数情况下不需要任何配置。

```js
new rspack.HotModuleReplacementPlugin();
new rspack.HotModuleReplacementPlugin({
// 选项...
});
```

## 选项

### strictModuleErrorHandling

按照 ES Module 规范处理 module 加载时的错误,会有性能损失。

- **类型:** `boolean`
- **默认值:** `false`
Loading