@modern-js/main-doc 2.58.3 → 2.60.0

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.
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
@@ -1,11 +1,26 @@
1
- ---
2
- sidebar_position: 21
3
- title: Using Rsbuild Plugin
4
- ---
1
+ # Plugin
5
2
 
6
- # Using Rsbuild Plugin
3
+ In Modern.js, you can directly use two types of plugins: Modern.js framework plugins and Rsbuild plugins.
7
4
 
8
- ## Introduce Rsbuild Plugin
5
+ ## Modern.js Framework Plugin
6
+
7
+ Modern.js has its own framework plugin system. You can use Modern.js plugins by configuring the [`plugins`](/configure/app/plugins) field in `modern.config.ts`.
8
+
9
+ ### Plugin Types
10
+
11
+ Framework plugins can be categorized into three types:
12
+
13
+ 1. [CLI Plugins](/plugin/cli-plugins): These are used to provide additional functionality when the Modern.js commands are executed in the application. Examples include adding commands, modifying configuration, and monitoring files. Most build-related capabilities can be achieved through CLI plugins.
14
+ 2. Server Plugins: These add extra functionality when the application receives requests. Examples include adding middleware and modifying request responses.
15
+ 3. Runtime Plugins: These provide additional functionality when the application runs React code. Examples include performing initialization actions and wrapping React higher-order components.
16
+
17
+ :::note
18
+ Server plugins and Runtime plugins are coming soon.
19
+ :::
20
+
21
+ ### Developing Plugins
22
+
23
+ If you need to develop Modern.js framework plugins, you can read [Modern.js Plugin System](/plugin/plugin-system/introduction) for more information.
9
24
 
10
25
  Rsbuild is the build tool of Modern.js. You can modify the default build behavior and add various additional features by adding the Rsbuild plugin, including but not limited to:
11
26
 
