@modern-js/main-doc 3.0.1 → 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/_nav.json +1 -1
- package/docs/en/apis/app/commands.mdx +1 -1
- package/docs/en/community/blog/_meta.json +7 -1
- package/docs/en/community/blog/v3-release-note.mdx +628 -0
- 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 +5 -5
- 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/server/rsc.mdx +2 -2
- 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/basic-features/render/rsc.mdx +137 -8
- package/docs/en/guides/concept/builder.mdx +3 -3
- package/docs/en/guides/get-started/tech-stack.mdx +3 -3
- package/docs/en/guides/topic-detail/module-federation/application.mdx +6 -6
- package/docs/en/guides/topic-detail/module-federation/deploy.mdx +2 -2
- package/docs/en/guides/topic-detail/module-federation/i18n.mdx +12 -12
- package/docs/en/guides/topic-detail/module-federation/introduce.mdx +1 -1
- package/docs/en/guides/topic-detail/module-federation/ssr.mdx +4 -4
- package/docs/en/guides/topic-detail/module-federation/usage.mdx +7 -7
- package/docs/en/guides/troubleshooting/builder.mdx +4 -4
- package/docs/en/guides/upgrade/config.mdx +31 -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 +5 -5
- package/docs/zh/_nav.json +1 -1
- package/docs/zh/apis/app/commands.mdx +1 -1
- package/docs/zh/community/blog/_meta.json +7 -1
- package/docs/zh/community/blog/v3-release-note.mdx +628 -0
- 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 +5 -5
- 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/server/rsc.mdx +2 -2
- 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/basic-features/render/rsc.mdx +222 -8
- package/docs/zh/guides/concept/builder.mdx +3 -3
- package/docs/zh/guides/get-started/tech-stack.mdx +3 -3
- package/docs/zh/guides/topic-detail/module-federation/application.mdx +6 -6
- package/docs/zh/guides/topic-detail/module-federation/deploy.mdx +2 -2
- package/docs/zh/guides/topic-detail/module-federation/i18n.mdx +12 -12
- package/docs/zh/guides/topic-detail/module-federation/introduce.mdx +1 -1
- package/docs/zh/guides/topic-detail/module-federation/ssr.mdx +4 -4
- package/docs/zh/guides/topic-detail/module-federation/usage.mdx +7 -7
- package/docs/zh/guides/troubleshooting/builder.mdx +4 -4
- package/docs/zh/guides/upgrade/config.mdx +31 -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 +5 -5
- package/package.json +3 -3
- package/src/components/RsbuildLink/index.tsx +1 -1
- 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 +13 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 开始使用
|
|
2
2
|
|
|
3
|
-
在 Modern.js 中使用 Module Federation 我们推荐使用官方插件 `@module-federation/modern-js`。
|
|
3
|
+
在 Modern.js 中使用 Module Federation 我们推荐使用官方插件 `@module-federation/modern-js-v3`。
|
|
4
4
|
|
|
5
5
|
本章节将会介绍如何通过官方插件搭含生产者应用与消费者应用,我们首先根据 [Modern.js 快速上手](/guides/get-started/quick-start) 创建两个应用。
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import { PackageManagerTabs } from '@theme';
|
|
12
12
|
|
|
13
|
-
<PackageManagerTabs command="add @module-federation/modern-js" />
|
|
13
|
+
<PackageManagerTabs command="add @module-federation/modern-js-v3" />
|
|
14
14
|
|
|
15
15
|
## 注册插件
|
|
16
16
|
|
|
@@ -18,7 +18,7 @@ import { PackageManagerTabs } from '@theme';
|
|
|
18
18
|
|
|
19
19
|
```ts
|
|
20
20
|
import { appTools, defineConfig } from '@modern-js/app-tools';
|
|
21
|
-
import { moduleFederationPlugin } from '@module-federation/modern-js';
|
|
21
|
+
import { moduleFederationPlugin } from '@module-federation/modern-js-v3';
|
|
22
22
|
|
|
23
23
|
export default defineConfig({
|
|
24
24
|
plugins: [appTools(), moduleFederationPlugin()],
|
|
@@ -42,7 +42,7 @@ export const Button = () => {
|
|
|
42
42
|
随后,在项目根目录添加 `module-federation.config.ts`,配置 Module Federation 模块的名称、共享依赖和导出内容:
|
|
43
43
|
|
|
44
44
|
```ts title="module-federation.config.ts"
|
|
45
|
-
import { createModuleFederationConfig } from '@module-federation/modern-js';
|
|
45
|
+
import { createModuleFederationConfig } from '@module-federation/modern-js-v3';
|
|
46
46
|
|
|
47
47
|
export default createModuleFederationConfig({
|
|
48
48
|
name: 'remote',
|
|
@@ -68,7 +68,7 @@ export default createModuleFederationConfig({
|
|
|
68
68
|
|
|
69
69
|
```ts title="modern.config.ts"
|
|
70
70
|
import { appTools, defineConfig } from '@modern-js/app-tools';
|
|
71
|
-
import { moduleFederationPlugin } from '@module-federation/modern-js';
|
|
71
|
+
import { moduleFederationPlugin } from '@module-federation/modern-js-v3';
|
|
72
72
|
|
|
73
73
|
export default defineConfig({
|
|
74
74
|
server: {
|
|
@@ -85,7 +85,7 @@ export default defineConfig({
|
|
|
85
85
|
在项目根目录添加 `module-federation.config.ts`,配置 Module Federation 模块的名称、共享依赖和使用的远程模块:
|
|
86
86
|
|
|
87
87
|
```ts title="module-federation.config.ts"
|
|
88
|
-
import { createModuleFederationConfig } from '@module-federation/modern-js';
|
|
88
|
+
import { createModuleFederationConfig } from '@module-federation/modern-js-v3';
|
|
89
89
|
|
|
90
90
|
export default createModuleFederationConfig({
|
|
91
91
|
name: 'host',
|
|
@@ -170,7 +170,7 @@ export default Index;
|
|
|
170
170
|
|
|
171
171
|
```ts
|
|
172
172
|
import { appTools, defineConfig } from '@modern-js/app-tools';
|
|
173
|
-
import { moduleFederationPlugin } from '@module-federation/modern-js';
|
|
173
|
+
import { moduleFederationPlugin } from '@module-federation/modern-js-v3';
|
|
174
174
|
|
|
175
175
|
// https://modernjs.dev/en/configure/app/usage
|
|
176
176
|
export default defineConfig({
|
|
@@ -10,11 +10,11 @@ sidebar_position: 3
|
|
|
10
10
|
|
|
11
11
|
### Rsbuild FAQ
|
|
12
12
|
|
|
13
|
-
Modern.js 内部基于 [Rsbuild](https://rsbuild.rs/) 封装了自身的构建工具,因此你可以直接参考 Rsbuild 的 FAQ 文档:
|
|
13
|
+
Modern.js 内部基于 [Rsbuild](https://v2.rsbuild.rs/) 封装了自身的构建工具,因此你可以直接参考 Rsbuild 的 FAQ 文档:
|
|
14
14
|
|
|
15
|
-
- [Rsbuild - 功能类问题](https://rsbuild.rs/zh/guide/faq/features)
|
|
16
|
-
- [Rsbuild - 异常类问题](https://rsbuild.rs/zh/guide/faq/exceptions)
|
|
17
|
-
- [Rsbuild - 热更新问题](https://rsbuild.rs/zh/guide/faq/hmr)
|
|
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
|
|
|
@@ -151,12 +151,40 @@ export default {
|
|
|
151
151
|
|
|
152
152
|
## tools
|
|
153
153
|
|
|
154
|
+
### toos.postcss
|
|
155
|
+
|
|
156
|
+
**变更内容**:对象式配置会覆盖 Modern.js 内置的 PostCSS 配置。如果需要在内置配置基础上进行扩展,请使用函数式配置。
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
// v2
|
|
160
|
+
export default {
|
|
161
|
+
tools: {
|
|
162
|
+
postcss: {
|
|
163
|
+
postcssOptions: {
|
|
164
|
+
plugins: [tailwindcssPlugin],
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
// v3
|
|
173
|
+
export default {
|
|
174
|
+
tools: {
|
|
175
|
+
postcss: (opts, { addPlugins }) => {
|
|
176
|
+
addPlugins(tailwindcssPlugin);
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
```
|
|
181
|
+
|
|
154
182
|
### tools.esbuild
|
|
155
183
|
|
|
156
184
|
**变更内容**:该配置已废弃,需要手动切换到 esbuild 压缩。
|
|
157
185
|
|
|
158
186
|
```typescript
|
|
159
|
-
// 该配置已废弃,请参考 [切换压缩器](https://rsbuild.rs/zh/config/output/minify#%E5%88%87%E6%8D%A2%E5%8E%8B%E7%BC%A9%E5%99%A8) 来手动切换到 esbuild 压缩
|
|
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 压缩
|
|
160
188
|
// tools: {
|
|
161
189
|
// esbuild: { /* 配置 */ }
|
|
162
190
|
// },
|
|
@@ -167,7 +195,7 @@ export default {
|
|
|
167
195
|
**变更内容**:该配置已废弃,需要手动切换到 Terser 压缩。
|
|
168
196
|
|
|
169
197
|
```typescript
|
|
170
|
-
// 该配置已废弃,请参考 [切换压缩器](https://rsbuild.rs/zh/config/output/minify#%E5%88%87%E6%8D%A2%E5%8E%8B%E7%BC%A9%E5%99%A8) 来手动切换到 Terser 压缩
|
|
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 压缩
|
|
171
199
|
// tools: {
|
|
172
200
|
// terser: { /* 配置 */ }
|
|
173
201
|
// },
|
|
@@ -893,7 +921,7 @@ export default defineRuntimeConfig({
|
|
|
893
921
|
|
|
894
922
|
### performance.bundleAnalyze
|
|
895
923
|
|
|
896
|
-
**变更内容**:该配置已废弃,建议使用 [Rsdoctor](https://rsbuild.rs/zh/guide/debug/rsdoctor) 来分析产物体积
|
|
924
|
+
**变更内容**:该配置已废弃,建议使用 [Rsdoctor](https://v2.rsbuild.rs/zh/guide/debug/rsdoctor) 来分析产物体积
|
|
897
925
|
|
|
898
926
|
### performance.transformLodash
|
|
899
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://rsbuild.rs/zh/plugins/dev/hooks#modifybundlerchain)
|
|
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://rsbuild.rs/zh/plugins/dev/hooks#modifyrsbuildconfig)
|
|
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://rsbuild.rs/zh/plugins/dev/hooks#modifyrspackconfig)
|
|
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://rsbuild.rs/zh/plugins/dev/hooks#onbeforebuild)
|
|
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://rsbuild.rs/zh/plugins/dev/hooks#onafterbuild)
|
|
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://rsbuild.rs/zh/plugins/dev/hooks#ondevcompiledone)
|
|
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://rsbuild.rs/zh/plugins/dev/hooks#onbeforecreatecompiler)
|
|
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://rsbuild.rs/zh/plugins/dev/hooks#onaftercreatecompiler)
|
|
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://rsbuild.rs/zh/plugins/dev/hooks#onafterstartdevserver)
|
|
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://rsbuild.rs/plugins/list/index) 了解更多 Rsbuild 插件体系内容。
|
|
120
|
+
可以阅读 [Rsbuild 官网 - 插件](https://v2.rsbuild.rs/plugins/list/index) 了解更多 Rsbuild 插件体系内容。
|
|
121
121
|
:::
|
|
122
122
|
|
|
123
123
|
### 官方插件
|
|
@@ -128,9 +128,9 @@ Rsbuild 是 Modern.js 底层的构建工具,通过添加 Rsbuild 插件可修
|
|
|
128
128
|
|
|
129
129
|
| 插件 | 介绍 | Modern.js 链接 |
|
|
130
130
|
| ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
131
|
-
| [React 插件](https://rsbuild.rs/zh/plugins/list/plugin-react) | 提供对 React 的支持 | - |
|
|
132
|
-
| [SVGR 插件](https://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
|
-
| [Assets Retry 插件](https://
|
|
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
|
+
| [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) |
|
|
136
136
|
| [Check Syntax 插件](https://github.com/rspack-contrib/rsbuild-plugin-check-syntax) | 用于分析产物的语法兼容性,判断是否存在导致兼容性问题的高级语法 | [security.checkSyntax](/configure/app/security/check-syntax.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://rsbuild.rs/zh/plugins/list/plugin-stylus):使用 Stylus 作为 CSS 预处理器。
|
|
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",
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
|
|
4
4
|
const RsbuildLink = ({ configName }: { configName: string }) => {
|
|
5
5
|
const lang = useLang();
|
|
6
|
-
const href = `https://v2.rsbuild.
|
|
6
|
+
const href = `https://v2.rsbuild.dev/${lang === 'zh' ? 'zh/' : ''}config/${configName
|
|
7
7
|
.split('.')
|
|
8
8
|
.join('/')
|
|
9
9
|
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
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,9 +14,21 @@ 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
|
-
Modern.js
|
|
31
|
+
Modern.js 3.0
|
|
20
32
|
</span>
|
|
21
33
|
<div>{t('slogan')}</div>
|
|
22
34
|
</h1>
|