@modern-js/main-doc 2.58.3 → 2.60.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. package/docs/en/_meta.json +10 -5
  2. package/docs/en/apis/app/hooks/api/lambda.mdx +4 -48
  3. package/docs/en/apis/app/hooks/api/middleware.mdx +11 -0
  4. package/docs/en/apis/app/runtime/core/use-loader.mdx +1 -1
  5. package/docs/en/community/blog/v2-release-note.mdx +1 -1
  6. package/docs/en/components/enable-bff.mdx +19 -2
  7. package/docs/en/components/extend-bff-function.mdx +5 -0
  8. package/docs/en/components/init-app.mdx +0 -1
  9. package/docs/en/components/init-rspack-app.mdx +0 -1
  10. package/docs/en/components/other-plugins.mdx +0 -0
  11. package/docs/en/components/ssr-monitor.mdx +3 -0
  12. package/docs/en/configure/app/auto-load-plugin.mdx +4 -0
  13. package/docs/en/configure/app/output/ssg.mdx +52 -141
  14. package/docs/en/configure/app/plugins.mdx +2 -2
  15. package/docs/en/configure/app/tools/esbuild.mdx +1 -1
  16. package/docs/en/configure/app/tools/swc.mdx +1 -1
  17. package/docs/en/configure/app/tools/tailwindcss.mdx +1 -1
  18. package/docs/en/guides/_meta.json +0 -5
  19. package/docs/en/guides/advanced-features/_meta.json +3 -8
  20. package/docs/en/guides/advanced-features/bff/_meta.json +1 -1
  21. package/docs/en/guides/advanced-features/bff/extend-server.mdx +154 -0
  22. package/docs/en/guides/advanced-features/bff/frameworks.mdx +52 -123
  23. package/docs/en/guides/advanced-features/bff/function.mdx +108 -80
  24. package/docs/en/guides/advanced-features/bff/sdk.mdx +40 -51
  25. package/docs/en/guides/advanced-features/build-performance.mdx +6 -21
  26. package/docs/en/guides/advanced-features/page-performance/_meta.json +1 -0
  27. package/docs/en/guides/advanced-features/rspack-start.mdx +6 -14
  28. package/docs/en/guides/basic-features/_meta.json +31 -9
  29. package/docs/en/guides/basic-features/css/_meta.json +1 -0
  30. package/docs/en/guides/basic-features/css/css-in-js.mdx +34 -0
  31. package/docs/en/guides/basic-features/{css-modules.mdx → css/css-modules.mdx} +0 -4
  32. package/docs/en/guides/basic-features/css/css.mdx +25 -0
  33. package/docs/en/guides/basic-features/{css.mdx → css/tailwindcss.mdx} +5 -66
  34. package/docs/en/guides/basic-features/data/data-fetch.mdx +134 -235
  35. package/docs/en/guides/basic-features/data/data-write.mdx +66 -77
  36. package/docs/en/guides/basic-features/debug/_meta.json +1 -0
  37. package/docs/en/guides/basic-features/debug/rsdoctor.mdx +57 -0
  38. package/docs/en/guides/{advanced-features → basic-features/debug}/using-storybook.mdx +2 -0
  39. package/docs/en/guides/basic-features/render/_meta.json +1 -0
  40. package/docs/en/guides/basic-features/render/ssg.mdx +208 -0
  41. package/docs/en/guides/{advanced-features/ssr/cache.mdx → basic-features/render/ssr-cache.mdx} +38 -50
  42. package/docs/en/guides/basic-features/render/ssr.mdx +301 -0
  43. package/docs/en/guides/basic-features/render/streaming-ssr.mdx +230 -0
  44. package/docs/en/guides/basic-features/routes.mdx +274 -263
  45. package/docs/en/guides/basic-features/static-assets/_meta.json +1 -0
  46. package/docs/en/guides/basic-features/static-assets.mdx +2 -2
  47. package/docs/en/guides/basic-features/testing/_meta.json +1 -0
  48. package/docs/en/guides/basic-features/testing/cypress.mdx +95 -0
  49. package/docs/en/guides/basic-features/testing/jest.mdx +148 -0
  50. package/docs/en/guides/basic-features/testing/playwright.mdx +111 -0
  51. package/docs/en/guides/basic-features/testing/vitest.mdx +100 -0
  52. package/docs/en/guides/concept/entries.mdx +9 -2
  53. package/docs/en/guides/deprecated.md +2 -0
  54. package/docs/en/guides/get-started/quick-start.mdx +1 -1
  55. package/docs/en/guides/get-started/tech-stack.mdx +4 -4
  56. package/docs/en/guides/topic-detail/_meta.json +0 -6
  57. package/docs/en/guides/topic-detail/generator/create/config.mdx +0 -10
  58. package/docs/en/guides/topic-detail/generator/create/use.mdx +0 -1
  59. package/docs/en/plugin/_meta.json +19 -0
  60. package/docs/en/plugin/cli-plugins/_meta.json +1 -0
  61. package/docs/en/plugin/cli-plugins/plugin-bff.mdx +5 -0
  62. package/docs/en/plugin/cli-plugins/plugin-ssg.mdx +5 -0
  63. package/docs/en/{guides/rsbuild-plugins → plugin/cli-plugins}/plugin-swc.mdx +7 -0
  64. package/docs/en/plugin/cli-plugins/plugin-tailwind.mdx +5 -0
  65. package/docs/en/plugin/cli-plugins.mdx +6 -0
  66. package/docs/en/{guides/advanced-features/rsbuild-plugin.mdx → plugin/introduction.mdx} +36 -11
  67. package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/extend.mdx +1 -1
  68. package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/implement.mdx +3 -3
  69. package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/plugin-api.mdx +2 -2
  70. package/docs/en/plugin/rsbuild-plugins/_meta.json +1 -0
  71. package/docs/en/plugin/rsbuild-plugins.mdx +3 -0
  72. package/docs/en/tutorials/first-app/c03-css.mdx +1 -1
  73. package/docs/zh/_meta.json +10 -5
  74. package/docs/zh/apis/app/hooks/api/lambda.mdx +5 -48
  75. package/docs/zh/apis/app/hooks/api/middleware.mdx +11 -0
  76. package/docs/zh/apis/app/runtime/core/use-loader.mdx +1 -1
  77. package/docs/zh/community/blog/v2-release-note.mdx +1 -1
  78. package/docs/zh/components/enable-bff.mdx +19 -2
  79. package/docs/zh/components/extend-bff-function.mdx +5 -0
  80. package/docs/zh/components/init-app.mdx +0 -1
  81. package/docs/zh/components/init-rspack-app.mdx +0 -1
  82. package/docs/zh/components/other-plugins.mdx +0 -0
  83. package/docs/zh/components/ssr-monitor.mdx +3 -0
  84. package/docs/zh/configure/app/auto-load-plugin.mdx +4 -0
  85. package/docs/zh/configure/app/output/ssg.mdx +49 -139
  86. package/docs/zh/configure/app/plugins.mdx +2 -2
  87. package/docs/zh/configure/app/tools/esbuild.mdx +1 -1
  88. package/docs/zh/configure/app/tools/swc.mdx +1 -1
  89. package/docs/zh/configure/app/tools/tailwindcss.mdx +1 -1
  90. package/docs/zh/guides/_meta.json +0 -5
  91. package/docs/zh/guides/advanced-features/_meta.json +3 -8
  92. package/docs/zh/guides/advanced-features/bff/_meta.json +1 -1
  93. package/docs/zh/guides/advanced-features/bff/extend-server.mdx +156 -0
  94. package/docs/zh/guides/advanced-features/bff/frameworks.mdx +51 -117
  95. package/docs/zh/guides/advanced-features/bff/function.mdx +69 -59
  96. package/docs/zh/guides/advanced-features/bff/sdk.mdx +27 -36
  97. package/docs/zh/guides/advanced-features/build-performance.mdx +6 -21
  98. package/docs/zh/guides/advanced-features/page-performance/_meta.json +1 -0
  99. package/docs/zh/guides/advanced-features/rspack-start.mdx +8 -17
  100. package/docs/zh/guides/basic-features/_meta.json +31 -9
  101. package/docs/zh/guides/basic-features/alias.mdx +5 -11
  102. package/docs/zh/guides/basic-features/css/_meta.json +1 -0
  103. package/docs/zh/guides/basic-features/css/css-in-js.mdx +34 -0
  104. package/docs/zh/guides/basic-features/css/css.mdx +25 -0
  105. package/docs/zh/guides/basic-features/{css.mdx → css/tailwindcss.mdx} +3 -64
  106. package/docs/zh/guides/basic-features/data/data-fetch.mdx +96 -211
  107. package/docs/zh/guides/basic-features/data/data-write.mdx +54 -55
  108. package/docs/zh/guides/basic-features/debug/_meta.json +1 -0
  109. package/docs/zh/guides/basic-features/debug/rsdoctor.mdx +57 -0
  110. package/docs/zh/guides/{advanced-features → basic-features/debug}/using-storybook.mdx +1 -1
  111. package/docs/zh/guides/basic-features/env-vars.mdx +1 -1
  112. package/docs/zh/guides/basic-features/render/_meta.json +1 -0
  113. package/docs/zh/guides/basic-features/render/ssg.mdx +210 -0
  114. package/docs/zh/guides/{advanced-features/ssr/cache.mdx → basic-features/render/ssr-cache.mdx} +16 -26
  115. package/docs/zh/guides/basic-features/render/ssr.mdx +309 -0
  116. package/docs/zh/guides/{advanced-features/ssr/stream.mdx → basic-features/render/streaming-ssr.mdx} +22 -37
  117. package/docs/zh/guides/basic-features/routes.mdx +251 -237
  118. package/docs/zh/guides/basic-features/static-assets/_meta.json +1 -0
  119. package/docs/zh/guides/basic-features/static-assets.mdx +3 -7
  120. package/docs/zh/guides/basic-features/testing/_meta.json +1 -0
  121. package/docs/zh/guides/basic-features/testing/cypress.mdx +95 -0
  122. package/docs/zh/guides/basic-features/testing/jest.mdx +148 -0
  123. package/docs/zh/guides/basic-features/testing/playwright.mdx +112 -0
  124. package/docs/zh/guides/basic-features/testing/vitest.mdx +100 -0
  125. package/docs/zh/guides/concept/entries.mdx +6 -3
  126. package/docs/zh/guides/deprecated.md +4 -0
  127. package/docs/zh/guides/get-started/quick-start.mdx +1 -1
  128. package/docs/zh/guides/get-started/tech-stack.mdx +8 -8
  129. package/docs/zh/guides/topic-detail/_meta.json +0 -6
  130. package/docs/zh/guides/topic-detail/generator/create/config.mdx +0 -10
  131. package/docs/zh/guides/topic-detail/generator/create/use.mdx +0 -1
  132. package/docs/zh/plugin/_meta.json +19 -0
  133. package/docs/zh/plugin/cli-plugins/_meta.json +1 -0
  134. package/docs/zh/plugin/cli-plugins/plugin-bff.mdx +5 -0
  135. package/docs/zh/plugin/cli-plugins/plugin-ssg.mdx +5 -0
  136. package/docs/zh/{guides/rsbuild-plugins → plugin/cli-plugins}/plugin-swc.mdx +7 -0
  137. package/docs/zh/plugin/cli-plugins/plugin-tailwind.mdx +5 -0
  138. package/docs/zh/plugin/cli-plugins.mdx +6 -0
  139. package/docs/zh/{guides/advanced-features/rsbuild-plugin.mdx → plugin/introduction.mdx} +38 -13
  140. package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/extend.mdx +1 -1
  141. package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/implement.mdx +3 -3
  142. package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/plugin-api.mdx +2 -2
  143. package/docs/zh/plugin/rsbuild-plugins/_meta.json +1 -0
  144. package/docs/zh/plugin/rsbuild-plugins.mdx +4 -0
  145. package/docs/zh/tutorials/first-app/c03-css.mdx +1 -1
  146. package/i18n.json +42 -6
  147. package/package.json +7 -6
  148. package/rspress.config.ts +1 -58
  149. package/src/components/Footer/index.tsx +1 -1
  150. package/src/pages/index.tsx +0 -1
  151. package/docs/en/apis/app/hooks/api/api.mdx +0 -80
  152. package/docs/en/apis/app/hooks/api/app.mdx +0 -12
  153. package/docs/en/apis/app/hooks/config/storybook.mdx +0 -37
  154. package/docs/en/guides/advanced-features/bff/type.mdx +0 -46
  155. package/docs/en/guides/advanced-features/eslint.mdx +0 -148
  156. package/docs/en/guides/advanced-features/ssg.mdx +0 -116
  157. package/docs/en/guides/advanced-features/ssr/_meta.json +0 -1
  158. package/docs/en/guides/advanced-features/ssr/index.mdx +0 -23
  159. package/docs/en/guides/advanced-features/ssr/stream.mdx +0 -248
  160. package/docs/en/guides/advanced-features/ssr/usage.mdx +0 -341
  161. package/docs/en/guides/advanced-features/ssr.mdx +0 -555
  162. package/docs/zh/apis/app/hooks/api/api.mdx +0 -81
  163. package/docs/zh/apis/app/hooks/api/app.mdx +0 -12
  164. package/docs/zh/apis/app/hooks/config/storybook.mdx +0 -38
  165. package/docs/zh/guides/advanced-features/bff/type.mdx +0 -46
  166. package/docs/zh/guides/advanced-features/eslint.mdx +0 -152
  167. package/docs/zh/guides/advanced-features/ssg.mdx +0 -116
  168. package/docs/zh/guides/advanced-features/ssr/_meta.json +0 -1
  169. package/docs/zh/guides/advanced-features/ssr/index.mdx +0 -23
  170. package/docs/zh/guides/advanced-features/ssr/usage.mdx +0 -329
  171. /package/docs/en/guides/advanced-features/{bff/index.mdx → bff.mdx} +0 -0
  172. /package/docs/en/guides/advanced-features/{code-split.mdx → page-performance/code-split.mdx} +0 -0
  173. /package/docs/en/guides/advanced-features/{inline-assets.mdx → page-performance/inline-assets.mdx} +0 -0
  174. /package/docs/en/guides/advanced-features/{optimize-bundle.mdx → page-performance/optimize-bundle.mdx} +0 -0
  175. /package/docs/en/guides/basic-features/{mock.mdx → debug/mock.mdx} +0 -0
  176. /package/docs/en/guides/basic-features/{proxy.mdx → debug/proxy.mdx} +0 -0
  177. /package/docs/en/guides/basic-features/{json-files.mdx → static-assets/json-files.mdx} +0 -0
  178. /package/docs/en/guides/basic-features/{svg-assets.mdx → static-assets/svg-assets.mdx} +0 -0
  179. /package/docs/en/guides/basic-features/{wasm-assets.mdx → static-assets/wasm-assets.mdx} +0 -0
  180. /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/_meta.json +0 -0
  181. /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/hook-list.mdx +0 -0
  182. /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/hook.mdx +0 -0
  183. /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/introduction.mdx +0 -0
  184. /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/lifecycle.mdx +0 -0
  185. /package/docs/en/{guides/topic-detail/framework-plugin → plugin/plugin-system}/relationship.mdx +0 -0
  186. /package/docs/en/{guides → plugin}/rsbuild-plugins/plugin-esbuild.mdx +0 -0
  187. /package/docs/zh/guides/advanced-features/{bff/index.mdx → bff.mdx} +0 -0
  188. /package/docs/zh/guides/advanced-features/{code-split.mdx → page-performance/code-split.mdx} +0 -0
  189. /package/docs/zh/guides/advanced-features/{inline-assets.mdx → page-performance/inline-assets.mdx} +0 -0
  190. /package/docs/zh/guides/advanced-features/{optimize-bundle.mdx → page-performance/optimize-bundle.mdx} +0 -0
  191. /package/docs/zh/guides/basic-features/{css-modules.mdx → css/css-modules.mdx} +0 -0
  192. /package/docs/zh/guides/basic-features/{mock.mdx → debug/mock.mdx} +0 -0
  193. /package/docs/zh/guides/basic-features/{proxy.mdx → debug/proxy.mdx} +0 -0
  194. /package/docs/zh/guides/basic-features/{json-files.mdx → static-assets/json-files.mdx} +0 -0
  195. /package/docs/zh/guides/basic-features/{svg-assets.mdx → static-assets/svg-assets.mdx} +0 -0
  196. /package/docs/zh/guides/basic-features/{wasm-assets.mdx → static-assets/wasm-assets.mdx} +0 -0
  197. /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/_meta.json +0 -0
  198. /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/hook-list.mdx +0 -0
  199. /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/hook.mdx +0 -0
  200. /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/introduction.mdx +0 -0
  201. /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/lifecycle.mdx +0 -0
  202. /package/docs/zh/{guides/topic-detail/framework-plugin → plugin/plugin-system}/relationship.mdx +0 -0
  203. /package/docs/zh/{guides → plugin}/rsbuild-plugins/plugin-esbuild.mdx +0 -0