@@ -22,9 +37,15 @@ Modern.js has upgraded the build tool to [Rsbuild](https://rsbuild.dev/) startin
22
37
  If your current version is lower than MAJOR_VERSION.46.0, you can upgrade by executing `npx modern upgrade`.
23
38
  :::
24
39
 
25
- ## Official Plugins
40
+ :::info
41
+ For more information about the Rsbuild plugin system, you can read [Rsbuild Official Site - Plugins](https://rsbuild.dev/plugins/list/index).
42
+ :::
43
+
44
+ ## Rsbuild Plugin
26
45
 
27
- ### Builtin Plugins
46
+ ### Official Plugins
47
+
48
+ #### Builtin Plugins
28
49
 
29
50
  Here are the official Rsbuild plugins built into Modern.js:
30
51
 
@@ -41,13 +62,17 @@ Here are the official Rsbuild plugins built into Modern.js:
41
62
  | [CSS Minimizer Plugin](https://github.com/rspack-contrib/rsbuild-plugin-css-minimizer) | Used to customize CSS minimizer, switch to [cssnano](https://cssnano.co/) or other tools for CSS compression | [tools.minifyCss](/configure/app/tools/minify-css.html) |
42
63
  | [Pug Plugin](https://github.com/rspack-contrib/rsbuild-plugin-pug) | Provides support for the Pug template engine | [tools.pug](/configure/app/tools/pug.html) |
43
64
  | [Rem Plugin](https://github.com/rspack-contrib/rsbuild-plugin-rem) | Implements the rem adaptive layout for mobile pages | [output.convertToRem](/configure/app/output/convert-to-rem.html) |
44
- | [YAML Plugin](https://github.com/rspack-contrib/rsbuild-plugin-yaml) | Used to import YAML files and convert them into JavaScript objects | [TOML File](/guides/basic-features/json-files.html#toml-file) |
45
- | [TOML Plugin](https://github.com/rspack-contrib/rsbuild-plugin-toml) | Used to import TOML files and convert them into JavaScript objects | [YAML File](/guides/basic-features/json-files.html#yaml-file) |
65
+ | [YAML Plugin](https://github.com/rspack-contrib/rsbuild-plugin-yaml) | Used to import YAML files and convert them into JavaScript objects | [TOML File](/guides/basic-features/static-assets/json-files.html#toml-file) |
66
+ | [TOML Plugin](https://github.com/rspack-contrib/rsbuild-plugin-toml) | Used to import TOML files and convert them into JavaScript objects | [YAML File](/guides/basic-features/static-assets/json-files.html#yaml-file) |
46
67
 
47
- ### Un-builtin Plugins
68
+ #### Un-builtin Plugins
48
69
 
49
70
  Here are the official Rsbuild plugins that are not built into Modern.js:
50
71
 
51
72
  - [Image Compress Plugin](https://github.com/rspack-contrib/rsbuild-plugin-image-compress): Compress the image resources used in the project.
52
73
  - [Stylus Plugin](https://rsbuild.dev/plugins/list/plugin-stylus): Use Stylus as the CSS preprocessor.
53
74
  - [UMD Plugin](https://github.com/rspack-contrib/rsbuild-plugin-umd): Used to build outputs in UMD format.
75
+
76
+ import OtherPlugins from '@site-docs-en/components/other-plugins.mdx';
77
+
78
+ <OtherPlugins />
@@ -4,7 +4,7 @@ sidebar_position: 5
4
4
 
5
5
  # Extending Plugin Hooks
6
6
 
7
- This section describes how to extend plugin Hooks by dynamically registering [Hook models](/guides/topic-detail/framework-plugin/hook).
7
+ This section describes how to extend plugin Hooks by dynamically registering [Hook models](/plugin/plugin-system/hook).
8
8
 
9
9
  ## Example
10
10
 
@@ -28,7 +28,7 @@ const myPlugin = {
28
28
  };
29
29
  ```
30
30
 
31
- In addition, plugins allow configuration of the execution order with other plugins. For more information, please refer to [Plugin Relationship](/guides/topic-detail/framework-plugin/relationship).
31
+ In addition, plugins allow configuration of the execution order with other plugins. For more information, please refer to [Plugin Relationship](/plugin/plugin-system/relationship).
32
32
 
33
33
  ### Plugin Types
34
34
 
@@ -108,7 +108,7 @@ import type { MyPluginHook } from 'xxx';
108
108
  const myPlugin: CliPlugin<AppTools & { hooks: MyPluginHook }> = {};
109
109
  ```
110
110
 
111
- Please refer to [Extending Hooks](/guides/topic-detail/framework-plugin/extend) for detailed explanations.
111
+ Please refer to [Extending Hooks](/plugin/plugin-system/extend) for detailed explanations.
112
112
 
113
113
  ### Plugin Configuration
114
114
 
@@ -151,7 +151,7 @@ export const myPlugin = (): CliPlugin => ({
151
151
  });
152
152
  ```
153
153
 
154
- For more detail [Plugin API](/guides/topic-detail/framework-plugin/plugin-api).
154
+ For more detail [Plugin API](/plugin/plugin-system/plugin-api).
155
155
 
156
156
  ### Async setup
157
157
 
@@ -44,7 +44,7 @@ interface UserConfig {
44
44
  Please refer to [Configuration](/configure/app/usage) for the specific meanings of configuration fields.
45
45
 
46
46
  :::tip
47
- This method returns a read-only configuration and cannot be modified. If you need to modify the configuration, please use [config hook](/guides/topic-detail/framework-plugin/hook-list.html#config).
47
+ This method returns a read-only configuration and cannot be modified. If you need to modify the configuration, please use [config hook](/plugin/plugin-system/hook-list.html#config).
48
48
  :::
49
49
 
50
50
  ### useResolvedConfigContext
@@ -67,7 +67,7 @@ interface NormalizedConfig {
67
67
  Please refer to [Configuration](/configure/app/usage) for the specific meanings of configuration fields.
68
68
 
69
69
  :::tip
70
- This method returns a read-only configuration and cannot be modified. If you need to modify the configuration, please use [config hook](/guides/topic-detail/framework-plugin/hook-list.html#config).
70
+ This method returns a read-only configuration and cannot be modified. If you need to modify the configuration, please use [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,3 @@
1
+ # Overview
2
+
3
+ - [@modern-js/plugin-esbuild](/plugin/rsbuild-plugins/plugin-esbuild): Provides esbuild compilation support.
@@ -294,7 +294,7 @@ A Utility Class named `custom-text-gray` is implemented in `src/routes/styles/ut
294
294
  ```
295
295
 
296
296
  :::info note
297
- Modern.js integrates with [PostCSS](/guides/basic-features/css) and supports modern CSS syntax features such as [custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties).
297
+ Modern.js integrates with [PostCSS](/guides/basic-features/css/css) and supports modern CSS syntax features such as [custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties).
298
298
 
299
299
  :::
300
300
 
@@ -4,21 +4,26 @@
4
4
  "link": "/guides/get-started/introduction",
5
5
  "activeMatch": "/guides/"
6
6
  },
7
- {
8
- "text": "tutorials",
9
- "link": "/tutorials/foundations/introduction",
10
- "activeMatch": "/tutorials/"
11
- },
12
7
  {
13
8
  "text": "configure",
14
9
  "link": "/configure/app/usage",
15
10
  "activeMatch": "/configure/"
16
11
  },
12
+ {
13
+ "text": "plugin-menu",
14
+ "link": "/plugin/introduction",
15
+ "activeMatch": "/plugin/"
16
+ },
17
17
  {
18
18
  "text": "apis",
19
19
  "link": "/apis/app/commands",
20
20
  "activeMatch": "/apis/"
21
21
  },
22
+ {
23
+ "text": "tutorials",
24
+ "link": "/tutorials/foundations/introduction",
25
+ "activeMatch": "/tutorials/"
26
+ },
22
27
  {
23
28
  "text": "community",
24
29
  "link": "/community/showcase",
@@ -2,56 +2,13 @@
2
2
  title: lambda/*.[tj]s
3
3
  sidebar_position: 3
4
4
  ---
5
- # lambda/*.[tj]s
6
-
7
- 在 [BFF 框架写法](/guides/advanced-features/bff/type.html#框架写法)下,声明 API 路由的文件。除了[某些约定文件](/apis/app/hooks/api/lambda#白名单)外,`lambda/` 目录下的文件会被注册为接口的路由。
8
-
9
- :::info
10
- 使用 `api` 目录需要开启 BFF 功能,需要在项目下执行 new 命令启用「BFF」功能。
11
5
 
12
- :::
6
+ # lambda/*.[tj]s
13
7
 
14
- :::tip
15
- 该文件支持使用 `js` 或 `ts` 语言,但必须使用 `esm` 语法导出函数。
8
+ 开启 BFF 后,`lambda/` 目录下的文件会按照约定被注册为 BFF 的路由。
16
9
 
10
+ :::note
11
+ 文件支持使用 `js` 或 `ts` 语言,但必须使用 `esm` 语法导出函数。
17
12
  :::
18
13
 
19
- ## 路由规则
20
-
21
- ### 默认路由
22
-
23
- 路由系统会将以 `index` 命名的文件会被映射到上一层目录。
24
-
25
- - `api/lambda/index.ts` -> `$BASENAME/`
26
- - `api/lambda/user/index.ts` -> `$BASENAME/user`
27
-
28
- ### 多级路由
29
-
30
- 路由系统也支持解析多级的文件,如果创建文件夹结构,文件仍会以相同方式自动解析路由。
31
-
32
- - `api/lambda/hello.ts` -> `$BASENAME/hello`
33
- - `api/lambda/user/list.ts` -> `$BASENAME/user/list`
34
-
35
- ### 动态路由
36
-
37
- 路由系统支持通过 `[]` 命名的文件目录生成动态路由。
38
-
39
- - `api/lambda/user/[username]/info.ts` -> `$BASENAME/user/:username/info`
40
- - `api/lambda/user/[username]/delete.ts` -> `$BASENAME/user/:username/delete`
41
- - `api/lambda/article/[id]/info.ts` -> `$BASENAME/article/:id/info`
42
-
43
- 其中的 `$BASENAME` 可以在 `modern.config.js` 中进行配置,默认值为 `/api`。
44
-
45
- ### 白名单
46
-
47
- 默认 `lambda` 目录下所有文件都会当作 BFF 函数文件去解析,但同样我们也设置了白名单,这些文件不被被解析:
48
-
49
- - 命名以 `_` 开头的文件。例如:`_utils.ts`。
50
- - 命名以 `_` 开头的文件夹下所有文件。例如:`_utils/index.ts`、`_utils/cp.ts`。
51
- - 测试文件。例如:`foo.test.ts`。
52
- - TypeScript 类型文件。例如:`hello.d.ts`。
53
- - `node_module` 下的文件。
54
-
55
- ## 函数定义
56
-
57
- 和函数写法下[函数定义](/apis/app/hooks/api/api#函数定义)完全一致。
14
+ 详细内容可以参考 [BFF 函数路由](/guides/advanced-features/bff/function.html#函数路由)。
@@ -0,0 +1,11 @@
1
+ ---
2
+ title: _app.[tj]s
3
+ sidebar_position: 2
4
+ ---
5
+ # _app.[tj]s
6
+
7
+ 该文件可以为 BFF 函数添加前置中间件,详细内容参考 [扩展 BFF Server](/guides/advanced-features/bff/extend-server)。
8
+
9
+ :::note
10
+ 具体示例请参考 [hook](/apis/app/runtime/bff/hook)。
11
+ :::
@@ -52,7 +52,7 @@ function useLoader(loaderFn: LoaderFn, options: Options): ReturnData;
52
52
  - `initialData`:首次执行前的初始数据,对应返回值中的 `data` 字段。
53
53
  - `skip`:当值为 `true` 时,函数不执行。
54
54
  - `params`:当 `params` 序列化结果发生改变时,函数会重新执行。同时,`params` 也会作为函数的第二个参数被传入。
55
- - `static`:当值为 `true` 时,`useLoader` 用于 [SSG](/guides/advanced-features/ssg) 编译阶段数据的获取。
55
+ - `static`:当值为 `true` 时,`useLoader` 用于 [SSG](/guides/basic-features/render/ssg) 编译阶段数据的获取。
56
56
 
57
57
  ### 返回值
58
58
 
@@ -132,7 +132,7 @@ Modern.js 可以划分为三个核心部分:**CLI 工具、服务端和运行
132
132
 
133
133
  在字节跳动内部,我们借助这些插件 API,结合公司内的基建和平台,封装出内部的企业级框架。如果你需要对 Modern.js 框架进行深度定制,也可以借助这些插件 API 来完成。
134
134
 
135
- > 如果你对 Modern.js 的插件系统感兴趣,请阅读 [「Modern.js - 自定义插件」](https://modernjs.dev/guides/topic-detail/framework-plugin/introduction.html)文档。
135
+ > 如果你对 Modern.js 的插件系统感兴趣,请阅读 [「Modern.js - 自定义插件」](https://modernjs.dev/plugin/plugin-system/introduction.html)文档。
136
136
 
137
137
  ### 嵌套路由
138
138
 
@@ -1,5 +1,22 @@
1
- 1. 执行 `pnpm new`,选择启用 BFF
2
- 2. 根据选择的运行时框架,将下面的代码添加到 `modern.config.[tj]s` 中:
1
+ import { PackageManagerTabs } from '@theme';
2
+
3
+ 1. 执行 `new` 命令:
4
+
5
+ <PackageManagerTabs command="run new" />
6
+
7
+ 2. 按照提示,选择**启用 BFF 功能**:
8
+
9
+ ```bash
10
+ ? 请选择你想要的操作 启用可选功能
11
+ ? 请选择功能名称 启用「BFF」功能
12
+ ? 请选择 BFF 类型 框架模式
13
+ ```
14
+
15
+ :::note
16
+ 目前推荐使用框架模式创建 BFF,后续我们将会移除 BFF 类型的概念。
17
+ :::
18
+
19
+ 3. 根据选择的运行时框架,将下面的代码添加到 `modern.config.[tj]s` 中:
3
20
 
4
21
  import { Tabs, Tab as TabItem } from "@theme";
5
22
 
@@ -0,0 +1,5 @@
1
+ 普通的 BFF 函数写法有时并不能满足需求,我们正在设计一套更强大的 BFF 函数写法,让开发者更方便地扩展 BFF 函数。
2
+
3
+ :::note
4
+ 敬请期待
5
+ :::
@@ -4,7 +4,6 @@
4
4
  ? 请选择你想创建的工程类型 Web 应用
5
5
  ? 请选择开发语言 TS
6
6
  ? 请选择包管理工具 pnpm
7
- ? 请选择构建工具 webpack
8
7
  ```
9
8
 
10
9
  在生成项目后,Modern.js 会自动安装依赖、创建 git 仓库。
@@ -3,5 +3,4 @@ $ npx @modern-js/create@latest myapp
3
3
  ? 请选择你想创建的工程类型:Web 应用
4
4
  ? 请选择开发语言:TS
5
5
  ? 请选择包管理工具:pnpm
6
- ? 请选择构建工具:Rspack
7
6
  ```
File without changes
@@ -0,0 +1,3 @@
1
+ :::note
2
+ 敬请期待
3
+ :::
@@ -9,6 +9,10 @@ sidebar_position: 22
9
9
 
10
10
  用于配置 Modern.js 是否开启自动注册插件。
11
11
 
12
+ :::warning
13
+ 该配置不推荐使用,相比手动注册插件,该配置相对黑盒且无法为插件添加自定义配置。
14
+ :::
15
+
12
16
  ### 手动注册插件
13
17
 
14
18
  默认情况下,安装插件后,你需要在 `modern.config.ts` 文件中手动注册插件。
@@ -4,44 +4,22 @@ title: ssg
4
4
 
5
5
  # output.ssg
6
6
 
7
- - **类型:** `boolean` | `object` | `function`
7
+ - **类型:** `boolean` | `object`
8
8
  - **默认值:** `undefined`
9
9
 
10
- 开启**自控式路由**或**约定式路由** SSG 功能的配置。
10
+ 开启应用 SSG 功能的配置
11
11
 
12
- :::info 开启 SSG 功能
13
- 此配置需要在开启 SSG 功能情况下才会生效。请阅读 [静态站点生成](/guides/advanced-features/ssg) 文档了解如何开启 SSG 功能。
12
+ :::tip 开启 SSG 功能
13
+ 此配置需要在开启 SSG 功能情况下才会生效。请阅读 [静态站点生成](/guides/basic-features/render/ssg) 文档了解如何开启 SSG 功能及使用场景。
14
14
  :::
15
15
 
16
- :::info 客户端路由
17
- 相关内容可以查看[路由方案](/guides/basic-features/routes)。
18
-
16
+ :::info 前置阅读
17
+ SSG 功能使用与路由关联性较大,建议使用前先了解[路由方案](/guides/basic-features/routes)。
19
18
  :::
20
19
 
21
- ## 示例
22
-
23
- ### 单入口
24
-
25
- 当该配置设置为 `true` 时,将会默认开启所有入口的 SSG 功能。
26
-
27
- 对**自控式路由**而言,将会渲染入口的根路由。对**约定式路由**而言,将会渲染入口中每一条路由。
28
-
29
- 例如 `src/` 目录下有以下满足**约定式路由**的文件结构:
30
-
31
- ```bash
32
- .
33
- ├── src
34
- │ └── routes
35
- │ ├── layout.tsx
36
- │ ├── page.tsx
37
- │ └── user
38
- │ ├── layout.tsx
39
- │ ├── page.tsx
40
- │ └── profile
41
- │ └── page.tsx
42
- ```
20
+ ## Boolean 类型
43
21
 
44
- `modern.config.js` 中做以下设置:
22
+ 当该配置设置为 `true` 时,将会默认开启所有入口的 SSG 功能。对**自控式路由**而言,将会渲染入口的根路由。对**约定式路由**而言,将会渲染入口中每一条路由。
45
23
 
46
24
  ```js
47
25
  export default defineConfig({
@@ -51,39 +29,20 @@ export default defineConfig({
51
29
  });
52
30
  ```
53
31
 
54
- 执行 `pnpm build` 构建应用后。`dist/` 目录将会生成三张 HTML 分别对应三条路由(不开启 SSG 时只有一张 HTML),并且所有 HTML 都已经渲染。
55
-
56
- 而例如下面的**自控式路由**:
57
-
58
- import SelfRouteExample from "@site-docs/components/self-route-example";
59
-
60
- <SelfRouteExample />
61
-
62
- 同样使用上面的配置,在执行 `pnpm run build` 后,只有入口路由 `/` 会生成渲染后的 HTML。
63
-
64
- ### 多入口
65
-
66
32
  `output.ssg` 也可以按照入口配置,配置生效的规则同样由入口路由方式决定。
67
33
 
68
- 例如以下目录结构:
34
+ 例如以下目录结构,分别存在约定式路由入口 `entryA` 和自控式路由入口 `entryB`:
69
35
 
70
36
  ```bash
71
-
72
- ├── src
73
- ├── entryA
74
- └── routes
75
- │ │ ├── layout.tsx
76
- │ │ ├── page.tsx
77
- │ │ └── user
78
- │ │ ├── layout.tsx
79
- │ │ ├── page.tsx
80
- │ │ └── profile
81
- │ │ └── page.tsx
82
- │ └── entryB
83
- │ └── App.tsx
37
+ .
38
+ └── src
39
+ ├── entryA
40
+ │ └── routes
41
+ └── entryB
42
+ └── App.tsx
84
43
  ```
85
44
 
86
- 默认情况下,所有约定式路由的入口,在设置 `output.ssg` 配置为 `true` 后都会在构建阶段渲染。可以配置 `false` 来取消指定入口的的默认行为,例如取消上述 entryA 入口在构建时的渲染:
45
+ 你可以指定 `entryA` `entryB` 的不同 SSG 配置:
87
46
 
88
47
  ```js
89
48
  export default defineConfig({
@@ -96,107 +55,58 @@ export default defineConfig({
96
55
  });
97
56
  ```
98
57
 
99
- ### 配置路由
100
-
101
- 上述内容中提到,**自控式路由**默认只会开启入口路由的 SSG 配置。
102
-
103
- 可以在 `output.ssg` 中设置具体的路由,告知 Modern.js 开启这些客户端路由的 SSG 功能。例如上述 `src/App.tsx` 的文件内容为:
104
-
105
-
106
- <SelfRouteExample />
107
-
108
- 在 `modern.config.js` 中这样设置后,`/about` 路由也会开启 SSG 功能:
109
-
110
- ```js
111
- export default defineConfig({
112
- output: {
113
- ssg: {
114
- routes: ['/', '/about'],
115
- },
116
- },
117
- });
118
- ```
119
-
120
- Modern.js 将会自动根据入口拼接完整的 URL 并交给 SSG 插件完成渲染。
121
-
122
- 也可以为具体入口或路由配置请求头,例如:
123
-
124
- ```js
125
- export default defineConfig({
126
- output: {
127
- ssg: {
128
- headers: {},
129
- routes: [
130
- '/',
131
- {
132
- url: '/about',
133
- headers: {},
134
- },
135
- ],
136
- },
137
- },
138
- });
139
- ```
140
-
141
58
  :::info
142
- 路由中设置的 `headers` 会覆盖入口中设置的 `headers`。
143
-
59
+ 更多关于**约定式路由**和**自控式路由**在开启 SSG 后的默认行为,请阅读 [静态站点生成](/guides/basic-features/render/ssg) 。
144
60
  :::
145
61
 
146
- ### 阻止默认行为
62
+ ## Object 类型
147
63
 
148
- 默认情况下,**约定式路由**的路由会全部开启 SSG。Modern.js 提供了另一个字段,用来阻止默认的 SSG 行为。
64
+ 当值类型为 `Object` 时,可以配置如下属性。
149
65
 
150
- 例如以下目录结构,`/`、`/user`、`/user/profle` 三条路由都开启 SSG:
66
+ ### 配置类型
151
67
 
152
- ```bash
153
- .
154
- ├── src
155
- │ └── routes
156
- │ ├── layout.tsx
157
- │ ├── page.tsx
158
- │ └── user
159
- │ ├── layout.tsx
160
- │ ├── page.tsx
161
- │ └── profile
162
- │ └── page.tsx
163
- ```
164
-
165
- 可以这样设置,禁用某一条客户端路由的默认行为:
68
+ ```ts
69
+ type SSGRouteOptions = string | {
70
+ url: string;
71
+ params?: Record<string, any>[];
72
+ headers?: Record<string, any>;
73
+ };
166
74
 
167
- ```js
168
- export default defineConfig({
169
- output: {
170
- ssg: {
171
- preventDefault: ['/user'],
172
- },
173
- },
174
- });
75
+ type SSGOptions = {
76
+ preventDefault?: string[];
77
+ headers?: Record<string, any>;
78
+ routes?: SSGRouteOptions[];
79
+ };
175
80
  ```
176
81
 
177
- ### 添加动态路由参数
82
+ ### 示例
178
83
 
179
- 部分路由可能是动态的,例如自控式路由中的 `/user/:id` 或是约定式路由中 `user/[id]/page.tsx` 文件生成的路由。
84
+ 下面的示例配置中,SSG 会渲染 `/`、`/about` `/user/:id` 三条路由对应的页面。
180
85
 
181
- 可以在 `output.ssg` 中配置具体的参数,渲染指定参数的路由,例如:
86
+ 对于 `/user/:id` 路由,`cookies` 添加到请求头中,同时会将 `params` 中的 `id` 替换为 `modernjs`。
182
87
 
183
- ```js
88
+ ```ts title="modern.config.ts"
184
89
  export default defineConfig({
185
90
  output: {
186
91
  ssg: {
187
92
  routes: [
93
+ '/',
94
+ '/about',
188
95
  {
189
96
  url: '/user/:id',
190
- params: [
191
- {
192
- id: 'modernjs',
193
- },
194
- ],
195
- },
97
+ headers: {
98
+ cookies: "name=modernjs"
99
+ },
100
+ params: [{
101
+ id: 'modernjs',
102
+ }],
103
+ }
196
104
  ],
197
- },
198
- },
105
+ }
106
+ }
199
107
  });
200
108
  ```
201
109
 
202
- 动态路由和 SSG 的组合,在根据 CMS 系统数据变更,实时生成静态页面时非常有用。
110
+ :::note
111
+ 多入口的情况和单入口的配置方式一致,这里不再额外介绍。
112
+ :::
@@ -9,7 +9,7 @@ sidebar_position: 9
9
9
 
10
10
  用于配置自定义的 Modern.js 框架插件。
11
11
 
12
- 自定义插件的编写方式请参考 [如何编写插件](/guides/topic-detail/framework-plugin/implement)。
12
+ 自定义插件的编写方式请参考 [如何编写插件](/plugin/plugin-system/implement)。
13
13
 
14
14
  ## 注意事项
15
15
 
@@ -33,7 +33,7 @@ Modern.js 中内置了三种不同的框架插件:
33
33
 
34
34
  默认情况下,自定义插件会按照 `plugins` 数组的顺序依次执行,Modern.js 内置插件的执行时机早于自定义插件。
35
35
 
36
- 当插件内部使用了控制顺序的相关字段,比如 `pre`、`post` 时,会基于声明的字段对执行顺序进行调整,详见 [插件之间的关系](/guides/topic-detail/framework-plugin/relationship)。
36
+ 当插件内部使用了控制顺序的相关字段,比如 `pre`、`post` 时,会基于声明的字段对执行顺序进行调整,详见 [插件之间的关系](/plugin/plugin-system/relationship)。
37
37
 
38
38
  ## 示例
39
39
 
@@ -41,4 +41,4 @@ export default defineConfig({
41
41
  });
42
42
  ```
43
43
 
44
- 完整配置项请参考 [esbuild 插件配置](/guides/rsbuild-plugins/plugin-esbuild.html#配置)。
44
+ 完整配置项请参考 [esbuild 插件配置](/plugin/rsbuild-plugins/plugin-esbuild#配置)。
@@ -77,4 +77,4 @@ export default defineConfig({
77
77
  });
78
78
  ```
79
79
 
80
- 完整配置项请参考 [SWC 插件配置](/guides/rsbuild-plugins/plugin-swc.html#配置)。
80
+ 完整配置项请参考 [SWC 插件配置](/plugin/cli-plugins/plugin-swc.html#配置)。
@@ -23,7 +23,7 @@ const tailwind = {
23
23
 
24
24
  在使用 `tools.tailwindcss` 之前,你需要启用 Modern.js 的 Tailwind CSS 插件。
25
25
 
26
- 请阅读[「使用 Tailwind CSS」](/guides/basic-features/css.html#使用-tailwind-css) 章节来了解开启方式。
26
+ 请阅读[「使用 Tailwind CSS」](/guides/basic-features/css/tailwindcss) 章节来了解开启方式。
27
27
 
28
28
  ### Function 类型
29
29
 
@@ -24,11 +24,6 @@
24
24
  "name": "topic-detail",
25
25
  "label": "topic"
26
26
  },
27
- {
28
- "type": "dir",
29
- "name": "rsbuild-plugins",
30
- "label": "构建插件"
31
- },
32
27
  {
33
28
  "type": "dir",
34
29
  "name": "troubleshooting",