Skip to content

Commit 2f6d4e9

Browse files
authored
feat: enable Rspack by default in new project (#6167)
1 parent 94c4f0a commit 2f6d4e9

File tree

54 files changed

+71
-200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+71
-200
lines changed

.changeset/short-snails-burn.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@modern-js/app-tools': minor
3+
---
4+
5+
feat: mark rspack as stable and support enabling rspack build via `bundler:'rspack'`
6+
7+
feat: 标记 rspack 功能稳定,支持通过 `bundler:'rspack'` 开启 rspack 构建

.changeset/three-geese-invent.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@modern-js/mwa-generator': minor
3+
'@modern-js/generator-common': minor
4+
---
5+
6+
feat: enable Rspack by default in new project

packages/devtools/client/modern.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,5 @@ export default defineConfig<'rspack'>({
114114
.use(ServiceWorkerCompilerPlugin);
115115
},
116116
},
117-
plugins: [appTools({ bundler: 'experimental-rspack' })],
117+
plugins: [appTools({ bundler: 'rspack' })],
118118
});

packages/document/builder-doc/docs/en/config/tools/bundlerChain.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ You can modify the webpack and Rspack configuration by configuring `tools.bundle
77

88
Bundler chain is a subset of webpack chain, which contains part of the webpack chain API that you can use to modify both webpack and Rspack configuration.
99

10-
Configurations modified via bundler chain will work on both webpack and Rspack builds. Note that the bundler chain only supports modifying the configuration of the non-differentiated parts of webpack and Rspack. For example, modifying the devtool configuration option (webpack and Rspack have the same devtool property value type), or adding an [Rspack-compatible](https://www.rspack.dev/guide/plugin-compat.html) webpack plugin.
10+
Configurations modified via bundler chain will work on both webpack and Rspack builds. Note that the bundler chain only supports modifying the configuration of the non-differentiated parts of webpack and Rspack. For example, modifying the devtool configuration option (webpack and Rspack have the same devtool property value type), or adding an [Rspack-compatible](https://rspack.dev/guide/compatibility/plugin) webpack plugin.
1111

1212
:::
1313

1414
> `tools.bundlerChain` is executed earlier than tools.webpackChain / tools.webpack / tools.rspack and thus will be overridden by changes in others.
1515
16-
For more information, please refer to [Rsbuild#tools.bundlerChain](https://rsbuild.dev/config/tools/bundler-chain)
16+
For more information, please refer to [Rsbuild#tools.bundlerChain](https://rsbuild.dev/config/tools/bundler-chain).
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Bundler chain is a subset of webpack chain, which contains part of the webpack chain API that you can use to modify both webpack and Rspack configuration.
22

3-
Configurations modified via bundler chain will work on both webpack and Rspack builds. Note that the bundler chain only supports modifying the configuration of the non-differentiated parts of webpack and Rspack. For example, modifying the devtool configuration option (webpack and Rspack have the same devtool property value type), or adding an [Rspack-compatible](https://www.rspack.dev/guide/plugin-compat.html) webpack plugin.
3+
Configurations modified via bundler chain will work on both webpack and Rspack builds. Note that the bundler chain only supports modifying the configuration of the non-differentiated parts of webpack and Rspack. For example, modifying the devtool configuration option (webpack and Rspack have the same devtool property value type), or adding an [Rspack-compatible](https://rspack.dev/guide/compatibility/plugin) webpack plugin.

packages/document/builder-doc/docs/zh/config/tools/bundlerChain.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
Bundler chain 是 webpack chain 的子集,其中包含一部分 webpack chain API,你可以用它来同时修改 webpack 和 Rspack 的配置。
1212

13-
通过 bundler chain 修改的配置,在 webpack 和 Rspack 构建时均可生效。需要注意的是,bundler chain 只支持修改 webpack 和 Rspack 间无差异部分的配置。如,修改 devtool 配置项(webpack 和 Rspack 的 devtool 属性值类型相同),或添加一个[Rspack 兼容](https://www.rspack.dev/zh/guide/plugin-compat.html)的 webpack 插件。
13+
通过 bundler chain 修改的配置,在 webpack 和 Rspack 构建时均可生效。需要注意的是,bundler chain 只支持修改 webpack 和 Rspack 间无差异部分的配置。如,修改 devtool 配置项(webpack 和 Rspack 的 devtool 属性值类型相同),或添加一个[Rspack 兼容](https://rspack.dev/zh/guide/compatibility/plugin)的 webpack 插件。
1414

1515
:::
1616

1717
> `tools.bundlerChain` 的执行时机早于 tools.webpackChain / tools.webpack / tools.rspack,因此会被其他几个配置中的修改所覆盖。
1818
19-
更多信息可参考 [Rsbuild#tools.bundlerChain](https://rsbuild.dev/zh/config/tools/bundler-chain)
19+
更多信息可参考 [Rsbuild#tools.bundlerChain](https://rsbuild.dev/zh/config/tools/bundler-chain)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Bundler chain 是 webpack chain 的子集,其中包含一部分 webpack chain API,你可以用它来同时修改 webpack 和 Rspack 的配置。
22

3-
通过 bundler chain 修改的配置,在 webpack 和 Rspack 构建时均可生效。需要注意的是,bundler chain 只支持修改 webpack 和 Rspack 间无差异部分的配置。如,修改 devtool 配置项(webpack 和 Rspack 的 devtool 属性值类型相同),或添加一个[Rspack 兼容](https://www.rspack.dev/zh/guide/plugin-compat.html)的 webpack 插件。
3+
通过 bundler chain 修改的配置,在 webpack 和 Rspack 构建时均可生效。需要注意的是,bundler chain 只支持修改 webpack 和 Rspack 间无差异部分的配置。如,修改 devtool 配置项(webpack 和 Rspack 的 devtool 属性值类型相同),或添加一个[Rspack 兼容](https://rspack.dev/zh/guide/compatibility/plugin)的 webpack 插件。

packages/document/main-doc/docs/en/components/init-app.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
? Please select the type of project you want to create: Web App
55
? Please select the programming language: TS
66
? Please select the package manager: pnpm
7-
? Please select the bundler: webpack
87
```
98
109
After create the project, Modern.js will automatically install dependencies and create a git repository.