@@ -0,0 +1,5 @@
1
+ # BFF 插件
2
+
3
+ 在 Modern.js 应用中,通过 BFF 插件,开发者可以在 `api/lambda` 目录下定义接口文件,并导出接口函数。在前端代码中,可以用文件引用的方式,直接调用这些接口函数,发起接口请求。
4
+
5
+ 详细内容可以参考 [BFF - 基础用法](/guides/advanced-features/bff/function)。
@@ -0,0 +1,5 @@
1
+ # SSG 插件
2
+
3
+ SSG(Static Site Generation)是一种基于数据与模板,在构建时渲染完整静态网页的技术解决方案。这意味着在生产环境中,页面默认就是有内容的,并且可以被 CDN 缓存。对于无需数据的页面,SSG 可以提供更好的性能和更高的安全性。
4
+
5
+ 详细内容可以参考 [静态站点生成(SSG)](/guides/basic-features/render/ssg)。
@@ -4,6 +4,13 @@ sidebar_position: 2
4
4
 
5
5
  # SWC 插件
6
6
 
7
+ :::warning
8
+ **当前文档中的 SWC 功能已停止迭代**,我们更推荐使用 Rspack + SWC 的方案。
9
+
10
+ 请参考[「使用 Rspack」](/guides/advanced-features/rspack-start.html)了解更多。
11
+
12
+ :::
13
+
7
14
  import SWC from '@modern-js/builder-doc/docs/zh/shared/swc.md';
