Skip to content

Commit

Permalink
docs: use Rsdoctor for duplicated packages (#1853)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Mar 18, 2024
1 parent a285e61 commit 98a1311
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
13 changes: 13 additions & 0 deletions packages/document/docs/en/config/module-federation/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ After setting the `moduleFederation.options` option, Rsbuild will take the follo

## Options

The type of `moduleFederation.options` is exactly the same as the ModuleFederationPlugin plugin of Rspack:

```ts title="rsbuild.config.ts"
export default defineConfig({
moduleFederation: {
options: {
name: 'remote',
// other options
},
},
});
```

Please refer to the [ModuleFederationPlugin](https://rspack.dev/config/plugins#containermodulefederationplugin) document for all available options.

## Example
Expand Down
14 changes: 12 additions & 2 deletions packages/document/docs/en/guide/optimization/optimize-bundle.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ Bundle size optimization is an important part in production build because it dir

## Reduce duplicate dependencies

In real projects, there will be some third-party dependencies installed with multiple versions. Duplicate dependencies can lead to larger bundles and slower builds.
It is common for web projects to bundle multiple versions of third-party dependencies. Duplicate dependencies can lead to increased bundle size and slower build speed.

We can detect or eliminate duplicate dependencies with some community tools.
### Detect duplicate dependencies

You can use [Rsdoctor](https://rsdoctor.dev) to detect whether there are duplicate dependencies in the project. Rsdoctor will analyze during the build process, find any duplicate bundled dependencies and display them visually:

![](https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-alerts.png)

For more details, see [Rsdoctor - Duplicate Dependency Problem](https://rsdoctor.dev/blog/topic/duplicate-pkg-problem).

### Eliminate duplicate dependencies

We can eliminate duplicate dependencies with the package manager.

- If you are using `pnpm >= 7.26.0`, you can use the [pnpm dedupe](https://pnpm.io/cli/dedupe) command to upgrade and eliminate duplicate dependencies.

Expand Down
13 changes: 13 additions & 0 deletions packages/document/docs/zh/config/module-federation/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@

## 选项

`moduleFederation.options` 的类型与 Rspack 的 ModuleFederationPlugin 插件完全一致:

```ts title="rsbuild.config.ts"
export default defineConfig({
moduleFederation: {
options: {
name: 'remote',
// other options
},
},
});
```

请参考 [ModuleFederationPlugin](https://rspack.dev/config/plugins#containermodulefederationplugin) 文档来了解所有可用的选项。

## 示例
Expand Down
12 changes: 11 additions & 1 deletion packages/document/docs/zh/guide/optimization/optimize-bundle.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@

## 减少重复依赖

在业务项目中,会存在某些第三方依赖被安装了多个版本的现象。重复依赖会导致包体积变大、构建速度变慢。
在 Web 项目中,经常出现某些第三方依赖被打包了多个版本的现象。重复依赖会导致包体积变大、构建速度变慢。

### 检测重复依赖

你可以使用 [Rsdoctor](https://rsdoctor.dev) 来检测项目中是否存在重复依赖,Rsdoctor 会在构建过程中进行分析,找出所有重复打包的依赖包,并可视化展示出来:

![](https://lf3-static.bytednsdoc.com/obj/eden-cn/lognuvj/rsdoctor/docs/usage/bundle/bundle-alerts.png)

详见 [Rsdoctor - 重复依赖问题](https://rsdoctor.dev/zh/blog/topic/duplicate-pkg-problem)

### 消除重复依赖

我们可以通过社区中的一些工具来检测或消除重复依赖。

Expand Down

0 comments on commit 98a1311

Please sign in to comment.