@modern-js/main-doc 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/en/apis/app/commands.mdx +1 -1
- package/docs/en/community/blog/v3-release-note.mdx +5 -2
- package/docs/en/components/rsbuild.mdx +1 -1
- package/docs/en/configure/app/builder-plugins.mdx +1 -1
- package/docs/en/configure/app/dev/server.mdx +6 -6
- package/docs/en/configure/app/resolve/alias-strategy.mdx +1 -1
- package/docs/en/configure/app/resolve/dedupe.mdx +1 -1
- package/docs/en/configure/app/security/sri.mdx +1 -1
- package/docs/en/configure/app/source/decorators.mdx +1 -1
- package/docs/en/configure/app/tools/bundler-chain.mdx +1 -1
- package/docs/en/configure/app/tools/swc.mdx +2 -2
- package/docs/en/guides/advanced-features/compatibility.mdx +1 -1
- package/docs/en/guides/advanced-features/page-performance/optimize-bundle.mdx +1 -1
- package/docs/en/guides/basic-features/css/css.mdx +4 -4
- package/docs/en/guides/basic-features/css/tailwindcss.mdx +2 -2
- package/docs/en/guides/concept/builder.mdx +3 -3
- package/docs/en/guides/get-started/tech-stack.mdx +3 -3
- package/docs/en/guides/troubleshooting/builder.mdx +4 -4
- package/docs/en/guides/upgrade/config.mdx +3 -3
- package/docs/en/guides/upgrade/other.mdx +50 -0
- package/docs/en/guides/upgrade/overview.mdx +1 -1
- package/docs/en/guides/upgrade/tailwindcss.mdx +1 -1
- package/docs/en/plugin/cli-plugins/api.mdx +9 -9
- package/docs/en/plugin/introduction.mdx +4 -4
- package/docs/zh/apis/app/commands.mdx +1 -1
- package/docs/zh/community/blog/v3-release-note.mdx +4 -2
- package/docs/zh/components/rsbuild.mdx +1 -1
- package/docs/zh/configure/app/builder-plugins.mdx +1 -1
- package/docs/zh/configure/app/dev/server.mdx +6 -6
- package/docs/zh/configure/app/resolve/alias-strategy.mdx +1 -1
- package/docs/zh/configure/app/resolve/dedupe.mdx +1 -1
- package/docs/zh/configure/app/security/sri.mdx +1 -1
- package/docs/zh/configure/app/source/decorators.mdx +1 -1
- package/docs/zh/configure/app/tools/bundler-chain.mdx +1 -1
- package/docs/zh/configure/app/tools/swc.mdx +2 -2
- package/docs/zh/guides/advanced-features/compatibility.mdx +1 -1
- package/docs/zh/guides/advanced-features/page-performance/optimize-bundle.mdx +1 -1
- package/docs/zh/guides/basic-features/css/css.mdx +4 -4
- package/docs/zh/guides/basic-features/css/tailwindcss.mdx +2 -2
- package/docs/zh/guides/concept/builder.mdx +3 -3
- package/docs/zh/guides/get-started/tech-stack.mdx +3 -3
- package/docs/zh/guides/troubleshooting/builder.mdx +4 -4
- package/docs/zh/guides/upgrade/config.mdx +3 -3
- package/docs/zh/guides/upgrade/other.md +50 -0
- package/docs/zh/guides/upgrade/overview.mdx +1 -1
- package/docs/zh/guides/upgrade/tailwindcss.mdx +1 -1
- package/docs/zh/plugin/cli-plugins/api.mdx +9 -9
- package/docs/zh/plugin/introduction.mdx +4 -4
- package/package.json +3 -3
- package/src/i18n/enUS.ts +5 -1
- package/src/i18n/zhCN.ts +5 -1
- package/src/pages/index.module.scss +93 -0
- package/src/pages/index.tsx +12 -0
|
@@ -7,7 +7,7 @@ title: aliasStrategy
|
|
|
7
7
|
- **类型:** `'prefer-tsconfig' | 'prefer-alias'`
|
|
8
8
|
- **默认值:** `'prefer-tsconfig'`
|
|
9
9
|
|
|
10
|
-
设置路径别名解析的策略,用于控制 `tsconfig.json` 中的 paths 选项与 Rsbuild 的 [resolve.alias](https://v2.rsbuild.
|
|
10
|
+
设置路径别名解析的策略,用于控制 `tsconfig.json` 中的 paths 选项与 Rsbuild 的 [resolve.alias](https://v2.rsbuild.rs/config/resolve/alias) 选项之间的优先级关系。
|
|
11
11
|
|
|
12
12
|
import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
|
|
13
13
|
|
|
@@ -6,7 +6,7 @@ title: dedupe
|
|
|
6
6
|
|
|
7
7
|
- **类型:** `string[]`
|
|
8
8
|
|
|
9
|
-
强制 Rsbuild 从项目根目录解析指定的包,这可以用于移除重复包和减少包大小。对应 Rsbuild 的 [resolve.dedupe](https://v2.rsbuild.
|
|
9
|
+
强制 Rsbuild 从项目根目录解析指定的包,这可以用于移除重复包和减少包大小。对应 Rsbuild 的 [resolve.dedupe](https://v2.rsbuild.rs/config/resolve/dedupe) 配置。
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
|
|
@@ -18,7 +18,7 @@ type SriOptions = {
|
|
|
18
18
|
为 HTML 所引入的 `<script>` 和 `<link rel="stylesheet">` 标签添加完整性属性 —— `integrity`,使浏览器能够验证引入资源的完整性,以此防止下载的资源被篡改。
|
|
19
19
|
|
|
20
20
|
:::info
|
|
21
|
-
SRI 的具体介绍可以参考 [Rsbuild security.sri](https://v2.rsbuild.
|
|
21
|
+
SRI 的具体介绍可以参考 [Rsbuild security.sri](https://v2.rsbuild.rs/zh/config/security/sri)。
|
|
22
22
|
|
|
23
23
|
该配置类型和 Rsbuild 不完全一致,在构建时将自动进行转换。
|
|
24
24
|
:::
|
|
@@ -21,7 +21,7 @@ const defaultDecorators = {
|
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
:::warning
|
|
24
|
-
该配置项的使用方式与 Rsbuild 一致,但默认值不同。详细信息请参考 [Rsbuild - source.decorators](https://v2.rsbuild.
|
|
24
|
+
该配置项的使用方式与 Rsbuild 一致,但默认值不同。详细信息请参考 [Rsbuild - source.decorators](https://v2.rsbuild.rs/zh/config/source/decorators)。
|
|
25
25
|
:::
|
|
26
26
|
|
|
27
27
|
我们发现大部分的项目仍使用 `legacy` 版本的装饰器语法,因此默认值为 `legacy`。
|
|
@@ -30,4 +30,4 @@ Bundler chain 是基于 Rspack 配置 API 实现的链式配置工具,你可
|
|
|
30
30
|
|
|
31
31
|
> `tools.bundlerChain` 的执行时机早于 tools.rspack,因此会被 tools.rspack 中的修改所覆盖。
|
|
32
32
|
|
|
33
|
-
更多信息可参考 [Rsbuild#tools.bundlerChain](https://v2.rsbuild.
|
|
33
|
+
更多信息可参考 [Rsbuild#tools.bundlerChain](https://v2.rsbuild.rs/zh/config/tools/bundler-chain)。
|
|
@@ -35,7 +35,7 @@ export default defineConfig({
|
|
|
35
35
|
});
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
更多用法可参考 [Rsbuild - tools.swc](https://v2.rsbuild.
|
|
38
|
+
更多用法可参考 [Rsbuild - tools.swc](https://v2.rsbuild.rs/zh/config/tools/swc)。
|
|
39
39
|
|
|
40
40
|
### 注册 SWC 插件
|
|
41
41
|
|
|
@@ -66,4 +66,4 @@ export default {
|
|
|
66
66
|
|
|
67
67
|
如果你遇到了以上问题,通常可行的解决方法是将 Modern.js 和 SWC 插件都升级到最新版本。
|
|
68
68
|
|
|
69
|
-
详情可参考 [Rsbuild - SWC 插件版本](https://v2.rsbuild.
|
|
69
|
+
详情可参考 [Rsbuild - SWC 插件版本](https://v2.rsbuild.rs/zh/guide/configuration/swc#swc-%E6%8F%92%E4%BB%B6%E7%89%88%E6%9C%AC)。
|
|
@@ -55,7 +55,7 @@ export default {
|
|
|
55
55
|
大多数场景下,推荐优先使用 `.browserslistrc` 文件,而不是使用 `overrideBrowserslist` 配置。因为 `.browserslistrc` 文件是官方定义的配置文件,通用性更强,可以被社区中的其他库识别。
|
|
56
56
|
|
|
57
57
|
:::tip
|
|
58
|
-
请查看 [Rsbuild - 设置浏览器范围](https://v2.rsbuild.
|
|
58
|
+
请查看 [Rsbuild - 设置浏览器范围](https://v2.rsbuild.rs/zh/guide/advanced/browserslist) 来了解更多内容。
|
|
59
59
|
:::
|
|
60
60
|
|
|
61
61
|
import UpgradeBrowserslist from '@site-docs/components/upgrade-browserslist';
|
|
@@ -98,4 +98,4 @@ export default {
|
|
|
98
98
|
|
|
99
99
|
良好的拆包策略对于提升应用的加载性能是十分重要的,可以充分利用浏览器的缓存机制,减少请求数量,加快页面加载速度。
|
|
100
100
|
|
|
101
|
-
在 Modern.js 中内置了[多种拆包策略](https://v2.rsbuild.
|
|
101
|
+
在 Modern.js 中内置了[多种拆包策略](https://v2.rsbuild.rs/zh/guide/optimization/code-splitting),可以满足大部分应用的需求,你也可以根据自己的业务场景,自定义拆包配置。
|
|
@@ -12,20 +12,20 @@ Modern.js 内置了社区流行的 CSS 预处理器,包括 Less 和 Sass。
|
|
|
12
12
|
|
|
13
13
|
默认情况下,你不需要对 Less 和 Sass 进行任何配置。如果你有自定义 loader 配置的需求,可以通过配置 [tools.less](/configure/app/tools/less)、[tools.sass](/configure/app/tools/sass) 来进行设置。
|
|
14
14
|
|
|
15
|
-
你也可以在 Modern.js 中使用 Stylus,只需要安装 Rsbuild 提供的 Stylus 插件即可,使用方式请参考 [Stylus 插件](https://v2.rsbuild.
|
|
15
|
+
你也可以在 Modern.js 中使用 Stylus,只需要安装 Rsbuild 提供的 Stylus 插件即可,使用方式请参考 [Stylus 插件](https://v2.rsbuild.rs/zh/plugins/list/plugin-stylus)。
|
|
16
16
|
|
|
17
17
|
## 使用 PostCSS
|
|
18
18
|
|
|
19
19
|
Modern.js 内置了 [PostCSS](https://postcss.org/) 来转换 CSS 代码。
|
|
20
20
|
|
|
21
|
-
请阅读 [Rsbuild - 使用 PostCSS](https://v2.rsbuild.
|
|
21
|
+
请阅读 [Rsbuild - 使用 PostCSS](https://v2.rsbuild.rs/zh/guide/styling/css-usage) 了解更多用法。
|
|
22
22
|
|
|
23
23
|
## 使用 Lightning CSS
|
|
24
24
|
|
|
25
25
|
Modern.js 支持使用 [Lightning CSS](https://lightningcss.dev/) 来转换 CSS 代码,可以通过配置 [tools.lightningcssLoader](/configure/app/tools/lightningcss-loader) 来开启此功能。
|
|
26
26
|
|
|
27
|
-
请阅读 [Rsbuild - 使用 Lightning CSS](https://v2.rsbuild.
|
|
27
|
+
请阅读 [Rsbuild - 使用 Lightning CSS](https://v2.rsbuild.rs/zh/guide/styling/css-usage#lightning-css) 了解更多用法。
|
|
28
28
|
|
|
29
29
|
## 使用 Uno CSS
|
|
30
30
|
|
|
31
|
-
请阅读 [Rsbuild - 使用 UnoCSS](https://v2.rsbuild.
|
|
31
|
+
请阅读 [Rsbuild - 使用 UnoCSS](https://v2.rsbuild.rs/zh/guide/styling/unocss) 了解更多用法。
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
在 Modern.js 中使用 [Tailwind CSS](https://tailwindcss.com/),你只需要按照 Rsbuild 操作步骤进行配置,Rsbuild 支持 Tailwind CSS v3 和 v4 版本:
|
|
8
8
|
|
|
9
|
-
- [Tailwind CSS v3](https://v2.rsbuild.
|
|
10
|
-
- [Tailwind CSS v4](https://v2.rsbuild.
|
|
9
|
+
- [Tailwind CSS v3](https://v2.rsbuild.rs/zh/guide/styling/tailwindcss-v3#tailwind-css-v3)
|
|
10
|
+
- [Tailwind CSS v4](https://v2.rsbuild.rs/zh/guide/styling/tailwindcss)
|
|
11
11
|
|
|
12
12
|
## Tailwind CSS 自动补全
|
|
13
13
|
|
|
@@ -4,7 +4,7 @@ sidebar_position: 2
|
|
|
4
4
|
|
|
5
5
|
# 构建工具
|
|
6
6
|
|
|
7
|
-
Modern.js 构建是基于 [Rsbuild](https://v2.rsbuild.
|
|
7
|
+
Modern.js 构建是基于 [Rsbuild](https://v2.rsbuild.rs/) 实现的,使用 Rspack 作为打包工具。
|
|
8
8
|
|
|
9
9
|
:::tip 什么是 Rsbuild
|
|
10
10
|
Rsbuild 是基于 Rspack 的构建工具,是一个增强版的 Rspack CLI,更易用、开箱即用。
|
|
@@ -40,7 +40,7 @@ flowchart TD
|
|
|
40
40
|
|
|
41
41
|
## 构建文档
|
|
42
42
|
|
|
43
|
-
Rsbuild 的文档地址为:https://v2.rsbuild.
|
|
43
|
+
Rsbuild 的文档地址为:https://v2.rsbuild.rs/
|
|
44
44
|
|
|
45
45
|
在该文档中,你可以了解到 Rsbuild 的详细介绍,同时也可以找到各个构建能力的完整使用指南。
|
|
46
46
|
|
|
@@ -57,4 +57,4 @@ Rsbuild 的文档地址为:https://v2.rsbuild.dev/
|
|
|
57
57
|
|
|
58
58
|
Rsbuild 提供了丰富的构建能力,包括 JavaScript 编译、CSS 编译、静态资源处理、代码热更新、代码压缩、TS 类型检查等几十种能力。
|
|
59
59
|
|
|
60
|
-
我们推荐你阅读 [「Rsbuild - 功能导航」](https://v2.rsbuild.
|
|
60
|
+
我们推荐你阅读 [「Rsbuild - 功能导航」](https://v2.rsbuild.rs/zh/guide/start/features) 来了解 Rsbuild 提供的所有构建能力。
|
|
@@ -12,7 +12,7 @@ Modern.js 框架默认集成了一些社区中流行的库和开发工具。
|
|
|
12
12
|
|
|
13
13
|
Modern.js 使用 [React 19](https://react.dev/) 来构建用户界面,同时也兼容 React 18。
|
|
14
14
|
|
|
15
|
-
Modern.js 底层的 Rsbuild 支持构建 Vue 应用,如果你需要使用 Vue,可以参考 [Rsbuild - Vue](https://v2.rsbuild.
|
|
15
|
+
Modern.js 底层的 Rsbuild 支持构建 Vue 应用,如果你需要使用 Vue,可以参考 [Rsbuild - Vue](https://v2.rsbuild.rs/zh/guide/framework/vue)。
|
|
16
16
|
|
|
17
17
|
## 路由
|
|
18
18
|
|
|
@@ -34,7 +34,7 @@ Modern.js 使用 [Rspack](https://rspack.rs/) 来打包你的 Web 应用。
|
|
|
34
34
|
|
|
35
35
|
Modern.js 使用 [SWC](https://swc.rs/) 作为 JS 转译工具,将 TypeScript 或 JSX 转义为可以在浏览器上运行的 JavaScript 代码,并进行语法降级。
|
|
36
36
|
|
|
37
|
-
在启用 Rspack 构建时,`babel-loader` 默认不会被启用。如需添加 [Babel](https://babeljs.io/) 插件,可通过 [`babel plugin`](https://v2.rsbuild.
|
|
37
|
+
在启用 Rspack 构建时,`babel-loader` 默认不会被启用。如需添加 [Babel](https://babeljs.io/) 插件,可通过 [`babel plugin`](https://v2.rsbuild.rs/plugins/list/plugin-babel#babel-plugin) 配置,此时会产生额外的编译开销,在一定程度上拖慢 Rspack 构建速度。
|
|
38
38
|
|
|
39
39
|
## 压缩工具
|
|
40
40
|
|
|
@@ -53,7 +53,7 @@ Modern.js 支持 [启用 Tailwind CSS](/guides/basic-features/css/tailwindcss)
|
|
|
53
53
|
Modern.js 支持 [Sass](https://sass-lang.com/)、[Less](https://lesscss.org/) 和 [Stylus](https://stylus-lang.com/) 三种 CSS 预处理器:
|
|
54
54
|
|
|
55
55
|
- 默认支持 Sass 和 Less,开箱即用。
|
|
56
|
-
- 可选支持 Stylus,请参考 [Stylus 插件](https://v2.rsbuild.
|
|
56
|
+
- 可选支持 Stylus,请参考 [Stylus 插件](https://v2.rsbuild.rs/zh/plugins/list/plugin-stylus) 来使用。
|
|
57
57
|
|
|
58
58
|
## CSS Modules
|
|
59
59
|
|
|
@@ -10,11 +10,11 @@ sidebar_position: 3
|
|
|
10
10
|
|
|
11
11
|
### Rsbuild FAQ
|
|
12
12
|
|
|
13
|
-
Modern.js 内部基于 [Rsbuild](https://v2.rsbuild.
|
|
13
|
+
Modern.js 内部基于 [Rsbuild](https://v2.rsbuild.rs/) 封装了自身的构建工具,因此你可以直接参考 Rsbuild 的 FAQ 文档:
|
|
14
14
|
|
|
15
|
-
- [Rsbuild - 功能类问题](https://v2.rsbuild.
|
|
16
|
-
- [Rsbuild - 异常类问题](https://v2.rsbuild.
|
|
17
|
-
- [Rsbuild - 热更新问题](https://v2.rsbuild.
|
|
15
|
+
- [Rsbuild - 功能类问题](https://v2.rsbuild.rs/zh/guide/faq/features)
|
|
16
|
+
- [Rsbuild - 异常类问题](https://v2.rsbuild.rs/zh/guide/faq/exceptions)
|
|
17
|
+
- [Rsbuild - 热更新问题](https://v2.rsbuild.rs/zh/guide/faq/hmr)
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
@@ -184,7 +184,7 @@ export default {
|
|
|
184
184
|
**变更内容**:该配置已废弃,需要手动切换到 esbuild 压缩。
|
|
185
185
|
|
|
186
186
|
```typescript
|
|
187
|
-
// 该配置已废弃,请参考 [切换压缩器](https://v2.rsbuild.
|
|
187
|
+
// 该配置已废弃,请参考 [切换压缩器](https://v2.rsbuild.rs/zh/config/output/minify#%E5%88%87%E6%8D%A2%E5%8E%8B%E7%BC%A9%E5%99%A8) 来手动切换到 esbuild 压缩
|
|
188
188
|
// tools: {
|
|
189
189
|
// esbuild: { /* 配置 */ }
|
|
190
190
|
// },
|
|
@@ -195,7 +195,7 @@ export default {
|
|
|
195
195
|
**变更内容**:该配置已废弃,需要手动切换到 Terser 压缩。
|
|
196
196
|
|
|
197
197
|
```typescript
|
|
198
|
-
// 该配置已废弃,请参考 [切换压缩器](https://v2.rsbuild.
|
|
198
|
+
// 该配置已废弃,请参考 [切换压缩器](https://v2.rsbuild.rs/zh/config/output/minify#%E5%88%87%E6%8D%A2%E5%8E%8B%E7%BC%A9%E5%99%A8) 来手动切换到 Terser 压缩
|
|
199
199
|
// tools: {
|
|
200
200
|
// terser: { /* 配置 */ }
|
|
201
201
|
// },
|
|
@@ -921,7 +921,7 @@ export default defineRuntimeConfig({
|
|
|
921
921
|
|
|
922
922
|
### performance.bundleAnalyze
|
|
923
923
|
|
|
924
|
-
**变更内容**:该配置已废弃,建议使用 [Rsdoctor](https://v2.rsbuild.
|
|
924
|
+
**变更内容**:该配置已废弃,建议使用 [Rsdoctor](https://v2.rsbuild.rs/zh/guide/debug/rsdoctor) 来分析产物体积
|
|
925
925
|
|
|
926
926
|
### performance.transformLodash
|
|
927
927
|
|
|
@@ -121,6 +121,56 @@ Modern.js 3.0 移除了 `modern new` 和 `modern upgrade` 命令,需要按照
|
|
|
121
121
|
移除这些命令的目的是让文档更贴合 AI Agent 的默认实现方式,不把操作做封装,使开发者能够更清晰地了解每个操作的具体步骤,也便于 AI Agent 根据文档直接执行相应的操作。
|
|
122
122
|
:::
|
|
123
123
|
|
|
124
|
+
## 不再内置 Arco/Antd 支持
|
|
125
|
+
|
|
126
|
+
Modern.js 2.0 内置了对 [Arco Design](https://arco.design/) 和 [Ant Design](https://ant.design/) 的按需引入支持,3.0 版本不再内置该能力,需要用户自行配置 `source.transformImport`。
|
|
127
|
+
|
|
128
|
+
如果项目中使用了 Arco Design 或 Ant Design,请手动添加对应的 `source.transformImport` 配置。
|
|
129
|
+
|
|
130
|
+
**Arco Design 迁移示例**:
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
export default {
|
|
134
|
+
source: {
|
|
135
|
+
transformImport: [
|
|
136
|
+
{
|
|
137
|
+
libraryName: '@arco-design/web-react',
|
|
138
|
+
libraryDirectory: 'es',
|
|
139
|
+
camelToDashComponentName: false,
|
|
140
|
+
style: 'css',
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
libraryName: '@arco-design/web-react/icon',
|
|
144
|
+
libraryDirectory: 'react-icon',
|
|
145
|
+
camelToDashComponentName: false,
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Ant Design 迁移示例**(antd v4 及以下版本):
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
export default {
|
|
156
|
+
source: {
|
|
157
|
+
transformImport: [
|
|
158
|
+
{
|
|
159
|
+
libraryName: 'antd',
|
|
160
|
+
libraryDirectory: 'es',
|
|
161
|
+
style: 'css',
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
:::tip
|
|
169
|
+
antd v5 使用了 CSS-in-JS 方案,已原生支持按需加载,无需配置 `source.transformImport`。
|
|
170
|
+
|
|
171
|
+
更多用法请参考 [Rsbuild - source.transformImport](https://v2.rsbuild.rs/config/source/transform-import)。
|
|
172
|
+
:::
|
|
173
|
+
|
|
124
174
|
## Eslint 规则集
|
|
125
175
|
|
|
126
176
|
Modern.js 之前提供了 ESLint 的完整规则集,涵盖了 @modern-js(针对 Node.js 项目的 Lint 规则)和 @modern-js-app(针对前端项目的 Lint 规则)。在 [v2.60.0](https://github.com/web-infra-dev/modern.js/releases/tag/v2.60.0) 版本中,我们正式移除了这些规则集。我们鼓励开发者根据自身需求选择合适的代码规范工具,直接使用 ESLint 并结合社区推荐的规则,或使用 Biome 以提升代码格式化的性能。
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Modern.js 3.0 带来了多项重大改进和变化,主要包括:
|
|
8
8
|
|
|
9
|
-
- **构建工具升级**:默认使用 [Rspack](https://rspack.dev) 构建,不再支持 Webpack,构建配置与 [Rsbuild](https://rsbuild.
|
|
9
|
+
- **构建工具升级**:默认使用 [Rspack](https://rspack.dev) 构建,不再支持 Webpack,构建配置与 [Rsbuild](https://v2.rsbuild.rs) 对齐。
|
|
10
10
|
- **React 生态升级**:全面支持 [React 19](https://react.dev/blog/2024/04/25/react-19) 和 [React Router v7](https://reactrouter.com)。
|
|
11
11
|
- **插件系统重构**:重新设计插件 API,支持在 CLI、Runtime、Server 层通过自定义插件扩展框架能力。
|
|
12
12
|
- **React Server Component**:支持在 [CSR](/guides/get-started/glossary#csr) 和 [SSR](/guides/basic-features/render/ssr) 项目中使用 React Server Component。
|
|
@@ -188,7 +188,7 @@ api.config(() => {
|
|
|
188
188
|
- **参数:**
|
|
189
189
|
- `modifyFn`: 修改函数,接收 `RspackChain` 实例和实用工具作为参数。
|
|
190
190
|
- **执行阶段:** 在生成最终的 Rspack 配置时。
|
|
191
|
-
- **对应 Rsbuild Hook**: [modifybundlerchain](https://v2.rsbuild.
|
|
191
|
+
- **对应 Rsbuild Hook**: [modifybundlerchain](https://v2.rsbuild.rs/zh/plugins/dev/hooks#modifybundlerchain)
|
|
192
192
|
- **示例:**
|
|
193
193
|
|
|
194
194
|
```typescript
|
|
@@ -208,7 +208,7 @@ api.modifyBundlerChain((chain, utils) => {
|
|
|
208
208
|
- **参数:**
|
|
209
209
|
- `modifyFn`: 修改函数,接收 Rsbuild 配置对象和实用工具作为参数,可以返回修改后的配置对象、Promise 或不返回(直接修改原对象)。
|
|
210
210
|
- **执行阶段:** 在生成最终的 Rsbuild 配置时。
|
|
211
|
-
- **对应 Rsbuild Hook**: [modifyRsbuildConfig](https://v2.rsbuild.
|
|
211
|
+
- **对应 Rsbuild Hook**: [modifyRsbuildConfig](https://v2.rsbuild.rs/zh/plugins/dev/hooks#modifyrsbuildconfig)
|
|
212
212
|
- **示例:**
|
|
213
213
|
|
|
214
214
|
```typescript
|
|
@@ -228,7 +228,7 @@ api.modifyRsbuildConfig((config, utils) => {
|
|
|
228
228
|
- **参数:**
|
|
229
229
|
- `modifyFn`: 修改函数,接收 Rspack 配置对象和实用工具作为参数,可以返回修改后的配置对象、Promise 或不返回(直接修改原对象)。
|
|
230
230
|
- **执行阶段:** 在生成最终的 Rspack 配置时。
|
|
231
|
-
- **对应 Rsbuild Hook**: [modifyRspackConfig](https://v2.rsbuild.
|
|
231
|
+
- **对应 Rsbuild Hook**: [modifyRspackConfig](https://v2.rsbuild.rs/zh/plugins/dev/hooks#modifyrspackconfig)
|
|
232
232
|
- **示例:**
|
|
233
233
|
|
|
234
234
|
```typescript
|
|
@@ -403,7 +403,7 @@ api.onFileChanged(({ filename, eventType }) => {
|
|
|
403
403
|
- **参数:**
|
|
404
404
|
- `buildFn`: 构建前执行的函数,无参数,可异步。
|
|
405
405
|
- **执行阶段:** 在执行构建流程之前。
|
|
406
|
-
- **对应 Rsbuild Hook**: [onBeforeBuild](https://v2.rsbuild.
|
|
406
|
+
- **对应 Rsbuild Hook**: [onBeforeBuild](https://v2.rsbuild.rs/zh/plugins/dev/hooks#onbeforebuild)
|
|
407
407
|
- **示例:**
|
|
408
408
|
|
|
409
409
|
```typescript
|
|
@@ -422,7 +422,7 @@ api.onBeforeBuild(() => {
|
|
|
422
422
|
- **参数:**
|
|
423
423
|
- `buildFn`: 构建后执行的函数,无参数,可异步。
|
|
424
424
|
- **执行阶段:** 在执行构建流程之后。
|
|
425
|
-
- **对应 Rsbuild Hook**: [onAfterBuild](https://v2.rsbuild.
|
|
425
|
+
- **对应 Rsbuild Hook**: [onAfterBuild](https://v2.rsbuild.rs/zh/plugins/dev/hooks#onafterbuild)
|
|
426
426
|
- **示例:**
|
|
427
427
|
|
|
428
428
|
```typescript
|
|
@@ -441,7 +441,7 @@ api.onAfterBuild(() => {
|
|
|
441
441
|
- **参数:**
|
|
442
442
|
- `compileFn`: 编译完成后执行的函数。
|
|
443
443
|
- **执行阶段:** 开发服务器启动,且首次编译完成后。
|
|
444
|
-
- **对应 Rsbuild Hook**: [onDevCompileDone](https://v2.rsbuild.
|
|
444
|
+
- **对应 Rsbuild Hook**: [onDevCompileDone](https://v2.rsbuild.rs/zh/plugins/dev/hooks#ondevcompiledone)
|
|
445
445
|
- **示例:**
|
|
446
446
|
|
|
447
447
|
```typescript
|
|
@@ -460,7 +460,7 @@ api.onDevCompileDone(() => {
|
|
|
460
460
|
- **参数:**
|
|
461
461
|
- `createFn`: 创建前执行的函数,无参数,可异步。
|
|
462
462
|
- **执行阶段:** 在创建 Rspack 编译器实例之前。
|
|
463
|
-
- **对应 Rsbuild Hook**: [onBeforeCreateCompiler](https://v2.rsbuild.
|
|
463
|
+
- **对应 Rsbuild Hook**: [onBeforeCreateCompiler](https://v2.rsbuild.rs/zh/plugins/dev/hooks#onbeforecreatecompiler)
|
|
464
464
|
- **示例:**
|
|
465
465
|
|
|
466
466
|
```typescript
|
|
@@ -479,7 +479,7 @@ api.onBeforeCreateCompiler(() => {
|
|
|
479
479
|
- **参数:**
|
|
480
480
|
- `createFn`: 创建后执行的函数,无参数,可异步。
|
|
481
481
|
- **执行阶段:** 在创建 Rspack 编译器实例之后。
|
|
482
|
-
- **对应 Rsbuild Hook**: [onAfterCreateCompiler](https://v2.rsbuild.
|
|
482
|
+
- **对应 Rsbuild Hook**: [onAfterCreateCompiler](https://v2.rsbuild.rs/zh/plugins/dev/hooks#onaftercreatecompiler)
|
|
483
483
|
- **示例:**
|
|
484
484
|
|
|
485
485
|
```typescript
|
|
@@ -517,7 +517,7 @@ api.onBeforeDev(async () => {
|
|
|
517
517
|
- **参数:**
|
|
518
518
|
- `devFn`: 开发服务器启动后执行的函数。
|
|
519
519
|
- **执行阶段:** 开发服务器成功启动后。
|
|
520
|
-
- **对应 Rsbuild Hook**: [onAfterStartDevServer](https://v2.rsbuild.
|
|
520
|
+
- **对应 Rsbuild Hook**: [onAfterStartDevServer](https://v2.rsbuild.rs/zh/plugins/dev/hooks#onafterstartdevserver)
|
|
521
521
|
- **示例:**
|
|
522
522
|
|
|
523
523
|
```typescript
|
|
@@ -117,7 +117,7 @@ Rsbuild 是 Modern.js 底层的构建工具,通过添加 Rsbuild 插件可修
|
|
|
117
117
|
你可以在 `modern.config.ts` 中通过 `builderPlugins` 选项注册 Rsbuild 插件,详见 [builderPlugins 构建插件](/configure/app/builder-plugins.html)。
|
|
118
118
|
|
|
119
119
|
:::info
|
|
120
|
-
可以阅读 [Rsbuild 官网 - 插件](https://v2.rsbuild.
|
|
120
|
+
可以阅读 [Rsbuild 官网 - 插件](https://v2.rsbuild.rs/plugins/list/index) 了解更多 Rsbuild 插件体系内容。
|
|
121
121
|
:::
|
|
122
122
|
|
|
123
123
|
### 官方插件
|
|
@@ -128,8 +128,8 @@ Rsbuild 是 Modern.js 底层的构建工具,通过添加 Rsbuild 插件可修
|
|
|
128
128
|
|
|
129
129
|
| 插件 | 介绍 | Modern.js 链接 |
|
|
130
130
|
| ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
131
|
-
| [React 插件](https://v2.rsbuild.
|
|
132
|
-
| [SVGR 插件](https://v2.rsbuild.
|
|
131
|
+
| [React 插件](https://v2.rsbuild.rs/zh/plugins/list/plugin-react) | 提供对 React 的支持 | - |
|
|
132
|
+
| [SVGR 插件](https://v2.rsbuild.rs/zh/plugins/list/plugin-svgr) | 支持将 SVG 图片转换为一个 React 组件 | [output.disableSvgr](/configure/app/output/disable-svgr)<br />[output.svgDefaultExport](/configure/app/output/svg-default-export) |
|
|
133
133
|
| [Assets Retry 插件](https://github.com/rstackjs/rsbuild-plugin-assets-retry) | 用于在静态资源加载失败时自动发起重试请求 | [output.assetsRetry](/configure/app/output/assets-retry.html) |
|
|
134
134
|
| [Type Check 插件](https://github.com/rspack-contrib/rsbuild-plugin-type-check) | 用于在单独的进程中运行 TypeScript 类型检查 | [output.disableTsChecker](/configure/app/output/disable-ts-checker.html)<br />[tools.tsChecker](/configure/app/tools/ts-checker.html) |
|
|
135
135
|
| [Source Build 插件](https://github.com/rspack-contrib/rsbuild-plugin-source-build) | 用于 monorepo 场景,支持引用其他子目录的源代码,并完成构建和热更新 | [experiments.sourceBuild](/configure/app/experiments/source-build.html) |
|
|
@@ -142,7 +142,7 @@ Rsbuild 是 Modern.js 底层的构建工具,通过添加 Rsbuild 插件可修
|
|
|
142
142
|
以下是未在 Modern.js 中内置的 Rsbuild 官方插件:
|
|
143
143
|
|
|
144
144
|
- [Image Compress 插件](https://github.com/rspack-contrib/rsbuild-plugin-image-compress):将项目中用到的图片资源进行压缩处理。
|
|
145
|
-
- [Stylus 插件](https://v2.rsbuild.
|
|
145
|
+
- [Stylus 插件](https://v2.rsbuild.rs/zh/plugins/list/plugin-stylus):使用 Stylus 作为 CSS 预处理器。
|
|
146
146
|
- [UMD 插件](https://github.com/rspack-contrib/rsbuild-plugin-umd):用于构建 UMD 格式的产物。
|
|
147
147
|
- [YAML 插件](https://github.com/rspack-contrib/rsbuild-plugin-yaml):用于引用 YAML 文件,并将其转换为 JavaScript 对象。
|
|
148
148
|
- [TOML 插件](https://github.com/rspack-contrib/rsbuild-plugin-toml):用于引用 TOML 文件,并将其转换为 JavaScript 对象。
|
package/package.json
CHANGED
|
@@ -16,21 +16,21 @@
|
|
|
16
16
|
"modern",
|
|
17
17
|
"modern.js"
|
|
18
18
|
],
|
|
19
|
-
"version": "3.0.
|
|
19
|
+
"version": "3.0.3",
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"registry": "https://registry.npmjs.org/",
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"mermaid": "^11.12.2",
|
|
26
|
-
"@modern-js/sandpack-react": "3.0.
|
|
26
|
+
"@modern-js/sandpack-react": "3.0.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@rsbuild/plugin-sass": "1.5.0",
|
|
30
30
|
"@rspress/core": "2.0.2",
|
|
31
31
|
"@rspress/plugin-llms": "2.0.2",
|
|
32
32
|
"@rspress/shared": "2.0.2",
|
|
33
|
-
"@shikijs/transformers": "^3.
|
|
33
|
+
"@shikijs/transformers": "^3.22.0",
|
|
34
34
|
"@types/fs-extra": "9.0.13",
|
|
35
35
|
"@types/node": "^20",
|
|
36
36
|
"classnames": "^2.5.1",
|
package/src/i18n/enUS.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const EN_US = {
|
|
2
|
+
// Announcement
|
|
3
|
+
announcementLabel: 'NEW',
|
|
4
|
+
announcementText: 'Modern.js 3.0 is released!',
|
|
5
|
+
|
|
2
6
|
introduction: 'Introduction',
|
|
3
7
|
quickStart: 'Quick Start',
|
|
4
8
|
|
|
@@ -16,7 +20,7 @@ export const EN_US = {
|
|
|
16
20
|
feature3: 'Nested Routes',
|
|
17
21
|
featureDesc3: 'File-as-route, comes with lots performance optimizations.',
|
|
18
22
|
feature4: 'Multi-Rendering Mode',
|
|
19
|
-
featureDesc4: 'SSR, SSG,
|
|
23
|
+
featureDesc4: 'RSC, SSR, SSG, all out of the box for you.',
|
|
20
24
|
feature5: 'CSS Solutions',
|
|
21
25
|
featureDesc5: 'CSS Modules, CSS-in-JS, Tailwind CSS, take your pick.',
|
|
22
26
|
feature6: 'Easy to Configure',
|
package/src/i18n/zhCN.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { EN_US } from './enUS';
|
|
2
2
|
|
|
3
3
|
export const ZH_CN: Record<keyof typeof EN_US, string> = {
|
|
4
|
+
// Announcement
|
|
5
|
+
announcementLabel: 'NEW',
|
|
6
|
+
announcementText: 'Modern.js 3.0 正式发布!',
|
|
7
|
+
|
|
4
8
|
introduction: '介绍',
|
|
5
9
|
quickStart: '快速上手',
|
|
6
10
|
|
|
@@ -17,7 +21,7 @@ export const ZH_CN: Record<keyof typeof EN_US, string> = {
|
|
|
17
21
|
feature3: '嵌套路由',
|
|
18
22
|
featureDesc3: '文件系统即路由,附赠全套性能优化。',
|
|
19
23
|
feature4: '多渲染模式',
|
|
20
|
-
featureDesc4: 'SSR、SSG
|
|
24
|
+
featureDesc4: 'RSC、SSR、SSG 等多种渲染模式,通通开箱即用。',
|
|
21
25
|
feature5: 'CSS 方案',
|
|
22
26
|
featureDesc5: 'CSS Modules、CSS-in-JS、Tailwind CSS,任你挑选。',
|
|
23
27
|
feature6: '易于配置',
|
|
@@ -26,6 +26,91 @@
|
|
|
26
26
|
padding-bottom: 16vh;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
.announcement {
|
|
30
|
+
display: inline-flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
gap: 10px;
|
|
33
|
+
padding: 6px 18px 6px 6px;
|
|
34
|
+
border-radius: 999px;
|
|
35
|
+
background: linear-gradient(
|
|
36
|
+
150.85deg,
|
|
37
|
+
rgba(124, 178, 250, 0.15) 3%,
|
|
38
|
+
rgba(124, 178, 250, 0.08) 97.17%
|
|
39
|
+
);
|
|
40
|
+
border: 1px solid rgba(124, 178, 250, 0.4);
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
transition: all 0.3s ease;
|
|
43
|
+
text-decoration: none;
|
|
44
|
+
margin-bottom: 1.5rem;
|
|
45
|
+
position: relative;
|
|
46
|
+
z-index: 1;
|
|
47
|
+
|
|
48
|
+
&:hover {
|
|
49
|
+
background: linear-gradient(
|
|
50
|
+
150.85deg,
|
|
51
|
+
rgba(124, 178, 250, 0.25) 3%,
|
|
52
|
+
rgba(124, 178, 250, 0.15) 97.17%
|
|
53
|
+
);
|
|
54
|
+
border-color: rgba(124, 178, 250, 0.55);
|
|
55
|
+
text-decoration: none;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
:global(.dark) .announcement {
|
|
60
|
+
background: linear-gradient(
|
|
61
|
+
150.85deg,
|
|
62
|
+
rgba(124, 178, 250, 0.18) 3%,
|
|
63
|
+
rgba(124, 178, 250, 0.08) 97.17%
|
|
64
|
+
);
|
|
65
|
+
border-color: rgba(124, 178, 250, 0.25);
|
|
66
|
+
|
|
67
|
+
&:hover {
|
|
68
|
+
background: linear-gradient(
|
|
69
|
+
150.85deg,
|
|
70
|
+
rgba(124, 178, 250, 0.28) 3%,
|
|
71
|
+
rgba(124, 178, 250, 0.14) 97.17%
|
|
72
|
+
);
|
|
73
|
+
border-color: rgba(124, 178, 250, 0.4);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.announcementLabel {
|
|
78
|
+
display: inline-flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
padding: 2px 10px;
|
|
81
|
+
border-radius: 999px;
|
|
82
|
+
background: var(--edenx-home-hero-name-background);
|
|
83
|
+
font-size: 12px;
|
|
84
|
+
font-weight: 700;
|
|
85
|
+
color: #fff;
|
|
86
|
+
letter-spacing: 0.5px;
|
|
87
|
+
line-height: 1.6;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.announcementText {
|
|
91
|
+
font-size: 14px;
|
|
92
|
+
font-weight: 500;
|
|
93
|
+
color: rgba(0, 0, 0, 0.75);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
:global(.dark) .announcementText {
|
|
97
|
+
color: rgba(255, 255, 255, 0.85);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.announcementArrow {
|
|
101
|
+
font-size: 14px;
|
|
102
|
+
color: rgba(0, 0, 0, 0.45);
|
|
103
|
+
transition: transform 0.3s ease;
|
|
104
|
+
|
|
105
|
+
.announcement:hover & {
|
|
106
|
+
transform: translateX(2px);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
:global(.dark) .announcementArrow {
|
|
111
|
+
color: rgba(255, 255, 255, 0.5);
|
|
112
|
+
}
|
|
113
|
+
|
|
29
114
|
.title {
|
|
30
115
|
font-style: normal;
|
|
31
116
|
font-weight: bold;
|
|
@@ -149,6 +234,14 @@
|
|
|
149
234
|
font-size: 7vw;
|
|
150
235
|
text-align: center;
|
|
151
236
|
}
|
|
237
|
+
.announcement {
|
|
238
|
+
padding: 4px 14px 4px 4px;
|
|
239
|
+
gap: 8px;
|
|
240
|
+
margin-bottom: 1rem;
|
|
241
|
+
}
|
|
242
|
+
.announcementText {
|
|
243
|
+
font-size: 12px;
|
|
244
|
+
}
|
|
152
245
|
.buttons {
|
|
153
246
|
width: 65%;
|
|
154
247
|
justify-content: center;
|
package/src/pages/index.tsx
CHANGED
|
@@ -14,6 +14,18 @@ const HomepageHeader = () => {
|
|
|
14
14
|
<div className={styles.header}>
|
|
15
15
|
<header className={clsx('hero hero--primary', styles.heroBanner)}>
|
|
16
16
|
<div className={styles.mask} />
|
|
17
|
+
<a
|
|
18
|
+
href={useUrl('/community/blog/v3-release-note')}
|
|
19
|
+
className={styles.announcement}
|
|
20
|
+
>
|
|
21
|
+
<span className={styles.announcementLabel}>
|
|
22
|
+
{t('announcementLabel')}
|
|
23
|
+
</span>
|
|
24
|
+
<span className={styles.announcementText}>
|
|
25
|
+
{t('announcementText')}
|
|
26
|
+
</span>
|
|
27
|
+
<span className={styles.announcementArrow}>→</span>
|
|
28
|
+
</a>
|
|
17
29
|
<h1 className={styles.title}>
|
|
18
30
|
<span className={clsx([styles.titleGradient, styles.mainTitle])}>
|
|
19
31
|
Modern.js 3.0
|