Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 21 additions & 3 deletions website/docs/en/guide/optimization/build-performance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The following are methods for improving performance in development mode.

Enabling lazy compilation can significantly reduce the number of modules compiled at dev startup and improve startup time.

```js
```ts title="rsbuild.config.ts"
export default {
dev: {
lazyCompilation: true,
Expand All @@ -42,6 +42,24 @@ export default {

> Please refer to [dev.lazyCompilation](/config/dev/lazy-compilation) for more information.

### Enable incremental build

Rspack provides experimental [experiments.incremental](https://rspack.dev/config/experiments#experimentsincremental) configuration, which can improve the HMR speed in development mode.

```ts title="rsbuild.config.ts"
const isDev = process.env.NODE_ENV === 'development';

export default {
tools: {
rspack: {
experiments: {
incremental: isDev,
},
},
},
};
```

### Source map format

In order to provide a good debugging experience, Rsbuild uses the `cheap-module-source-map` format source map by default in development mode, which is a high-quality source map format and will bring certain performance overhead.
Expand All @@ -50,7 +68,7 @@ You can improve build speed by adjusting the source map format in development mo

For example to disable source map:

```js
```ts title="rsbuild.config.ts"
export default {
output: {
sourceMap: {
Expand All @@ -62,7 +80,7 @@ export default {

Or set the source map format of the development mode to the cheapest `eval` format:

```js
```ts title="rsbuild.config.ts"
export default {
output: {
sourceMap: {
Expand Down
24 changes: 21 additions & 3 deletions website/docs/zh/guide/optimization/build-performance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Rsbuild 默认对构建性能进行了充分优化,但是随着使用场景变

启用 lazy compilation 可以显著减少开发启动时编译的模块数量,从而提升启动时间。

```js
```ts title="rsbuild.config.ts"
export default {
dev: {
lazyCompilation: true,
Expand All @@ -42,6 +42,24 @@ export default {

> 请参考 [dev.lazyCompilation](/config/dev/lazy-compilation) 了解更多。

### 开启增量构建

Rspack 提供了实验性的 [experiments.incremental](https://rspack.dev/zh/config/experiments#experimentsincremental) 配置,开启后可以提升开发阶段 HMR 的速度。

```ts title="rsbuild.config.ts"
const isDev = process.env.NODE_ENV === 'development';

export default {
tools: {
rspack: {
experiments: {
incremental: isDev,
},
},
},
};
```

### Source map 格式

为了提供良好的调试体验,Rsbuild 在开发模式下默认使用 `cheap-module-source-map` 格式 source map,这是一种高质量的 source map 格式,会带来一定的性能开销。
Expand All @@ -50,7 +68,7 @@ export default {

比如禁用 source map:

```js
```ts title="rsbuild.config.ts"
export default {
output: {
sourceMap: {
Expand All @@ -62,7 +80,7 @@ export default {

或是把开发模式的 source map 格式设置为开销最小的 `eval` 格式:

```js
```ts title="rsbuild.config.ts"
export default {
output: {
sourceMap: {
Expand Down