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: improve migrating from 0.x #7694

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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.
SyMind marked this conversation as resolved.
Show resolved Hide resolved

```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` 钩子来实现相关的功能。
SyMind marked this conversation as resolved.
Show resolved Hide resolved

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

:::
Loading