From b891c3bcfaa6ae3129169ccaa7753bd3122cf507 Mon Sep 17 00:00:00 2001 From: Cong-Cong Date: Thu, 18 Apr 2024 19:48:40 +0800 Subject: [PATCH 1/4] docs: improve hmr plugin docs --- .../webpack/hot-module-replacement-plugin.mdx | 21 +++++++++++++++++-- .../webpack/hot-module-replacement-plugin.mdx | 21 +++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/website/docs/en/plugins/webpack/hot-module-replacement-plugin.mdx b/website/docs/en/plugins/webpack/hot-module-replacement-plugin.mdx index e35dec0a56b..fdff5c71f2a 100644 --- a/website/docs/en/plugins/webpack/hot-module-replacement-plugin.mdx +++ b/website/docs/en/plugins/webpack/hot-module-replacement-plugin.mdx @@ -4,8 +4,25 @@ import { ApiMeta } from '../../../../components/ApiMeta.tsx'; -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. + +- **Type:** `boolean` +- **Default:** `false` diff --git a/website/docs/zh/plugins/webpack/hot-module-replacement-plugin.mdx b/website/docs/zh/plugins/webpack/hot-module-replacement-plugin.mdx index 480dc37d3f2..58898670e6f 100644 --- a/website/docs/zh/plugins/webpack/hot-module-replacement-plugin.mdx +++ b/website/docs/zh/plugins/webpack/hot-module-replacement-plugin.mdx @@ -4,8 +4,25 @@ import { ApiMeta } from '../../../../components/ApiMeta.tsx'; -此插件用来添加热模块更新功能,添加后会在产物中加入热更所需的运行时模块。 +此插件用于实现 HMR(Hot Module Replacement)。 + +```warning 警告 +HMR **绝对不能**被用在生产环境。 +``` + +启用 HMR 很容易,且在大多数情况下不需要任何配置。 ```js -new rspack.HotModuleReplacementPlugin(); +new rspack.HotModuleReplacementPlugin({ + // 选项... +}); ``` + +## 选项 + +### strictModuleErrorHandling + +按照 ES Module 规范处理 module 加载时的错误,会有性能损失。 + +- **类型:** `boolean` +- **默认值:** `false` From 4eaf67ba2043b1f51821b0f39a8dbccb6a91a394 Mon Sep 17 00:00:00 2001 From: Cong-Cong Date: Thu, 18 Apr 2024 19:51:07 +0800 Subject: [PATCH 2/4] fix: english title in plugin --- website/docs/en/plugins/index.mdx | 4 ++-- website/docs/en/plugins/webpack/index.mdx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/website/docs/en/plugins/index.mdx b/website/docs/en/plugins/index.mdx index 6ba3086fb90..53871fb06dd 100644 --- a/website/docs/en/plugins/index.mdx +++ b/website/docs/en/plugins/index.mdx @@ -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. diff --git a/website/docs/en/plugins/webpack/index.mdx b/website/docs/en/plugins/webpack/index.mdx index 55ed96fb2a3..eb2c16018b0 100644 --- a/website/docs/en/plugins/webpack/index.mdx +++ b/website/docs/en/plugins/webpack/index.mdx @@ -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. From 493548813e21e58839307405ad4703c1f520b22d Mon Sep 17 00:00:00 2001 From: Cong-Cong Date: Thu, 18 Apr 2024 19:52:47 +0800 Subject: [PATCH 3/4] fix: warning --- .../docs/en/plugins/webpack/hot-module-replacement-plugin.mdx | 4 ++-- .../docs/zh/plugins/webpack/hot-module-replacement-plugin.mdx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/website/docs/en/plugins/webpack/hot-module-replacement-plugin.mdx b/website/docs/en/plugins/webpack/hot-module-replacement-plugin.mdx index fdff5c71f2a..7f421239c13 100644 --- a/website/docs/en/plugins/webpack/hot-module-replacement-plugin.mdx +++ b/website/docs/en/plugins/webpack/hot-module-replacement-plugin.mdx @@ -6,9 +6,9 @@ import { ApiMeta } from '../../../../components/ApiMeta.tsx'; Enables Hot Module Replacement. -```warning +:::warning HMR should **never** be used in production. -``` +::: Enabling HMR is straightforward and in most cases no options are necessary. diff --git a/website/docs/zh/plugins/webpack/hot-module-replacement-plugin.mdx b/website/docs/zh/plugins/webpack/hot-module-replacement-plugin.mdx index 58898670e6f..9374fcc0b9a 100644 --- a/website/docs/zh/plugins/webpack/hot-module-replacement-plugin.mdx +++ b/website/docs/zh/plugins/webpack/hot-module-replacement-plugin.mdx @@ -6,9 +6,9 @@ import { ApiMeta } from '../../../../components/ApiMeta.tsx'; 此插件用于实现 HMR(Hot Module Replacement)。 -```warning 警告 +:::warning 警告 HMR **绝对不能**被用在生产环境。 -``` +::: 启用 HMR 很容易,且在大多数情况下不需要任何配置。 From 5e26bc727503e6b0a91f29394c67d598aeeb412d Mon Sep 17 00:00:00 2001 From: Boshen Date: Thu, 18 Apr 2024 22:14:31 +0800 Subject: [PATCH 4/4] Update website/docs/en/plugins/webpack/hot-module-replacement-plugin.mdx --- .../docs/en/plugins/webpack/hot-module-replacement-plugin.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/en/plugins/webpack/hot-module-replacement-plugin.mdx b/website/docs/en/plugins/webpack/hot-module-replacement-plugin.mdx index 7f421239c13..ab19861157b 100644 --- a/website/docs/en/plugins/webpack/hot-module-replacement-plugin.mdx +++ b/website/docs/en/plugins/webpack/hot-module-replacement-plugin.mdx @@ -22,7 +22,7 @@ new rspack.HotModuleReplacementPlugin({ ### strictModuleErrorHandling -Handle error in module loading as per EcmaScript Modules spec at a performance cost. +Handle error in module loading as per ECMAScript Modules spec at a performance cost. - **Type:** `boolean` - **Default:** `false`