8
15
 
9
16
  <SWC />
@@ -0,0 +1,5 @@
1
+ # Tailwind CSS 插件
2
+
3
+ Tailwind CSS 是一个以 Utility Class 为基础的 CSS 框架和设计系统,可以快速地为组件添加常用样式,同时支持主题样式的灵活扩展。
4
+
5
+ 详细内容可以参考 [使用 Tailwind CSS](/guides/basic-features/css/tailwindcss)。
@@ -0,0 +1,6 @@
1
+ # 概览
2
+
3
+ - [@modern-js/plugin-tailwindcss](/plugin/cli-plugins/plugin-tailwind):提供使用 Tailwind CSS 样式的能力。
4
+ - [@modern-js/plugin-bff](/plugin/cli-plugins/plugin-bff):提供 BFF 服务,一体化调用的能力。
5
+ - [@modern-js/plugin-ssg](/plugin/cli-plugins/plugin-bff):提供静态站点生成的能力。
6
+ - [@modern-js/plugin-swc](/plugin/cli-plugins/plugin-swc):提供 SWC 编译支持。
@@ -1,11 +1,28 @@
1
- ---
2
- sidebar_position: 21
3
- title: 使用 Rsbuild 插件
4
- ---
1
+ # 插件
5
2
 
6
- # 使用 Rsbuild 插件
3
+ Modern.js 中目前可以直接使用两种插件,分别是 Modern.js 框架插件和 Rsbuild 构建插件。
7
4
 