packages/document/main-doc/docs/en/components/init-rspack-app.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ $ npx @modern-js/create@latest myapp
33
? Please select the type of project you want to create: Web App
44
? Please select the programming language: TS
55
? Please select the package manager: pnpm
6-
? Please select the bundler: Rspack
76
```

packages/document/main-doc/docs/en/guides/advanced-features/rspack-start.mdx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This document will show you how to enable Rspack build mode in Modern.js.
1414

1515
## Initializing an Rspack project
1616

17-
The Modern.js generator provides an interactive question-and-answer interface to initialize a project. To create an Rspack project, simply select the **Rspack** build tool by running:
17+
The Modern.js new project has enabled Rspack by default. Just execute [Initialize Project](/guides/get-started/quick-start.html#initialize) to create an Rspack project:
1818

1919
import InitRspackApp from '@site-docs-en/components/init-rspack-app';
2020

@@ -24,22 +24,22 @@ After the project is created, you can experience the project by running `pnpm ru
2424

2525
## Enable Rspack build
2626

27-
Since Modern.js MAJOR_VERSION.46.0, you can enable Rspack build by add the following configuration in `modern.config.ts`:
27+
Since Modern.js MAJOR_VERSION.59.0, you can enable Rspack build by add the following configuration in `modern.config.ts`:
2828

2929
```diff title=modern.config.ts
3030
import { appTools, defineConfig } from '@modern-js/app-tools';
3131

3232
export default defineConfig({
3333
plugins: [
3434
appTools({
35-
+ bundler: 'experimental-rspack',
35+
+ bundler: 'rspack',
3636
}),
3737
],
3838
});
3939
```
4040

4141
:::tip
42-
If your current version is lower than MAJOR_VERSION.46.0, you can upgrade by executing `npx modern upgrade`.
42+
If your current version is lower than MAJOR_VERSION.59.0, you can upgrade by executing `npx modern upgrade`.
4343
:::
4444

4545
import RspackPrecautions from '@modern-js/builder-doc/docs/en/shared/rspackPrecautions.md';
@@ -70,12 +70,6 @@ export default {
7070
};
7171
```
7272

73-
:::tip
74-
After using Rspack for build, there are currently a few configs that are not supported in Rspack, such as [source.moduleScopes](/configure/app/source/module-scopes).
75-
76-
For unsupported configurations, we have marked `Bundler: only support webpack` or `Bundler: only support Rspack` in the document. Please refer to the specific configuration introduction.
77-
:::
78-
7973
## Modify transpile configuration
8074

8175
Modern.js uses Rspack [builtin:swc-loader](https://rspack.dev/guide/features/builtin-swc-loader) for code translation in Rspack mode.

0 commit comments

Comments
 (0)