Skip to content

Commit

Permalink
docs: improve migrating from 0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
SyMind committed Aug 27, 2024
1 parent 6d31029 commit ec0a8e0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions website/docs/en/guide/migration/rspack_0.x.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,19 @@ Additionally, `Resolver` now only supports the following methods:
- `withOptions`

This change might cause some plugins to become unusable.

:::tip
Rspack supports the `NormalModuleFactory`'s `resolve` hook. In most cases, you can use this hook as a replacement for the `Resolver`'s `resolve` hook to achieve the same functionality.

```js
compiler.hooks.normalModuleFactory.tap('PLUGIN', normalModuleFactory => {
normalModuleFactory.hooks.resolve.tap('PLUGIN', data => {
// Redirect the module
if (data.request === './foo.js') {
data.request = './bar.js';
}
});
});
```

:::
16 changes: 16 additions & 0 deletions website/docs/zh/guide/migration/rspack_0.x.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,19 @@ module.exports = {
- `withOptions`

此变更可能会导致某些插件无法正常使用。

:::tip
Rspack 支持 `NormalModuleFactory``resolve` 钩子,在大多数情况下,你可以使用该钩子替代 `Resolver``resolve` 钩子来实现相关的功能。

```js
compiler.hooks.normalModuleFactory.tap('PLUGIN', normalModuleFactory => {
normalModuleFactory.hooks.resolve.tap('PLUGIN', data => {
// 重定向模块
if (data.request === './foo.js') {
data.request = './bar.js';
}
});
});
```

:::

0 comments on commit ec0a8e0

Please sign in to comment.