8
- ## 插件介绍
5
+ ## Modern.js 框架插件
6
+
7
+ Modern.js 拥有自己的框架插件系统,你可以通过在 `modern.config.ts` 中配置 [`plugins`](/configure/app/plugins) 字段来使用 Modern.js 插件。
8
+
9
+ ### 插件类型
10
+
11
+ 框架插件可以细分成三类,分别是:
12
+
13
+ 1. [CLI 插件](/plugin/cli-plugins):用于在应用执行 Modern.js 命令时,提供额外的功能。例如,添加命令、修改配置、监听文件等。大多数构建相关的能力都可以通过 CLI 插件来实现。
14
+ 2. 服务端插件:用于在应用接受请求时,提供额外的功能。例如,添加中间件、修改请求响应等。
15
+ 3. 运行时插件:用于在应用运行 React 代码时,提供额外的功能。例如,执行初始化行为,包裹 React 高阶组件等。
16
+
17
+ :::note
18
+ 服务端插件和运行时插件即将正式对外开放。
19
+ :::
20
+
21
+ ### 开发插件
22
+
23
+ 如果你需要开发 Modern.js 框架插件,可以阅读 [Modern.js 插件系统](/plugin/plugin-system/introduction) 获取更多信息。
24
+
25
+ ## Rsbuild 构建插件
9
26
 
10
27
  Rsbuild 是 Modern.js 底层的构建工具,可通过添加 Rsbuild 插件修改默认的构建行为并添加各类额外功能,包括但不限于:
11
28
 
@@ -17,14 +34,18 @@ Rsbuild 是 Modern.js 底层的构建工具,可通过添加 Rsbuild 插件修
17
34
  你可以在 `modern.config.ts` 中通过 `builderPlugins` 选项来注册 Rsbuild 插件,详见 [builderPlugins 构建插件](/configure/app/builder-plugins.html)。
18
35
 
19
36
  :::tip
20
- Modern.js 从 `MAJOR_VERSION.46.0` 起开始将底层的构建工具升级为 [Rsbuild](https://rsbuild.dev/)
37
+ Modern.js 从 `MAJOR_VERSION.46.0` 起开始将底层的构建工具升级为 [Rsbuild](https://rsbuild.dev/).
38
+
39
+ 如果你当前版本低于 MAJOR_VERSION.46.0,可通过执行 `npx modern upgrade` 进行升级。
40
+ :::
21
41
 
22
- 如果你当前版本低于 MAJOR_VERSION.46.0, 可通过执行 `npx modern upgrade` 进行升级。
42
+ :::info
43
+ 可以阅读 [Rsbuild 官网 - 插件](https://rsbuild.dev/plugins/list/index) 来了解更多 Rsbuild 插件体系的内容。
23
44
  :::
24
45
 
25
- ## 官方插件
46
+ ### 官方插件
26
47
 
27
- ### 内置插件
48
+ #### 内置插件
28
49
 
29
50
  以下是已在 Modern.js 中内置的 Rsbuild 官方插件,无需安装,即可启用:
30
51
 
@@ -41,13 +62,17 @@ Modern.js 从 `MAJOR_VERSION.46.0` 起开始将底层的构建工具升级为 [R
41
62
  | [CSS Minimizer 插件](https://github.com/rspack-contrib/rsbuild-plugin-css-minimizer) | 用于自定义 CSS 压缩工具,切换到 [cssnano](https://cssnano.co/) 或其他工具进行 CSS 压缩。 | [tools.minifyCss](/configure/app/tools/minify-css.html) |
42
63
  | [Pug 插件](https://github.com/rspack-contrib/rsbuild-plugin-pug) | 提供对 Pug 模板引擎的支持 | [tools.pug](/configure/app/tools/pug.html) |
43
64
  | [Rem 插件](https://github.com/rspack-contrib/rsbuild-plugin-rem) | 用于实现移动端页面的 rem 自适应布局 | [output.convertToRem](/configure/app/output/convert-to-rem.html) |
44
- | [YAML 插件](https://github.com/rspack-contrib/rsbuild-plugin-yaml) | 用于引用 YAML 文件,并将其转换为 JavaScript 对象 | [TOML 文件](/guides/basic-features/json-files.html#toml-文件) |
45
- | [TOML 插件](https://github.com/rspack-contrib/rsbuild-plugin-toml) | 用于引用 TOML 文件,并将其转换为 JavaScript 对象 | [YAML 文件](/guides/basic-features/json-files.html#yaml-文件) |
65
+ | [YAML 插件](https://github.com/rspack-contrib/rsbuild-plugin-yaml) | 用于引用 YAML 文件,并将其转换为 JavaScript 对象 | [TOML 文件](/guides/basic-features/static-assets/json-files.html#toml-文件) |
66
+ | [TOML 插件](https://github.com/rspack-contrib/rsbuild-plugin-toml) | 用于引用 TOML 文件,并将其转换为 JavaScript 对象 | [YAML 文件](/guides/basic-features/static-assets/json-files.html#yaml-文件) |
46
67
 
47
- ### 未内置插件
68
+ #### 未内置的插件
48
69
 
49
70
  以下是未在 Modern.js 中内置的 Rsbuild 官方插件:
50
71
 
51
72
  - [Image Compress 插件](https://github.com/rspack-contrib/rsbuild-plugin-image-compress):将项目中用到的图片资源进行压缩处理。
52
73
  - [Stylus 插件](https://rsbuild.dev/zh/plugins/list/plugin-stylus):使用 Stylus 作为 CSS 预处理器。
53
74
  - [UMD 插件](https://github.com/rspack-contrib/rsbuild-plugin-umd):用于构建 UMD 格式的产物。
75
+
76
+ import OtherPlugins from '@site-docs/components/other-plugins.mdx';
77
+
78
+ <OtherPlugins />
@@ -4,7 +4,7 @@ sidebar_position: 5
4
4
 
5
5
  # 扩展插件 Hook
6
6
 
7
- 本小节介绍如何通过动态注册 [Hook 模型](/guides/topic-detail/framework-plugin/hook) 的方式来扩展插件 Hook。
7
+ 本小节介绍如何通过动态注册 [Hook 模型](/plugin/plugin-system/hook) 的方式来扩展插件 Hook。
8
8
 
9
9
  ## 示例
10
10
 
@@ -31,7 +31,7 @@ const myPlugin = {
31
31
  };
32
32
  ```
33
33
 
34
- 另外,在插件中,允许配置与其他插件的执行顺序。详情可以参考[插件关系](/guides/topic-detail/framework-plugin/relationship)。
34
+ 另外,在插件中,允许配置与其他插件的执行顺序。详情可以参考[插件关系](/plugin/plugin-system/relationship)。
35
35
 
36
36
  ### 插件类型
37
37
 
@@ -115,7 +115,7 @@ import type { MyPluginHook } from 'xxx';
115
115
  const myPlugin: CliPlugin<AppTools & { hooks: MyPluginHook }> = {};
116
116
  ```
117
117
 
118
- 详细说明,请参考 [扩展 Hook](/guides/topic-detail/framework-plugin/extend)。
118
+ 详细说明,请参考 [扩展 Hook](/plugin/plugin-system/extend)。
119
119
 
120
120
  ### 插件配置项
121
121
 
@@ -158,7 +158,7 @@ export const myPlugin = (): CliPlugin => ({
158
158
  });
159
159
  ```
160
160
 
161
- 插件 API 的详细说明,请参考 [Plugin API](/guides/topic-detail/framework-plugin/plugin-api)。
161
+ 插件 API 的详细说明,请参考 [Plugin API](/plugin/plugin-system/plugin-api)。
162
162
 
163
163
  ### 异步 setup
164
164
 
@@ -44,7 +44,7 @@ interface UserConfig {
44
44
  具体配置字段的意义请参考 [配置](/configure/app/usage)。
45
45
 
46
46
  :::tip
47
- 该方法获取到的是只读配置,不可修改。如果需要修改配置,请使用 [config hook](/guides/topic-detail/framework-plugin/hook-list.html#config)。
47
+ 该方法获取到的是只读配置,不可修改。如果需要修改配置,请使用 [config hook](/plugin/plugin-system/hook-list.html#config)。
48
48
  :::
49
49
 
50
50
  ### useResolvedConfigContext
@@ -67,7 +67,7 @@ interface NormalizedConfig {
67
67
  配置字段的完整内容请参考 [配置](/configure/app/usage)。
68
68
 
69
69
  :::tip
70
- 该方法获取到的是只读配置,不可修改。如果需要修改配置,请使用 [config hook](/guides/topic-detail/framework-plugin/hook-list.html#config)。
70
+ 该方法获取到的是只读配置,不可修改。如果需要修改配置,请使用 [config hook](/plugin/plugin-system/hook-list.html#config)。
71
71
  :::
72
72
 
73
73
  ### useAppContext
@@ -0,0 +1 @@
1
+ ["plugin-esbuild"]
@@ -0,0 +1,4 @@
1
+ # 概览
2
+
3
+ - [@modern-js/plugin-esbuild](/plugin/rsbuild-plugins/plugin-esbuild):提供 esbuild 编译支持。
4
+
@@ -293,7 +293,7 @@ import '../styles/utils.css';
293
293
  ```
294
294
 
295
295
  :::info
296
- Modern.js 集成了 [PostCSS](/guides/basic-features/css),支持现代 CSS 语法特性,比如 [custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)。
296
+ Modern.js 集成了 [PostCSS](/guides/basic-features/css/css),支持现代 CSS 语法特性,比如 [custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)。
297
297
 
298
298
  :::
299
299
 
package/i18n.json CHANGED
@@ -11,6 +11,10 @@
11
11
  "zh": "配置",
12
12
  "en": "Config"
13
13
  },
14
+ "plugin-menu": {
15
+ "zh": "插件",
16
+ "en": "Plugin"
17
+ },
14
18
  "apis": {
15
19
  "zh": "API",
16
20
  "en": "API"
@@ -51,21 +55,53 @@
51
55
  "zh": "渲染",
52
56
  "en": "Rendering"
53
57
  },
58
+ "css-solution": {
59
+ "zh": "样式开发",
60
+ "en": "Styling"
61
+ },
62
+ "debug": {
63
+ "zh": "调试",
64
+ "en": "Debug"
65
+ },
66
+ "static-assets": {
67
+ "zh": "引用静态资源",
68
+ "en": "Import Static Assets"
69
+ },
70
+ "testing": {
71
+ "zh": "测试",
72
+ "en": "Testing"
73
+ },
54
74
  "use-bff": {
55
75
  "zh": "使用 BFF",
56
76
  "en": "Using BFF"
57
77
  },
58
- "use-ssr": {
59
- "zh": "服务端渲染",
60
- "en": "SSR"
78
+ "page-performance": {
79
+ "zh": "优化页面性能",
80
+ "en": "Optimize Page Performance"
61
81
  },
62
82
  "micro-frontend": {
63
83
  "zh": "微前端",
64
84
  "en": "Micro Frontend"
65
85
  },
66
- "framework-plugin": {
67
- "zh": "框架插件",
68
- "en": "Framework Plugin"
86
+ "plugin-system": {
87
+ "zh": "插件系统",
88
+ "en": "Plugin System"
89
+ },
90
+ "cli-plugins": {
91
+ "zh": "CLI 插件",
92
+ "en": "CLI Plugins"
93
+ },
94
+ "server-plugins": {
95
+ "zh": "服务端插件",
96
+ "en": "Server Plugins"
97
+ },
98
+ "runtime-plugins": {
99
+ "zh": "运行时插件",
100
+ "en": "Runtime Plugins"
101
+ },
102
+ "rsbuild-plugins": {
103
+ "zh": "Rsbuild 插件",
104
+ "en": "Rsbuild Plugins"
69
105
  },
70
106
  "reduck": {
71
107
  "zh": "Reduck 状态管理",
package/package.json CHANGED
@@ -15,20 +15,20 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.58.3",
18
+ "version": "2.60.0",
19
19
  "publishConfig": {
20
20
  "registry": "https://registry.npmjs.org/",
21
21
  "access": "public",
22
22
  "provenance": true
23
23
  },
24
24
  "dependencies": {
25
- "@modern-js/sandpack-react": "2.58.3"
25
+ "@modern-js/sandpack-react": "2.60.0"
26
26
  },
27
27
  "peerDependencies": {
28
- "@modern-js/builder-doc": "^2.58.3"
28
+ "@modern-js/builder-doc": "^2.60.0"
29
29
  },
30
30
  "devDependencies": {
31
- "@rspress/shared": "1.27.0",
31
+ "@rspress/shared": "1.28.2",
32
32
  "@types/fs-extra": "9.0.13",
33
33
  "@types/node": "^16",
34
34
  "classnames": "^2",
@@ -36,13 +36,14 @@
36
36
  "fs-extra": "^10",
37
37
  "react": "^18",
38
38
  "react-dom": "^18",
39
- "rspress": "1.27.0",
39
+ "rspress": "1.28.2",
40
40
  "ts-node": "^10.9.1",
41
41
  "typescript": "^5",
42
- "@modern-js/builder-doc": "2.58.3"
42
+ "@modern-js/builder-doc": "2.60.0"
43
43
  },
44
44
  "scripts": {
45
45
  "dev": "rspress dev",
46
+ "dev:no_lazy": "LAZY=false rspress dev",
46
47
  "build": "npx ts-node ./scripts/sync.ts",
47
48
  "build:doc": "rspress build",
48
49
  "preview": "rspress preview"
package/rspress.config.ts CHANGED
@@ -6,61 +6,6 @@ const { version } = require('./package.json');
6
6
 
7
7
  const docPath = path.join(__dirname, 'docs');
8
8
 
9
- const getNavbar = (lang: string): NavItem[] => {
10
- const cn = lang === 'zh';
11
- const prefix = cn ? '' : '/en';
12
- const getLink = (str: string) => `${prefix}${str}`;
13
- const getText = (cnText: string, enText: string) => (cn ? cnText : enText);
14
- return [
15
- {
16
- text: getText('指南', 'Guide'),
17
- link: getLink('/guides/get-started/introduction'),
18
- activeMatch: '/guides/',
19
- },
20
- {
21
- text: getText('教程', 'Tutorials'),
22
- link: getLink('/tutorials/foundations/introduction'),
23
- activeMatch: '/tutorials/',
24
- },
25
- {
26
- text: getText('配置', 'Configure'),
27
- link: getLink('/configure/app/usage'),
28
- activeMatch: '/configure/app',
29
- },
30
- {
31
- text: getText('API', 'API'),
32
- link: getLink('/apis/app/commands'),
33
- activeMatch: '/apis/',
34
- },
35
- {
36
- text: getText('社区', 'Community'),
37
- link: getLink('/community/showcase'),
38
- activeMatch: '/community/',
39
- },
40
- {
41
- text: `v${version}`,
42
- items: [
43
- {
44
- text: 'Rsbuild',
45
- link: 'https://github.com/web-infra-dev/rsbuild',
46
- },
47
- {
48
- text: 'Rspress',
49
- link: 'https://github.com/web-infra-dev/rspress',
50
- },
51
- {
52
- text: 'Modern.js Module',
53
- link: 'https://modernjs.dev/module-tools/en/',
54
- },
55
- {
56
- text: 'Modern.js v1',
57
- link: 'https://modernjs.dev/v1/',
58
- },
59
- ],
60
- },
61
- ];
62
- };
63
-
64
9
  export default defineConfig({
65
10
  root: docPath,
66
11
  base: '/',
@@ -134,12 +79,10 @@ export default defineConfig({
134
79
  ],
135
80
  builderConfig: {
136
81
  output: {
137
- disableTsChecker: true,
138
- svgDefaultExport: 'component',
139
82
  dataUriLimit: 0,
140
83
  },
141
84
  dev: {
142
- startUrl: false,
85
+ lazyCompilation: process.env.LAZY !== 'false',
143
86
  },
144
87
  source: {
145
88
  alias: {
@@ -76,7 +76,7 @@ export default function Footer() {
76
76
  },
77
77
  {
78
78
  label: t('pluginSystem'),
79
- to: useUrl('/guides/topic-detail/framework-plugin/introduction'),
79
+ to: useUrl('/plugin/plugin-system/introduction'),
80
80
  },
81
81
  {
82
82
  label: t('projectGenerator'),
@@ -1,4 +1,3 @@
1
- /* eslint-disable react/no-unescaped-entities */
2
1
  import clsx from 'clsx';
3
2
  import { useEffect } from 'react';
4
3
  import { Helmet, useLang, useLocation } from 'rspress/runtime';
@@ -1,80 +0,0 @@
1
- ---
2
- title: '**/*.[tj]s'
3
- sidebar_position: 1
4
- ---
5
- # **/*.[tj]s
6
-
7
- Files that declare API routes in the [BFF Function Mode](/guides/advanced-features/bff/type.html#function-mode). Except for some [convention files](/apis/app/hooks/api/api#allow-list), files in the `api` directory will be registered as the routes.
8
-
9
- :::info
10
- Using the `api` directory requires enabling the BFF feature, and you need to run the `new` command in the project to enable the "BFF" feature.
11
-
12
- This file supports using the `js` or `ts` language, but you must use `esm` syntax to export functions.
13
-
14
- :::
15
-
16
- ## Routing File Convention
17
-
18
- ### Default Routing
19
-
20
- The routing system will map files named `index` to the previous directory.
21
-
22
- - `api/index.ts` -> `$BASENAME/`
23
- - `api/user/index.ts` -> `$BASENAME/user`
24
-
25
- ### Nested Routing
26
-
27
- The routing system also supports parsing nested files. If you create a nested folder structure, the files will still automatically resolve routes in the same way.
28
-
29
- - `api/hello.ts` -> `$BASENAME/hello`
30
- - `api/user/list.ts` -> `$BASENAME/user/list`
31
-
32
- ### Dynamic Routing
33
-
34
- The routing system supports generating dynamic routes through file directories named with `[]`.
35
-
36
- - `api/user/[username]/info.ts` -> `$BASENAME/user/:username/info`
37
- - `api/user/[username]/delete.ts` -> `$BASENAME/user/:username/delete`
38
- - `api/article/[id]/info.ts` -> `$BASENAME/article/:id/info`
39
-
40
- The `$BASENAME` can be configured in `modern.config.js`, and the default value is `/api`.
41
-
42
- ### Allow List
43
-
44
- By default, all files in the `api` directory will be parsed as BFF function files, but we also set a white list for these files that are not parsed:
45
-
46
- - Files whose names start with `_`. For example: `_utils.ts`.
47
- - All files in folders whose names start with `_`. For example: `_utils/index.ts`, `_utils/cp.ts`.
48
- - Test files. For example: `foo.test.ts`.
49
- - TypeScript type files. For example: `hello.d.ts`.
50
- - Files under `node_modules`.
51
-
52
- ## Function Definition
53
-
54
- In addition to the routing rules above, there are also conventions for function definitions and exports in the code.
55
-
56
- Functions are exported by name, and the name of the exported function is the HTTP method accepted by the corresponding interface, that is:
57
-
58
- ```ts
59
- export const get = async () => {
60
- return {
61
- name: 'Modern.js',
62
- desc: 'Modern web Solutions',
63
- };
64
- };
65
- ```
66
-
67
- By exporting functions in this way, you will get a `GET` interface.
68
-
69
- The application project supports 9 Method definitions, namely: `GET`, `POST`, `PUT`, `DELETE`, `CONNECT`, `TRACE`, `PATCH`, `OPTION`, `HEAD`, that is, these Methods can be used as the names of the exported functions.
70
-
71
- The name is case-insensitive, that is, if it is `GET`, it can be written as `get`, `Get`, `GEt`, `GET`, all of which can be accurately recognized. The default export, that is, `export default xxx`, will be mapped to `Get`.
72
-
73
- Because `delete` is a keyword in JavaScript, you can use `del` or `DELETE` instead.
74
-
75
- Multiple functions with different Methods can be defined in one file, but if multiple functions with the same Method are defined, only the first one will take effect.
76
-
77
- :::info
78
- It should be noted that the defined functions should all be asynchronous, which is related to the type when calling the function.
79
-
80
- :::
@@ -1,12 +0,0 @@
1
- ---
2
- title: _app.[tj]s
3
- sidebar_position: 2
4
- ---
5
- # _app.[tj]s
6
-
7
- In the [BFF Function Mode](/guides/advanced-features/bff/type.html#function-mode), this file can add pre-middleware for BFF functions.
8
-
9
- :::note
10
- For specific examples, please refer to [hook](/apis/app/runtime/bff/hook).
11
-
12
- :::
@@ -1,37 +0,0 @@
1
- ---
2
- title: storybook/
3
- sidebar_position: 7
4
- ---
5
-
6
- # storybook/
7
-
8
- Modern.js supports debugging using Storybook. When configuring Storybook, you need to configure it in the `config/storybook` directory of the project.
9
-
10
- Please refer to [Storybook Configuration](https://storybook.js.org/docs/react/configure/overview) for Storybook configuration.
11
-
12
- :::info
13
- Enabling the Storybook function requires running the new command to enable it under the project first.
14
- :::
15
-
16
- #### Example
17
-
18
- For the webpack configuration of the Storybook Manager app section, you can configure it by adding the `./config/storybook/main.js` file to configure it.
19
-
20
- ```js
21
- // ./config/storybook/main.js
22
-
23
- module.exports = {
24
- // it controls the Storybook manager app
25
- managerWebpack: async (config, options) => {
26
- // update config here
27
- return config;
28
- },
29
- };
30
- ```
31
-
32
- ### Limitation
33
-
34
- There are some limitations when using the `config/storybook` directory for configuration:
35
-
36
- - The location where the Story file is stored cannot be modified, that is, the `stories` configuration cannot be modified in the `main.js` file.
37
- - It is not supported to modify Webpack and Babel related configurations in `main.js`, related requirements can be passed through [`tools.webpack`](/configure/app/tools/webpack.html) /[`tools.babel`](/configure/app/tools/babel.html) modify.
@@ -1,46 +0,0 @@
1
- ---
2
- sidebar_position: 2
3
- title: BFF Type
4
- ---
5
- # BFF Type
6
-
7
- Runtime framework support is also an important part of **BFF**. Modern.js supports extending BFF's runtime framework through plugins, and provides a series of built-in plugins, developers can directly use the conventions and ecology of the framework.
8
-
9
- The plugin is compatible with most of the specifications of these frameworks, and each framework needs to provide two types of ways to extend the writing of BFF functions, namely **Function Mode** and **Framework Mode**.
10
-
11
- :::note
12
- Whether the current `api/` directory structure is written as a framework is determined by the corresponding plugin, Modern.js don't care.
13
-
14
- :::
15
-
16
- ## Function Mode
17
-
18
- When the plugin considers that it is currently written as a function, it must support writing middleware in the `api/_ app.ts` to extend the BFF function.
19
-
20
- Modern.js collects the middleware in the `api/_app.ts` and passes it to the plugin, which injects the middleware into the runtime, for example:
21
-
22
- ```ts
23
- import { hook } from '@modern-js/runtime/server';
24
-
25
- export default hook(({ addMiddleware }) => {
26
- addMiddleware(myMiddleware);
27
- });
28
- ```
29
-
30
- :::note
31
- The writing of middleware for different plugins is not the same, see [Runtime Framework](/guides/advanced-features/bff/frameworks) for details.
32
-
33
- :::
34
-
35
- ## Framework Mode
36
-
37
- Framework writing is a way of using frame structure to extend BFF functions. Compared with function writing, although frame writing can use more frame structure and make the entire BFF Server clearer in complex scenarios, it is also more complex and requires more attention to the content at the framework level.
38
-
39
- In the framework writing method, all BFF functions need to be written in the `api/lambda/` directory, and the hook file `_app.[tj]s` cannot be used.
40
-
41
- In most cases, the function writing method can cover the customization requirements of most BFF functions. Only when your project server level logic is more complex, the code needs to be layered, or you need to use more elements of the framework, you need to use the framework writing method.
42
-
43
- :::note
44
- The directory structure of different plugin frameworks is not the same, see [Runtime Frameworks](/guides/advanced-features/bff/frameworks) for details.
45
-
46
- :::