@modern-js/main-doc 2.69.4 → 3.0.0-alpha.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 (540) hide show
  1. package/docs/en/{_meta.json → _nav.json} +5 -1
  2. package/docs/en/apis/app/commands.mdx +2 -3
  3. package/docs/en/apis/app/hooks/src/entry.mdx +1 -5
  4. package/docs/en/apis/app/hooks/src/entry.server.mdx +4 -5
  5. package/docs/en/apis/app/hooks/src/routes.mdx +2 -2
  6. package/docs/en/apis/app/runtime/_meta.json +0 -18
  7. package/docs/en/apis/app/runtime/bff/use-hono-context.mdx +2 -2
  8. package/docs/en/apis/app/runtime/router/router.mdx +1 -1
  9. package/docs/en/apis/app/runtime/utility/css-in-js.mdx +3 -2
  10. package/docs/en/community/blog/v2-release-note.mdx +0 -2
  11. package/docs/en/community/contributing-guide.mdx +10 -12
  12. package/docs/en/components/bff-upload.mdx +16 -12
  13. package/docs/en/components/build-output.mdx +45 -0
  14. package/docs/en/components/debug-app.mdx +1 -1
  15. package/docs/en/components/enable-bff-caution.mdx +2 -2
  16. package/docs/en/components/enable-bff.mdx +38 -8
  17. package/docs/en/components/enable-ssg.mdx +48 -0
  18. package/docs/en/components/entry-scan-logic.mdx +7 -0
  19. package/docs/en/components/init-app.mdx +40 -17
  20. package/docs/en/components/international/install-command.mdx +9 -0
  21. package/docs/en/components/international/introduce.mdx +2 -0
  22. package/docs/en/components/module-federation.mdx +4 -4
  23. package/docs/en/components/new-entry-tooltip.mdx +0 -0
  24. package/docs/en/components/nodeVersion.mdx +2 -6
  25. package/docs/en/components/prerequisites.mdx +1 -1
  26. package/docs/en/components/ua-polyfill.mdx +16 -12
  27. package/docs/en/components/upgrade-browserslist.mdx +0 -0
  28. package/docs/en/configure/_meta.json +7 -8
  29. package/docs/en/configure/app/bff/cross-project.mdx +24 -0
  30. package/docs/en/configure/app/dev/lazy-compilation.mdx +45 -0
  31. package/docs/en/configure/app/dev/server.mdx +103 -0
  32. package/docs/en/configure/app/dev/setup-middlewares.mdx +4 -22
  33. package/docs/en/configure/app/html/app-icon.mdx +1 -23
  34. package/docs/en/configure/app/output/inline-scripts.mdx +1 -1
  35. package/docs/en/configure/app/output/override-browserslist.mdx +6 -4
  36. package/docs/en/configure/app/output/source-map.mdx +6 -3
  37. package/docs/en/configure/app/output/ssg.mdx +12 -43
  38. package/docs/en/configure/app/output/ssgByEntries.mdx +93 -0
  39. package/docs/en/configure/app/performance/build-cache.mdx +0 -4
  40. package/docs/en/configure/app/resolve/alias-strategy.mdx +14 -0
  41. package/docs/en/configure/app/resolve/alias.mdx +13 -0
  42. package/docs/en/configure/app/resolve/condition-names.mdx +18 -0
  43. package/docs/en/configure/app/resolve/dedupe.mdx +13 -0
  44. package/docs/en/configure/app/resolve/extensions.mdx +18 -0
  45. package/docs/en/configure/app/runtime/0-intro.mdx +2 -51
  46. package/docs/en/configure/app/security/check-syntax.mdx +1 -1
  47. package/docs/en/configure/app/server/port.mdx +1 -21
  48. package/docs/en/configure/app/server/rsc.mdx +30 -0
  49. package/docs/en/configure/app/server/ssr.mdx +20 -9
  50. package/docs/en/configure/app/source/decorators.mdx +4 -2
  51. package/docs/en/configure/app/source/entries.mdx +0 -2
  52. package/docs/en/configure/app/source/main-entry-name.mdx +4 -4
  53. package/docs/en/configure/app/source/transform-import.mdx +1 -59
  54. package/docs/en/configure/app/tools/bundler-chain.mdx +5 -5
  55. package/docs/en/configure/app/tools/css-extract.mdx +1 -1
  56. package/docs/en/configure/app/tools/dev-server.mdx +14 -248
  57. package/docs/en/configure/app/tools/html-plugin.mdx +3 -3
  58. package/docs/en/configure/app/tools/lightningcss-loader.mdx +0 -1
  59. package/docs/en/configure/app/tools/swc.mdx +1 -43
  60. package/docs/en/configure/app/usage.mdx +7 -17
  61. package/docs/en/guides/_meta.json +1 -2
  62. package/docs/en/guides/advanced-features/_meta.json +6 -0
  63. package/docs/en/guides/advanced-features/bff/cross-project.mdx +1 -7
  64. package/docs/en/guides/advanced-features/bff/extend-server.mdx +18 -3
  65. package/docs/en/guides/advanced-features/bff/frameworks.mdx +1 -1
  66. package/docs/en/guides/advanced-features/bff/function.mdx +2 -6
  67. package/docs/en/guides/advanced-features/bff/sdk.mdx +3 -3
  68. package/docs/en/guides/advanced-features/build-performance.mdx +23 -26
  69. package/docs/en/guides/advanced-features/compatibility.mdx +53 -9
  70. package/docs/en/guides/advanced-features/international/_meta.json +11 -0
  71. package/docs/en/guides/advanced-features/international/advanced.mdx +193 -0
  72. package/docs/en/guides/advanced-features/international/api.mdx +400 -0
  73. package/docs/en/guides/advanced-features/international/basic.mdx +417 -0
  74. package/docs/en/guides/advanced-features/international/best-practices.mdx +135 -0
  75. package/docs/en/guides/advanced-features/international/configuration.mdx +437 -0
  76. package/docs/en/guides/advanced-features/international/locale-detection.mdx +276 -0
  77. package/docs/en/guides/advanced-features/international/quick-start.mdx +154 -0
  78. package/docs/en/guides/advanced-features/international/resource-loading.mdx +417 -0
  79. package/docs/en/guides/advanced-features/international/routing.mdx +212 -0
  80. package/docs/en/guides/advanced-features/international.mdx +37 -0
  81. package/docs/en/guides/advanced-features/low-level.mdx +21 -16
  82. package/docs/en/guides/advanced-features/page-performance/code-split.mdx +4 -4
  83. package/docs/en/guides/advanced-features/page-performance/inline-assets.mdx +4 -4
  84. package/docs/en/guides/advanced-features/page-performance/optimize-bundle.mdx +7 -21
  85. package/docs/en/guides/advanced-features/page-performance/react-compiler.mdx +1 -8
  86. package/docs/en/guides/advanced-features/rspack-start.mdx +2 -22
  87. package/docs/en/guides/advanced-features/server-monitor/logger.mdx +0 -4
  88. package/docs/en/guides/advanced-features/server-monitor/monitors.mdx +62 -34
  89. package/docs/en/guides/advanced-features/web-server.mdx +82 -299
  90. package/docs/en/guides/basic-features/_meta.json +6 -1
  91. package/docs/en/guides/basic-features/css/css-in-js.mdx +46 -11
  92. package/docs/en/guides/basic-features/css/css-modules.mdx +5 -17
  93. package/docs/en/guides/basic-features/css/css.mdx +3 -3
  94. package/docs/en/guides/basic-features/css/tailwindcss.mdx +5 -89
  95. package/docs/en/guides/basic-features/data/data-cache.mdx +5 -1
  96. package/docs/en/guides/basic-features/data/data-fetch.mdx +4 -4
  97. package/docs/en/guides/basic-features/data/data-write.mdx +2 -2
  98. package/docs/en/guides/basic-features/debug/mock.mdx +4 -1
  99. package/docs/en/guides/basic-features/debug/proxy.mdx +0 -8
  100. package/docs/en/guides/basic-features/debug/rsdoctor.mdx +5 -5
  101. package/docs/en/guides/basic-features/deploy.mdx +25 -18
  102. package/docs/en/guides/basic-features/env-vars.mdx +1 -1
  103. package/docs/en/guides/basic-features/html.mdx +1 -1
  104. package/docs/en/guides/basic-features/output-files.mdx +3 -3
  105. package/docs/en/guides/basic-features/render/_meta.json +1 -1
  106. package/docs/en/guides/basic-features/render/before-render.mdx +16 -23
  107. package/docs/en/guides/basic-features/render/overview.mdx +51 -0
  108. package/docs/en/guides/basic-features/render/rsc.mdx +394 -0
  109. package/docs/en/guides/basic-features/render/ssg.mdx +26 -62
  110. package/docs/en/guides/basic-features/render/ssr-cache.mdx +6 -6
  111. package/docs/en/guides/basic-features/render/ssr.mdx +31 -31
  112. package/docs/en/guides/basic-features/render/streaming-ssr.mdx +29 -9
  113. package/docs/en/guides/basic-features/routes/_meta.json +1 -0
  114. package/docs/en/guides/basic-features/routes/config-routes.mdx +427 -0
  115. package/docs/en/guides/basic-features/{routes.mdx → routes/routes.mdx} +7 -110
  116. package/docs/en/guides/basic-features/static-assets/json-files.mdx +21 -3
  117. package/docs/en/guides/basic-features/static-assets.mdx +2 -2
  118. package/docs/en/guides/concept/builder.mdx +24 -9
  119. package/docs/en/guides/concept/entries.mdx +139 -147
  120. package/docs/en/guides/get-started/glossary.mdx +0 -18
  121. package/docs/en/guides/get-started/introduction.mdx +1 -4
  122. package/docs/en/guides/get-started/quick-start.mdx +8 -73
  123. package/docs/en/guides/get-started/tech-stack.mdx +7 -25
  124. package/docs/en/guides/get-started/upgrade.mdx +30 -23
  125. package/docs/en/guides/topic-detail/_meta.json +0 -12
  126. package/docs/en/guides/topic-detail/module-federation/_meta.json +1 -1
  127. package/docs/en/guides/topic-detail/module-federation/application.mdx +16 -15
  128. package/docs/en/guides/topic-detail/module-federation/i18n.mdx +670 -0
  129. package/docs/en/guides/topic-detail/module-federation/introduce.mdx +5 -4
  130. package/docs/en/guides/topic-detail/module-federation/ssr.mdx +50 -2
  131. package/docs/en/guides/topic-detail/module-federation/usage.mdx +10 -30
  132. package/docs/en/guides/troubleshooting/builder.mdx +3 -82
  133. package/docs/en/guides/troubleshooting/cli.mdx +6 -30
  134. package/docs/en/guides/troubleshooting/dependencies.mdx +22 -22
  135. package/docs/en/plugin/cli-plugins/api.mdx +4 -5
  136. package/docs/en/plugin/cli-plugins/migration.mdx +33 -48
  137. package/docs/en/plugin/introduction.mdx +39 -27
  138. package/docs/en/plugin/official/_meta.json +0 -5
  139. package/docs/en/plugin/official/cli-plugins/_meta.json +1 -1
  140. package/docs/en/plugin/official/cli-plugins/plugin-styled-components.mdx +5 -0
  141. package/docs/en/plugin/official/cli-plugins.mdx +0 -2
  142. package/docs/en/plugin/plugin-system.mdx +68 -61
  143. package/docs/en/plugin/runtime-plugins/api.mdx +62 -59
  144. package/docs/en/plugin/runtime-plugins/migration.mdx +29 -20
  145. package/docs/en/tutorials/_meta.json +0 -10
  146. package/docs/en/tutorials/examples/csr-auth.mdx +1 -1
  147. package/docs/en/tutorials/foundations/introduction.mdx +9 -25
  148. package/docs/zh/{_meta.json → _nav.json} +10 -6
  149. package/docs/zh/apis/app/commands.mdx +2 -3
  150. package/docs/zh/apis/app/hooks/src/entry.mdx +1 -5
  151. package/docs/zh/apis/app/hooks/src/entry.server.mdx +4 -5
  152. package/docs/zh/apis/app/hooks/src/routes.mdx +2 -2
  153. package/docs/zh/apis/app/runtime/_meta.json +0 -18
  154. package/docs/zh/apis/app/runtime/bff/use-hono-context.mdx +2 -2
  155. package/docs/zh/apis/app/runtime/utility/css-in-js.mdx +3 -2
  156. package/docs/zh/community/blog/v2-release-note.mdx +0 -2
  157. package/docs/zh/community/contributing-guide.mdx +10 -12
  158. package/docs/zh/components/auto-upgrade.mdx +0 -0
  159. package/docs/zh/components/bff-upload.mdx +8 -5
  160. package/docs/zh/components/build-output.mdx +45 -0
  161. package/docs/zh/components/debug-app.mdx +1 -1
  162. package/docs/zh/components/enable-bff-caution.mdx +1 -1
  163. package/docs/zh/components/enable-bff.mdx +37 -8
  164. package/docs/zh/components/enable-ssg.mdx +47 -0
  165. package/docs/zh/components/entry-scan-logic.mdx +7 -0
  166. package/docs/zh/components/init-app.mdx +40 -18
  167. package/docs/zh/components/international/install-command.mdx +8 -0
  168. package/docs/zh/components/international/introduce.mdx +2 -0
  169. package/docs/zh/components/international/platform-support.mdx +0 -0
  170. package/docs/zh/components/module-federation.mdx +4 -4
  171. package/docs/zh/components/new-entry-tooltip.mdx +0 -0
  172. package/docs/zh/components/nodeVersion.mdx +3 -7
  173. package/docs/zh/components/prerequisites.mdx +1 -1
  174. package/docs/zh/components/self-route-example.mdx +3 -3
  175. package/docs/zh/components/ua-polyfill.mdx +11 -6
  176. package/docs/zh/components/upgrade-browserslist.mdx +0 -0
  177. package/docs/zh/configure/_meta.json +7 -8
  178. package/docs/zh/configure/app/bff/cross-project.mdx +24 -0
  179. package/docs/zh/configure/app/dev/lazy-compilation.mdx +44 -0
  180. package/docs/zh/configure/app/dev/server.mdx +104 -0
  181. package/docs/zh/configure/app/dev/setup-middlewares.mdx +4 -23
  182. package/docs/zh/configure/app/html/app-icon.mdx +1 -23
  183. package/docs/zh/configure/app/output/inline-scripts.mdx +1 -1
  184. package/docs/zh/configure/app/output/override-browserslist.mdx +3 -3
  185. package/docs/zh/configure/app/output/source-map.mdx +10 -3
  186. package/docs/zh/configure/app/output/ssg.mdx +13 -45
  187. package/docs/zh/configure/app/output/ssgByEntries.mdx +94 -0
  188. package/docs/zh/configure/app/performance/build-cache.mdx +0 -4
  189. package/docs/zh/configure/app/resolve/alias-strategy.mdx +14 -0
  190. package/docs/zh/configure/app/resolve/alias.mdx +13 -0
  191. package/docs/zh/configure/app/resolve/condition-names.mdx +18 -0
  192. package/docs/zh/configure/app/resolve/dedupe.mdx +14 -0
  193. package/docs/zh/configure/app/resolve/extensions.mdx +18 -0
  194. package/docs/zh/configure/app/runtime/0-intro.mdx +2 -53
  195. package/docs/zh/configure/app/security/check-syntax.mdx +1 -1
  196. package/docs/zh/configure/app/server/port.mdx +2 -21
  197. package/docs/zh/configure/app/server/rsc.mdx +30 -0
  198. package/docs/zh/configure/app/server/ssr.mdx +21 -11
  199. package/docs/zh/configure/app/source/decorators.mdx +4 -4
  200. package/docs/zh/configure/app/source/entries.mdx +0 -2
  201. package/docs/zh/configure/app/source/main-entry-name.mdx +4 -4
  202. package/docs/zh/configure/app/source/transform-import.mdx +1 -59
  203. package/docs/zh/configure/app/tools/bundler-chain.mdx +6 -6
  204. package/docs/zh/configure/app/tools/css-extract.mdx +1 -1
  205. package/docs/zh/configure/app/tools/dev-server.mdx +14 -248
  206. package/docs/zh/configure/app/tools/html-plugin.mdx +3 -2
  207. package/docs/zh/configure/app/tools/lightningcss-loader.mdx +0 -1
  208. package/docs/zh/configure/app/tools/swc.mdx +1 -43
  209. package/docs/zh/configure/app/usage.mdx +8 -18
  210. package/docs/zh/guides/_meta.json +5 -1
  211. package/docs/zh/guides/advanced-features/_meta.json +6 -1
  212. package/docs/zh/guides/advanced-features/bff/cross-project.mdx +8 -16
  213. package/docs/zh/guides/advanced-features/bff/extend-server.mdx +25 -8
  214. package/docs/zh/guides/advanced-features/bff/frameworks.mdx +1 -1
  215. package/docs/zh/guides/advanced-features/bff/function.mdx +7 -12
  216. package/docs/zh/guides/advanced-features/bff/sdk.mdx +4 -4
  217. package/docs/zh/guides/advanced-features/build-performance.mdx +23 -30
  218. package/docs/zh/guides/advanced-features/compatibility.mdx +44 -0
  219. package/docs/zh/guides/advanced-features/international/_meta.json +11 -0
  220. package/docs/zh/guides/advanced-features/international/advanced.mdx +193 -0
  221. package/docs/zh/guides/advanced-features/international/api.mdx +400 -0
  222. package/docs/zh/guides/advanced-features/international/basic.mdx +416 -0
  223. package/docs/zh/guides/advanced-features/international/best-practices.mdx +135 -0
  224. package/docs/zh/guides/advanced-features/international/configuration.mdx +441 -0
  225. package/docs/zh/guides/advanced-features/international/locale-detection.mdx +304 -0
  226. package/docs/zh/guides/advanced-features/international/quick-start.mdx +149 -0
  227. package/docs/zh/guides/advanced-features/international/resource-loading.mdx +417 -0
  228. package/docs/zh/guides/advanced-features/international/routing.mdx +212 -0
  229. package/docs/zh/guides/advanced-features/international.mdx +36 -0
  230. package/docs/zh/guides/advanced-features/low-level.mdx +21 -16
  231. package/docs/zh/guides/advanced-features/page-performance/code-split.mdx +3 -3
  232. package/docs/zh/guides/advanced-features/page-performance/inline-assets.mdx +4 -4
  233. package/docs/zh/guides/advanced-features/page-performance/optimize-bundle.mdx +7 -21
  234. package/docs/zh/guides/advanced-features/page-performance/react-compiler.mdx +1 -8
  235. package/docs/zh/guides/advanced-features/server-monitor/logger.mdx +0 -4
  236. package/docs/zh/guides/advanced-features/server-monitor/monitors.mdx +63 -35
  237. package/docs/zh/guides/advanced-features/web-server.mdx +79 -300
  238. package/docs/zh/guides/basic-features/_meta.json +6 -1
  239. package/docs/zh/guides/basic-features/css/css-in-js.mdx +40 -5
  240. package/docs/zh/guides/basic-features/css/css-modules.mdx +6 -17
  241. package/docs/zh/guides/basic-features/css/css.mdx +2 -2
  242. package/docs/zh/guides/basic-features/css/tailwindcss.mdx +6 -90
  243. package/docs/zh/guides/basic-features/data/data-cache.mdx +8 -5
  244. package/docs/zh/guides/basic-features/data/data-fetch.mdx +6 -5
  245. package/docs/zh/guides/basic-features/data/data-write.mdx +4 -4
  246. package/docs/zh/guides/basic-features/debug/mock.mdx +4 -1
  247. package/docs/zh/guides/basic-features/debug/proxy.mdx +0 -8
  248. package/docs/zh/guides/basic-features/debug/rsdoctor.mdx +6 -6
  249. package/docs/zh/guides/basic-features/deploy.mdx +24 -20
  250. package/docs/zh/guides/basic-features/env-vars.mdx +1 -1
  251. package/docs/zh/guides/basic-features/html.mdx +2 -2
  252. package/docs/zh/guides/basic-features/output-files.mdx +3 -3
  253. package/docs/zh/guides/basic-features/render/_meta.json +1 -1
  254. package/docs/zh/guides/basic-features/render/before-render.mdx +17 -24
  255. package/docs/zh/guides/basic-features/render/overview.mdx +52 -0
  256. package/docs/zh/guides/basic-features/render/rsc.mdx +413 -0
  257. package/docs/zh/guides/basic-features/render/ssg.mdx +27 -69
  258. package/docs/zh/guides/basic-features/render/ssr-cache.mdx +5 -5
  259. package/docs/zh/guides/basic-features/render/ssr.mdx +34 -31
  260. package/docs/zh/guides/basic-features/render/streaming-ssr.mdx +34 -14
  261. package/docs/zh/guides/basic-features/routes/_meta.json +1 -0
  262. package/docs/zh/guides/basic-features/routes/config-routes.mdx +426 -0
  263. package/docs/zh/guides/basic-features/{routes.mdx → routes/routes.mdx} +8 -114
  264. package/docs/zh/guides/basic-features/static-assets/json-files.mdx +21 -3
  265. package/docs/zh/guides/basic-features/static-assets.mdx +2 -2
  266. package/docs/zh/guides/basic-features/testing/cypress.mdx +5 -5
  267. package/docs/zh/guides/basic-features/testing/jest.mdx +12 -12
  268. package/docs/zh/guides/concept/builder.mdx +24 -9
  269. package/docs/zh/guides/concept/entries.mdx +95 -92
  270. package/docs/zh/guides/get-started/glossary.mdx +0 -18
  271. package/docs/zh/guides/get-started/introduction.mdx +1 -5
  272. package/docs/zh/guides/get-started/quick-start.mdx +5 -72
  273. package/docs/zh/guides/get-started/tech-stack.mdx +8 -26
  274. package/docs/zh/guides/get-started/upgrade.mdx +30 -23
  275. package/docs/zh/guides/topic-detail/_meta.json +0 -12
  276. package/docs/zh/guides/topic-detail/module-federation/_meta.json +1 -1
  277. package/docs/zh/guides/topic-detail/module-federation/application.mdx +18 -16
  278. package/docs/zh/guides/topic-detail/module-federation/i18n.mdx +623 -0
  279. package/docs/zh/guides/topic-detail/module-federation/introduce.mdx +4 -4
  280. package/docs/zh/guides/topic-detail/module-federation/ssr.mdx +51 -5
  281. package/docs/zh/guides/topic-detail/module-federation/usage.mdx +11 -32
  282. package/docs/zh/guides/troubleshooting/builder.mdx +3 -84
  283. package/docs/zh/guides/troubleshooting/cli.mdx +6 -30
  284. package/docs/zh/guides/troubleshooting/dependencies.mdx +23 -23
  285. package/docs/zh/guides/upgrade/_meta.json +1 -0
  286. package/docs/zh/guides/upgrade/config.mdx +809 -0
  287. package/docs/zh/guides/upgrade/entry.mdx +463 -0
  288. package/docs/zh/guides/upgrade/other.md +90 -0
  289. package/docs/zh/guides/upgrade/overview.mdx +36 -0
  290. package/docs/zh/guides/upgrade/tailwindcss.mdx +130 -0
  291. package/docs/zh/guides/upgrade/web-server.md +93 -0
  292. package/docs/zh/plugin/cli-plugins/api.mdx +4 -5
  293. package/docs/zh/plugin/cli-plugins/migration.mdx +30 -45
  294. package/docs/zh/plugin/introduction.mdx +36 -24
  295. package/docs/zh/plugin/official/_meta.json +0 -5
  296. package/docs/zh/plugin/official/cli-plugins/_meta.json +1 -1
  297. package/docs/zh/plugin/official/cli-plugins/plugin-styled-components.mdx +5 -0
  298. package/docs/zh/plugin/official/cli-plugins.mdx +0 -2
  299. package/docs/zh/plugin/plugin-system.mdx +45 -42
  300. package/docs/zh/plugin/runtime-plugins/api.mdx +58 -56
  301. package/docs/zh/plugin/runtime-plugins/migration.mdx +26 -17
  302. package/docs/zh/tutorials/_meta.json +0 -10
  303. package/docs/zh/tutorials/examples/csr-auth.mdx +1 -1
  304. package/docs/zh/tutorials/foundations/introduction.mdx +8 -25
  305. package/i18n.json +0 -16
  306. package/package.json +12 -12
  307. package/rspress.config.ts +5 -8
  308. package/src/components/ContentCard/index.module.scss +11 -7
  309. package/src/components/ContentCard/index.tsx +1 -1
  310. package/src/components/FeatureLayout/index.module.css +1 -1
  311. package/src/components/Footer/index.tsx +2 -14
  312. package/src/components/Footer/styles.module.scss +5 -5
  313. package/src/components/ListCard/index.tsx +1 -1
  314. package/src/components/RandomMemberList/index.tsx +1 -1
  315. package/src/components/RsbuildLink/index.tsx +1 -1
  316. package/src/components/Sandpack/index.tsx +1 -1
  317. package/src/custom.scss +15 -0
  318. package/src/i18n/enUS.ts +2 -4
  319. package/src/i18n/index.ts +1 -1
  320. package/src/i18n/zhCN.ts +2 -4
  321. package/src/index.ts +2 -1
  322. package/src/pages/index.module.scss +59 -41
  323. package/src/pages/index.tsx +9 -24
  324. package/docs/en/apis/app/hooks/server/index_.mdx +0 -10
  325. package/docs/en/apis/app/hooks/src/index_.mdx +0 -38
  326. package/docs/en/apis/app/hooks/src/stories.mdx +0 -16
  327. package/docs/en/apis/app/runtime/app/define-config.mdx +0 -67
  328. package/docs/en/apis/app/runtime/core/bootstrap.mdx +0 -74
  329. package/docs/en/apis/app/runtime/core/create-app.mdx +0 -49
  330. package/docs/en/apis/app/runtime/core/use-loader.mdx +0 -89
  331. package/docs/en/apis/app/runtime/core/use-module-apps.mdx +0 -140
  332. package/docs/en/apis/app/runtime/core/use-runtime-context.mdx +0 -116
  333. package/docs/en/apis/app/runtime/model/Provider.mdx +0 -36
  334. package/docs/en/apis/app/runtime/model/auto-actions.mdx +0 -122
  335. package/docs/en/apis/app/runtime/model/connect.mdx +0 -146
  336. package/docs/en/apis/app/runtime/model/create-app.mdx +0 -75
  337. package/docs/en/apis/app/runtime/model/create-store.mdx +0 -61
  338. package/docs/en/apis/app/runtime/model/handle-effect.mdx +0 -107
  339. package/docs/en/apis/app/runtime/model/model_.mdx +0 -198
  340. package/docs/en/apis/app/runtime/model/use-local-model.mdx +0 -29
  341. package/docs/en/apis/app/runtime/model/use-model.mdx +0 -89
  342. package/docs/en/apis/app/runtime/model/use-static-model.mdx +0 -51
  343. package/docs/en/apis/app/runtime/model/use-store.mdx +0 -26
  344. package/docs/en/apis/app/runtime/ssr/pre-render.mdx +0 -96
  345. package/docs/en/apis/app/runtime/web-server/hook.mdx +0 -134
  346. package/docs/en/apis/app/runtime/web-server/middleware.mdx +0 -113
  347. package/docs/en/apis/app/runtime/web-server/unstable_middleware.mdx +0 -167
  348. package/docs/en/components/bff-proxy-path-rewrite.mdx +0 -16
  349. package/docs/en/components/bff-proxy-principle.mdx +0 -1
  350. package/docs/en/components/builder.mdx +0 -3
  351. package/docs/en/components/create-bff-api-app.mdx +0 -25
  352. package/docs/en/components/custom-router-micro-frontend.mdx +0 -40
  353. package/docs/en/components/enable-micro-frontend.mdx +0 -30
  354. package/docs/en/components/enableSwc.mdx +0 -17
  355. package/docs/en/components/global-proxy-config.mdx +0 -85
  356. package/docs/en/components/global-proxy.mdx +0 -29
  357. package/docs/en/components/package-manager.mdx +0 -11
  358. package/docs/en/components/reduck-notify.mdx +0 -27
  359. package/docs/en/components/reduck-tip.mdx +0 -8
  360. package/docs/en/configure/app/auto-load-plugin.mdx +0 -66
  361. package/docs/en/configure/app/deploy/microFrontend.mdx +0 -53
  362. package/docs/en/configure/app/dev/port.mdx +0 -25
  363. package/docs/en/configure/app/dev/proxy.mdx +0 -9
  364. package/docs/en/configure/app/experiments/lazy-compilation.mdx +0 -106
  365. package/docs/en/configure/app/html/disable-html-folder.mdx +0 -46
  366. package/docs/en/configure/app/html/favicon-by-entries.mdx +0 -36
  367. package/docs/en/configure/app/html/inject-by-entries.mdx +0 -36
  368. package/docs/en/configure/app/html/meta-by-entries.mdx +0 -48
  369. package/docs/en/configure/app/html/tags-by-entries.mdx +0 -44
  370. package/docs/en/configure/app/html/template-by-entries.mdx +0 -33
  371. package/docs/en/configure/app/html/template-parameters-by-entries.mdx +0 -35
  372. package/docs/en/configure/app/html/title-by-entries.mdx +0 -37
  373. package/docs/en/configure/app/output/css-module-local-ident-name.mdx +0 -21
  374. package/docs/en/configure/app/output/disable-css-extract.mdx +0 -16
  375. package/docs/en/configure/app/output/disable-filename-hash.mdx +0 -16
  376. package/docs/en/configure/app/output/disable-minimize.mdx +0 -14
  377. package/docs/en/configure/app/output/disable-node-polyfill.mdx +0 -22
  378. package/docs/en/configure/app/output/disable-source-map.mdx +0 -31
  379. package/docs/en/configure/app/output/enable-asset-fallback.mdx +0 -36
  380. package/docs/en/configure/app/output/enable-inline-scripts.mdx +0 -22
  381. package/docs/en/configure/app/output/enable-inline-styles.mdx +0 -22
  382. package/docs/en/configure/app/output/enable-latest-decorators.mdx +0 -14
  383. package/docs/en/configure/app/performance/transform-lodash.mdx +0 -52
  384. package/docs/en/configure/app/runtime/master-app.mdx +0 -36
  385. package/docs/en/configure/app/runtime/state.mdx +0 -52
  386. package/docs/en/configure/app/source/disable-entry-dirs.mdx +0 -38
  387. package/docs/en/configure/app/source/enable-custom-entry.mdx +0 -68
  388. package/docs/en/configure/app/source/module-scopes.mdx +0 -72
  389. package/docs/en/configure/app/source/resolve-extension-prefix.mdx +0 -55
  390. package/docs/en/configure/app/source/resolve-main-fields.mdx +0 -46
  391. package/docs/en/configure/app/tools/esbuild.mdx +0 -44
  392. package/docs/en/configure/app/tools/pug.mdx +0 -54
  393. package/docs/en/configure/app/tools/styled-components.mdx +0 -55
  394. package/docs/en/configure/app/tools/tailwindcss.mdx +0 -98
  395. package/docs/en/configure/app/tools/terser.mdx +0 -58
  396. package/docs/en/configure/app/tools/ts-loader.mdx +0 -76
  397. package/docs/en/configure/app/tools/webpack-chain.mdx +0 -249
  398. package/docs/en/configure/app/tools/webpack.mdx +0 -305
  399. package/docs/en/guides/deprecated.md +0 -17
  400. package/docs/en/guides/topic-detail/micro-frontend/c01-introduction.mdx +0 -27
  401. package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +0 -290
  402. package/docs/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +0 -298
  403. package/docs/en/guides/topic-detail/micro-frontend/c04-communicate.mdx +0 -58
  404. package/docs/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +0 -26
  405. package/docs/en/guides/topic-detail/model/_meta.json +0 -14
  406. package/docs/en/guides/topic-detail/model/auto-actions.mdx +0 -85
  407. package/docs/en/guides/topic-detail/model/computed-state.mdx +0 -148
  408. package/docs/en/guides/topic-detail/model/define-model.mdx +0 -62
  409. package/docs/en/guides/topic-detail/model/faq.mdx +0 -35
  410. package/docs/en/guides/topic-detail/model/manage-effects.mdx +0 -247
  411. package/docs/en/guides/topic-detail/model/model-communicate.mdx +0 -217
  412. package/docs/en/guides/topic-detail/model/performance.mdx +0 -167
  413. package/docs/en/guides/topic-detail/model/quick-start.mdx +0 -117
  414. package/docs/en/guides/topic-detail/model/redux-integration.mdx +0 -20
  415. package/docs/en/guides/topic-detail/model/typescript-best-practice.mdx +0 -68
  416. package/docs/en/guides/topic-detail/model/use-model.mdx +0 -243
  417. package/docs/en/guides/topic-detail/model/use-out-of-modernjs.mdx +0 -46
  418. package/docs/en/plugin/official/cli-plugins/plugin-swc.mdx +0 -363
  419. package/docs/en/plugin/official/cli-plugins/plugin-tailwind.mdx +0 -5
  420. package/docs/en/plugin/official/rsbuild-plugins/_meta.json +0 -1
  421. package/docs/en/plugin/official/rsbuild-plugins/plugin-esbuild.mdx +0 -205
  422. package/docs/en/plugin/official/rsbuild-plugins.mdx +0 -3
  423. package/docs/en/tutorials/first-app/c01-start.mdx +0 -99
  424. package/docs/en/tutorials/first-app/c02-component.mdx +0 -60
  425. package/docs/en/tutorials/first-app/c03-css.mdx +0 -324
  426. package/docs/en/tutorials/first-app/c04-routes.mdx +0 -172
  427. package/docs/en/tutorials/first-app/c05-loader.mdx +0 -87
  428. package/docs/en/tutorials/first-app/c06-model.mdx +0 -278
  429. package/docs/en/tutorials/first-app/c07-container.mdx +0 -281
  430. package/docs/en/tutorials/first-app/c08-entries.mdx +0 -135
  431. package/docs/zh/apis/app/hooks/server/index_.mdx +0 -10
  432. package/docs/zh/apis/app/hooks/src/index_.mdx +0 -39
  433. package/docs/zh/apis/app/hooks/src/stories.mdx +0 -16
  434. package/docs/zh/apis/app/runtime/app/define-config.mdx +0 -67
  435. package/docs/zh/apis/app/runtime/core/bootstrap.mdx +0 -74
  436. package/docs/zh/apis/app/runtime/core/create-app.mdx +0 -35
  437. package/docs/zh/apis/app/runtime/core/use-loader.mdx +0 -89
  438. package/docs/zh/apis/app/runtime/core/use-module-apps.mdx +0 -179
  439. package/docs/zh/apis/app/runtime/core/use-runtime-context.mdx +0 -116
  440. package/docs/zh/apis/app/runtime/model/Provider.mdx +0 -36
  441. package/docs/zh/apis/app/runtime/model/auto-actions.mdx +0 -122
  442. package/docs/zh/apis/app/runtime/model/connect.mdx +0 -143
  443. package/docs/zh/apis/app/runtime/model/create-app.mdx +0 -75
  444. package/docs/zh/apis/app/runtime/model/create-store.mdx +0 -61
  445. package/docs/zh/apis/app/runtime/model/handle-effect.mdx +0 -108
  446. package/docs/zh/apis/app/runtime/model/model_.mdx +0 -201
  447. package/docs/zh/apis/app/runtime/model/use-local-model.mdx +0 -29
  448. package/docs/zh/apis/app/runtime/model/use-model.mdx +0 -89
  449. package/docs/zh/apis/app/runtime/model/use-static-model.mdx +0 -49
  450. package/docs/zh/apis/app/runtime/model/use-store.mdx +0 -26
  451. package/docs/zh/apis/app/runtime/ssr/pre-render.mdx +0 -96
  452. package/docs/zh/apis/app/runtime/web-server/hook.mdx +0 -136
  453. package/docs/zh/apis/app/runtime/web-server/middleware.mdx +0 -114
  454. package/docs/zh/apis/app/runtime/web-server/unstable_middleware.mdx +0 -165
  455. package/docs/zh/components/bff-proxy-path-rewrite.mdx +0 -16
  456. package/docs/zh/components/bff-proxy-principle.mdx +0 -1
  457. package/docs/zh/components/builder.mdx +0 -3
  458. package/docs/zh/components/create-bff-api-app.mdx +0 -25
  459. package/docs/zh/components/custom-router-micro-frontend.mdx +0 -40
  460. package/docs/zh/components/enable-micro-frontend.mdx +0 -30
  461. package/docs/zh/components/enableSwc.mdx +0 -17
  462. package/docs/zh/components/global-proxy-config.mdx +0 -85
  463. package/docs/zh/components/global-proxy.mdx +0 -29
  464. package/docs/zh/components/package-manager.mdx +0 -11
  465. package/docs/zh/components/reduck-notify.mdx +0 -27
  466. package/docs/zh/components/reduck-tip.mdx +0 -8
  467. package/docs/zh/configure/app/auto-load-plugin.mdx +0 -66
  468. package/docs/zh/configure/app/deploy/microFrontend.mdx +0 -55
  469. package/docs/zh/configure/app/dev/port.mdx +0 -25
  470. package/docs/zh/configure/app/dev/proxy.mdx +0 -9
  471. package/docs/zh/configure/app/experiments/lazy-compilation.mdx +0 -105
  472. package/docs/zh/configure/app/html/disable-html-folder.mdx +0 -45
  473. package/docs/zh/configure/app/html/favicon-by-entries.mdx +0 -37
  474. package/docs/zh/configure/app/html/inject-by-entries.mdx +0 -37
  475. package/docs/zh/configure/app/html/meta-by-entries.mdx +0 -48
  476. package/docs/zh/configure/app/html/tags-by-entries.mdx +0 -44
  477. package/docs/zh/configure/app/html/template-by-entries.mdx +0 -33
  478. package/docs/zh/configure/app/html/template-parameters-by-entries.mdx +0 -36
  479. package/docs/zh/configure/app/html/title-by-entries.mdx +0 -37
  480. package/docs/zh/configure/app/output/css-module-local-ident-name.mdx +0 -21
  481. package/docs/zh/configure/app/output/disable-css-extract.mdx +0 -16
  482. package/docs/zh/configure/app/output/disable-filename-hash.mdx +0 -16
  483. package/docs/zh/configure/app/output/disable-minimize.mdx +0 -14
  484. package/docs/zh/configure/app/output/disable-node-polyfill.mdx +0 -22
  485. package/docs/zh/configure/app/output/disable-source-map.mdx +0 -31
  486. package/docs/zh/configure/app/output/enable-asset-fallback.mdx +0 -36
  487. package/docs/zh/configure/app/output/enable-inline-scripts.mdx +0 -22
  488. package/docs/zh/configure/app/output/enable-inline-styles.mdx +0 -22
  489. package/docs/zh/configure/app/output/enable-latest-decorators.mdx +0 -14
  490. package/docs/zh/configure/app/performance/transform-lodash.mdx +0 -52
  491. package/docs/zh/configure/app/runtime/master-app.mdx +0 -38
  492. package/docs/zh/configure/app/runtime/state.mdx +0 -52
  493. package/docs/zh/configure/app/source/disable-entry-dirs.mdx +0 -38
  494. package/docs/zh/configure/app/source/enable-custom-entry.mdx +0 -67
  495. package/docs/zh/configure/app/source/module-scopes.mdx +0 -72
  496. package/docs/zh/configure/app/source/resolve-extension-prefix.mdx +0 -57
  497. package/docs/zh/configure/app/source/resolve-main-fields.mdx +0 -46
  498. package/docs/zh/configure/app/tools/esbuild.mdx +0 -44
  499. package/docs/zh/configure/app/tools/pug.mdx +0 -54
  500. package/docs/zh/configure/app/tools/styled-components.mdx +0 -54
  501. package/docs/zh/configure/app/tools/tailwindcss.mdx +0 -98
  502. package/docs/zh/configure/app/tools/terser.mdx +0 -58
  503. package/docs/zh/configure/app/tools/ts-loader.mdx +0 -76
  504. package/docs/zh/configure/app/tools/webpack-chain.mdx +0 -253
  505. package/docs/zh/configure/app/tools/webpack.mdx +0 -305
  506. package/docs/zh/guides/advanced-features/rspack-start.mdx +0 -154
  507. package/docs/zh/guides/deprecated.md +0 -19
  508. package/docs/zh/guides/topic-detail/micro-frontend/c01-introduction.mdx +0 -26
  509. package/docs/zh/guides/topic-detail/micro-frontend/c02-development.mdx +0 -332
  510. package/docs/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +0 -296
  511. package/docs/zh/guides/topic-detail/micro-frontend/c04-communicate.mdx +0 -58
  512. package/docs/zh/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +0 -27
  513. package/docs/zh/guides/topic-detail/model/_meta.json +0 -14
  514. package/docs/zh/guides/topic-detail/model/auto-actions.mdx +0 -88
  515. package/docs/zh/guides/topic-detail/model/computed-state.mdx +0 -147
  516. package/docs/zh/guides/topic-detail/model/define-model.mdx +0 -63
  517. package/docs/zh/guides/topic-detail/model/faq.mdx +0 -36
  518. package/docs/zh/guides/topic-detail/model/manage-effects.mdx +0 -256
  519. package/docs/zh/guides/topic-detail/model/model-communicate.mdx +0 -217
  520. package/docs/zh/guides/topic-detail/model/performance.mdx +0 -167
  521. package/docs/zh/guides/topic-detail/model/quick-start.mdx +0 -117
  522. package/docs/zh/guides/topic-detail/model/redux-integration.mdx +0 -20
  523. package/docs/zh/guides/topic-detail/model/typescript-best-practice.mdx +0 -67
  524. package/docs/zh/guides/topic-detail/model/use-model.mdx +0 -248
  525. package/docs/zh/guides/topic-detail/model/use-out-of-modernjs.mdx +0 -46
  526. package/docs/zh/plugin/official/cli-plugins/plugin-swc.mdx +0 -351
  527. package/docs/zh/plugin/official/cli-plugins/plugin-tailwind.mdx +0 -5
  528. package/docs/zh/plugin/official/rsbuild-plugins/_meta.json +0 -1
  529. package/docs/zh/plugin/official/rsbuild-plugins/plugin-esbuild.mdx +0 -201
  530. package/docs/zh/plugin/official/rsbuild-plugins.mdx +0 -3
  531. package/docs/zh/tutorials/first-app/c01-start.mdx +0 -99
  532. package/docs/zh/tutorials/first-app/c02-component.mdx +0 -60
  533. package/docs/zh/tutorials/first-app/c03-css.mdx +0 -323
  534. package/docs/zh/tutorials/first-app/c04-routes.mdx +0 -172
  535. package/docs/zh/tutorials/first-app/c05-loader.mdx +0 -89
  536. package/docs/zh/tutorials/first-app/c06-model.mdx +0 -274
  537. package/docs/zh/tutorials/first-app/c07-container.mdx +0 -281
  538. package/docs/zh/tutorials/first-app/c08-entries.mdx +0 -135
  539. /package/docs/en/components/{reduck-migration.mdx → auto-upgrade.mdx} +0 -0
  540. /package/docs/{zh/components/reduck-migration.mdx → en/components/international/platform-support.mdx} +0 -0
@@ -4,26 +4,34 @@ title: 服务端渲染(SSR)
4
4
 
5
5
  # 服务端渲染(SSR)
6
6
 
7
- 通过在服务器端将网页的 HTML 内容渲染成完整的网页(Server-Side Rendering,简称 SSR),然后将生成的网页发送到浏览器端,浏览器端只需要显示网页即可,不需要再进行额外的渲染。
7
+ 服务端渲染(Server-Side Rendering,简称 SSR)在服务器端生成完整的 HTML 页面,然后发送到浏览器端直接显示,无需客户端额外渲染。
8
8
 
9
- 它主要的优势在于:
9
+ ## 核心优势
10
10
 
11
- - 提高首屏加载速度:SSR 可以在服务器端生成完整的网页,浏览器端只需要下载网页内容即可,不需要再进行额外的渲染,从而提高了首屏加载速度。
12
- - 有利于 SEO:SSR 可以生成完整的 HTML 内容,搜索引擎可以直接索引 HTML 内容,从而提高网站的排名。
11
+ - **更快首屏**:服务端预渲染,浏览器直接显示,无需等待 JavaScript 执行
12
+ - **更好 SEO**:搜索引擎可直接索引完整的 HTML 内容
13
+ - **开箱即用**:无需编写复杂服务端逻辑,无需单独运维
13
14
 
14
- 如果你有以下场景的需求,开发者可以考虑使用 SSR 来渲染你的页面:
15
+ :::info 默认渲染模式
16
+ Modern.js 的 SSR **默认使用流式渲染(Streaming SSR)**,页面会边渲染边返回,用户可以更快看到初始内容。
15
17
 
16
- 1. 对首屏加载速度要求较高的网站,如电商网站、新闻网站等。
17
- 2. 对用户体验要求较高的网站,如社交网站、游戏网站等。
18
- 3. 对 SEO 要求较高的网站,如企业官网、博客等。
18
+ 详细用法请参考[流式服务端渲染(Streaming SSR)](/guides/basic-features/render/streaming-ssr)文档。
19
19
 
20
- Modern.js 中,SSR 也是开箱即用的。开发者无需为 SSR 编写复杂的服务端逻辑,也无需关心 SSR 的运维,或是创建单独的服务。
20
+ 如需切换到传统 SSR 模式(等待所有数据加载完成后一次性返回),可配置:
21
21
 
22
- 除了开箱即用的 SSR 服务,为了保证开发者的开发体验,Modern.js 还具备:
22
+ ```ts title="modern.config.ts"
23
+ import { defineConfig } from '@modern-js/app-tools';
24
+
25
+ export default defineConfig({
26
+ server: {
27
+ ssr: {
28
+ mode: 'string', // 传统 SSR 模式
29
+ },
30
+ },
31
+ });
32
+ ```
23
33
 
24
- - 完备的 SSR 降级策略,保证页面能够安全运行。
25
- - 自动分割子路由,按需加载,减少首屏资源体积。
26
- - 内置缓存系统,解决服务端负载高的问题。
34
+ :::
27
35
 
28
36
  ## 开启 SSR
29
37
 
@@ -34,20 +42,19 @@ import { defineConfig } from '@modern-js/app-tools';
34
42
 
35
43
  export default defineConfig({
36
44
  server: {
37
- ssr: true,
45
+ ssr: true, // 默认启用流式渲染
38
46
  },
39
47
  });
40
48
  ```
41
49
 
42
50
  ## 数据获取
43
51
 
44
- :::tip 前置阅读
45
- 如果你还不了解 Data Loader 如何使用或 Client Loader 的概念,请先阅读[数据获取](/guides/basic-features/data/data-fetch)。
46
- :::
52
+ Modern.js 提供了 Data Loader,支持在 SSR 和 CSR 下同构地获取数据。每个路由模块(如 `layout.tsx` 和 `page.tsx`)都可以定义自己的 Data Loader:
47
53
 
48
- ### 基本用法
54
+ :::tip 了解更多
55
+ 以下方式不会有流式渲染效果,要想获得流式渲染效果请参考[流式服务端渲染(Streaming SSR)](/guides/basic-features/render/streaming-ssr)
49
56
 
50
- Modern.js 中提供了 Data Loader,方便开发者在 SSR、CSR 下同构地获取数据。每个路由模块,如 `layout.tsx` 和 `page.tsx` 都可以定义自己的 Data Loader:
57
+ :::
51
58
 
52
59
  ```ts title="src/routes/page.data.ts"
53
60
  export const loader = () => {
@@ -57,7 +64,7 @@ export const loader = () => {
57
64
  };
58
65
  ```
59
66
 
60
- 在组件中可以通过 Hooks API 的方式获取 `loader` 函数返回的数据:
67
+ 在组件中通过 Hooks API 获取数据:
61
68
 
62
69
  ```tsx
63
70
  import { useLoaderData } from '@modern-js/runtime/router';
@@ -70,9 +77,6 @@ export default () => {
70
77
 
71
78
  ### 使用 Client Loader
72
79
 
73
- :::info
74
- 该功能需要 x.36.0 以上版本,推荐使用框架最新版本。
75
- :::
76
80
 
77
81
  默认情况下,在 SSR 应用中,`loader` 函数只会在服务端执行。但有些场景下,开发者可能期望在浏览器端发送的请求不经过 SSR 服务,直接请求数据源,例如:
78
82
 
@@ -88,16 +92,15 @@ export async function loader({ params }) {
88
92
  if (cache.has(params.id)) {
89
93
  return cache.get(params.id);
90
94
  }
91
- const res = await fetch('URL_ADDRESS?id={params.id}');
95
+ const res = await fetch(`URL_ADDRESS?id=${params.id}`);
96
+ const data = await res.json();
92
97
  return {
93
- message: res.message,
98
+ message: data.message,
94
99
  }
95
100
  }
96
101
  ```
97
102
 
98
- :::warning
99
- 要使用 Client Loader,必须有对应的 Server Loader,且 Server Loader 必须是 `.data` 文件约定,不能是 `.loader` 文件约定。
100
- :::
103
+
101
104
 
102
105
  ## SSR 降级
103
106
 
@@ -281,7 +284,7 @@ Warning: Expected server HTML to contain a matching <div> in <div>.
281
284
 
282
285
  :::
283
286
 
284
- 应用需要保持 SSR 与 CSR 渲染结果的一致性,如果存在不一致的情况,说明这部分内容无需在 SSR 中进行渲染。Modern.js 为这类在 SSR 中不需要渲染的内容提供 [`<NoSSR>` 工具组件](/apis/app/runtime/core/use-runtime-context):
287
+ 应用需要保持 SSR 与 CSR 渲染结果的一致性,如果存在不一致的情况,说明这部分内容无需在 SSR 中进行渲染。Modern.js 为这类在 SSR 中不需要渲染的内容提供 [`<NoSSR>` 工具组件](/apis/app/runtime/ssr/no-ssr):
285
288
 
286
289
  ```ts
287
290
  import { NoSSR } from '@modern-js/runtime/ssr';
@@ -297,8 +300,7 @@ import { NoSSR } from '@modern-js/runtime/ssr';
297
300
 
298
301
  修改代码后,刷新页发现之前的 Waring 消失。打开浏览器开发者工具的 Network 窗口,查看返回的 HTML 文档是不包含 `NoSSR` 组件包裹的内容的。
299
302
 
300
- 在实际场景中,有些应用的 UI 展示会和用户设备有关,例如 [UA](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent) 信息。Modern.js 也提供了
301
- [`useRuntimeContext`](/apis/app/runtime/core/use-runtime-context) 这类 API,可以在组件中获取完整的请求信息,利用它保证 SSR 与 CSR 的渲染结果一致。
303
+ 在实际场景中,有些应用的 UI 展示会和用户设备有关,例如 [UA](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent) 信息。Modern.js 也提供了 `use(RuntimeContext)` 这类 API,可以在组件中获取完整的请求信息,利用它保证 SSR 与 CSR 的渲染结果一致。详细用法请参考[运行时上下文](/guides/basic-features/render/before-render#运行时上下文)。
302
304
 
303
305
  ### 关注内存泄漏
304
306
 
@@ -329,3 +331,4 @@ export default function Test() {
329
331
  在浏览器端,这段代码不会造成任何问题,但是在 SSR 时,Middleware 实例会一直无法被销毁。每次渲染组件,调用 `epicMiddleware.run(rootEpic)` 时,都会在内部添加新的事件绑定,导致整个对象不断变大,最终对应用性能造成影响。
330
332
 
331
333
  CSR 中这类问题不易被发觉,因此从 CSR 切换到 SSR 时,如果不确定应用是否存在这类隐患,可以对应用进行压测。
334
+
@@ -2,22 +2,40 @@
2
2
  title: 服务端流式渲染(Streaming SSR)
3
3
  ---
4
4
 
5
- # 服务端流式渲染(Streaming SSR)
5
+ # 流式服务端渲染(Streaming SSR)
6
6
 
7
- 流式渲染是一种新的渲染方式,它可以在用户与页面交互时,实时地更新页面内容,从而提高用户体验。
7
+ 流式渲染是一种先进的渲染方式,它可以在页面渲染过程中逐步返回内容,从而显著提升用户体验。
8
8
 
9
- 在传统的渲染方式中,页面的渲染是一次性完成的,而在流式渲染中,页面的渲染是逐步完成的,在用户与页面交互时,逐步加载数据,而不是一次性加载所有数据。
9
+ 在传统的 SSR 渲染方式中,页面的渲染是一次性完成的,需要等待所有数据加载完成后才能返回完整的 HTML。而在流式渲染中,页面的渲染是逐步完成的,可以边渲染边返回,用户能够更快地看到初始内容。
10
10
 
11
- 相比传统渲染:
11
+ :::info 默认模式
12
+ **Streaming SSR 是 Modern.js SSR 的默认渲染模式**。当你启用 SSR 时,无需额外配置即可使用流式渲染。
12
13
 
13
- - 拥有更快感知速度:流式渲染可以在渲染过程中逐步显示内容能够以最快的速度显示业务首页。
14
- - 拥有更好的用户体验:通过流式渲染,用户可以更快地看到页面上的内容,而不需要等待整个页面都渲染完成后才能交互。
15
- - 拥有更好的性能控制:流式渲染可以让开发者更好地控制页面加载的优先级和顺序,从而更好地优化性能和用户体验。
16
- - 更好的适应性:流式渲染可以更好地适应不同网络速度和设备性能,使得页面在各种环境下都能有更好的表现。
14
+ 如果你需要切换到传统的 SSR 模式(等待所有数据加载完成后一次性返回),可以配置 `server.ssr.mode` 为 `'string'`。详细说明请参考[服务端渲染(SSR)](/guides/basic-features/render/ssr)文档。
15
+ :::
16
+
17
+ 相比传统 SSR 渲染:
18
+
19
+ - **更快感知速度**:流式渲染可以在渲染过程中逐步显示内容,能够以最快的速度显示业务首页
20
+ - **更好的用户体验**:通过流式渲染,用户可以更快地看到页面上的内容,而不需要等待整个页面都渲染完成后才能交互
21
+ - **更好的性能控制**:流式渲染可以让开发者更好地控制页面加载的优先级和顺序,从而更好地优化性能和用户体验
22
+ - **更好的适应性**:流式渲染可以更好地适应不同网络速度和设备性能,使得页面在各种环境下都能有更好的表现
17
23
 
18
24
  ## 开启流式渲染
19
25
 
20
- Modern.js 支持了 React 18 的流式渲染,可以通过如下配置启用:
26
+ Modern.js 支持了 React 18+ 的流式渲染。当你启用 SSR 时,流式渲染默认开启:
27
+
28
+ ```ts title="modern.config.ts"
29
+ import { defineConfig } from '@modern-js/app-tools';
30
+
31
+ export default defineConfig({
32
+ server: {
33
+ ssr: true, // 默认启用流式渲染
34
+ },
35
+ });
36
+ ```
37
+
38
+ 如果你需要显式指定流式渲染模式,可以配置:
21
39
 
22
40
  ```ts title="modern.config.ts"
23
41
  import { defineConfig } from '@modern-js/app-tools';
@@ -25,7 +43,7 @@ import { defineConfig } from '@modern-js/app-tools';
25
43
  export default defineConfig({
26
44
  server: {
27
45
  ssr: {
28
- mode: 'stream',
46
+ mode: 'stream', // 显式指定流式渲染模式
29
47
  },
30
48
  },
31
49
  });
@@ -33,7 +51,6 @@ export default defineConfig({
33
51
 
34
52
  Modern.js 的流式渲染基于 React Router 实现,主要涉及 API 有:
35
53
 
36
- - [`defer`](https://reactrouter.com/en/main/utils/defer):在 Data Loader 中使用,用于支持异步获取数据。
37
54
  - [`Await`](https://reactrouter.com/en/main/components/await):用于渲染 Data Loader 返回的异步数据。
38
55
  - [`useAsyncValue`](https://reactrouter.com/en/main/hooks/use-async-value):用于从最近的父级 `Await` 组件中获取数据。
39
56
 
@@ -224,7 +241,7 @@ function ErrorElement() {
224
241
 
225
242
  然而,当一个爬虫访问该页面时,它可能需要先加载所有内容,直接输出整个 HTML,而不是渐进式地加载它。
226
243
 
227
- Modern.js 使用 [isbot](https://www.npmjs.com/package/isbot) 对请求的 `uesr-agent`,以判断请求是否来自爬虫。
244
+ Modern.js 使用 [isbot](https://www.npmjs.com/package/isbot) 对请求的 `user-agent`,以判断请求是否来自爬虫。
228
245
 
229
246
 
230
247
  import StreamSSRPerformance from '@site-docs/components/stream-ssr-performance';
@@ -233,5 +250,8 @@ import StreamSSRPerformance from '@site-docs/components/stream-ssr-performance';
233
250
 
234
251
  ## 相关文档
235
252
 
236
- 1. [Deferred Data](https://reactrouter.com/en/main/guides/deferred)
237
- 2. [New Suspense SSR Architecture in React 18](https://github.com/reactwg/react-18/discussions/37)
253
+ - [渲染模式总览](/guides/basic-features/render/overview)
254
+ - [服务端渲染(SSR](/guides/basic-features/render/ssr)
255
+ - [渲染缓存](/guides/basic-features/render/ssr-cache)
256
+ - [React Server Components(RSC)](/guides/basic-features/render/rsc) - 与 Streaming SSR 结合使用
257
+ - [New Suspense SSR Architecture in React 18](https://github.com/reactwg/react-18/discussions/37) - React 18 架构说明
@@ -0,0 +1 @@
1
+ ["routes", "config-routes"]
@@ -0,0 +1,426 @@
1
+ ---
2
+ sidebar_position: 3
3
+ ---
4
+
5
+ # 配置式路由
6
+
7
+ 默认情况下,Modern.js 推荐使用 [约定式路由](./routes.mdx) 作为路由定义的方式。同时,Modern.js 也提供了一个配置式路由的能力,其可以和约定式路由一起使用,或两者分别单独使用。
8
+
9
+
10
+ ## 何时使用配置式路由
11
+
12
+ 配置式路由在以下场景中特别有用:
13
+
14
+ - **需要灵活的路由控制**:当文件结构无法直接映射到所需的 URL 结构时
15
+ - **多路由指向同一组件**:需要将不同的 URL 路径指向同一个页面组件
16
+ - **条件性路由**:根据不同条件动态配置路由
17
+ - **遗留项目迁移**:从其他路由系统迁移到 Modern.js 时保持原有的路由结构
18
+ - **复杂的路由命名**:需要自定义路由路径而不受文件目录限制
19
+
20
+ ## 基本用法
21
+
22
+ 在 `src` 或每个入口目录下,你可以定义一个 `modern.routes.[tj]s` 文件,通过该文件,你可以对路由进行配置:
23
+
24
+ ```ts
25
+ import { defineRoutes } from '@modern-js/runtime/config-routes'
26
+
27
+ export default defineRoutes(({ route, layout, page, $ }, fileRoutes) => {
28
+ return [
29
+ route("home.tsx", "/"),
30
+ ]
31
+ })
32
+ ```
33
+
34
+ ### 函数签名说明
35
+
36
+ `defineRoutes` 接受一个回调函数,该回调函数有两个参数:
37
+ 1. `routeFunctions`: 包含 `route`、`layout`、`page`、`$` 函数的对象
38
+ 2. `fileRoutes`: 约定式路由生成的路由配置数组
39
+
40
+ 路由函数的基本签名:
41
+ - 第一个参数:相对于 `modern.routes.[tj]s` 的文件路径
42
+ - 第二个参数:路由路径(可选,必须是字符串)
43
+ - 第三个参数:子路由数组(可选)
44
+
45
+
46
+ ## 路由函数
47
+
48
+ Modern.js 提供了四个主要的路由配置函数:
49
+
50
+ :::tip 路径说明
51
+
52
+ 所有路由函数的第一个参数(路径)都是**相对路径**,会与父级路径拼接生成最终的路由路径:
53
+ - **根路径**:`"/"` 或 "" 表示当前层级的根路径
54
+ - **相对路径**:子路由的路径会相对于父级路径进行拼接
55
+ - **动态路径**:使用 `:param` 语法表示动态参数
56
+ - **通配路径**:使用 `"*"` 语法匹配所有路径
57
+
58
+ :::
59
+
60
+
61
+ :::info
62
+
63
+ - `route`、`layout`、`page`、`$` 等函数的第一个参数(组件文件路径)必须指向当前项目中的真实文件,暂不支持 `node_modules` 及 Monorepo 下其他仓库中的文件
64
+ - 不支持使用路径别名(例如 `@/pages/...`、`~/pages/...` 等);请使用相对于 `modern.routes.[tj]s` 的相对路径。
65
+
66
+ :::
67
+
68
+ ### `route` 函数
69
+
70
+ `route` 函数是通用的路由配置函数,会根据是否有子路由自动决定生成页面路由还是布局路由,可以代替 `layout`, `page`, `$`等函数。
71
+
72
+ ```ts
73
+ export default defineRoutes(({ route }, fileRoutes) => {
74
+ return [
75
+ // 无子路由时,自动生成页面路由
76
+ route("home.tsx", "/"),
77
+ route("about.tsx", "about"),
78
+
79
+ // 有子路由时,自动生成布局路由
80
+ // dashboard/layout.tsx 需要包含 <Outlet> 来渲染子路由
81
+ route("dashboard/layout.tsx", "dashboard", [
82
+ route("dashboard/overview.tsx", "overview"), // 生成路径:/dashboard/overview
83
+ route("dashboard/settings.tsx", "settings"), // 生成路径:/dashboard/settings
84
+ ]),
85
+
86
+ // 动态路由
87
+ route("products/detail.tsx", "products/:id"),
88
+
89
+ // 多路径指向同一组件
90
+ route("user/profile.tsx", "user"),
91
+ route("user/profile.tsx", "profile"),
92
+ ]
93
+ })
94
+ ```
95
+
96
+ **使用场景**:
97
+ - 快速配置路由,无需明确指定是页面还是布局
98
+ - 简化路由配置的复杂度
99
+
100
+ ### `layout` 函数
101
+
102
+ `layout` 函数专门用于配置布局路由,始终生成布局组件,必须包含子路由:
103
+
104
+ ```ts
105
+ export default defineRoutes(({ layout, page }, fileRoutes) => {
106
+ return [
107
+ // 生成布局路由,路径为 "/auth",必须包含子路由
108
+ layout("auth/layout.tsx", "auth", [
109
+ page("auth/login/page.tsx", "login"), // 生成路径:/auth/login
110
+ page("auth/register/page.tsx", "register"), // 生成路径:/auth/register
111
+ ]),
112
+ ]
113
+ })
114
+ ```
115
+
116
+ **使用场景**:
117
+ - 需要明确指定某个组件为布局组件
118
+ - 为多个页面提供共同的布局结构
119
+ - 需要在多个路由间共享导航、侧边栏等UI组件
120
+
121
+ ### `page` 函数
122
+
123
+ `page` 函数专门用于配置页面路由,始终生成页面组件:
124
+
125
+ ```ts
126
+ export default defineRoutes(({ layout, page }, fileRoutes) => {
127
+ return [
128
+ layout("dashboard/layout.tsx", "dashboard", [
129
+ page("dashboard/overview.tsx", "overview"), // 生成路径:/dashboard/overview
130
+ page("dashboard/settings.tsx", "settings"), // 生成路径:/dashboard/settings
131
+ ]),
132
+ ]
133
+ })
134
+ ```
135
+
136
+ **使用场景**:
137
+ - 需要明确指定某个组件为页面组件
138
+ - 确保组件不包含 `<Outlet>` 子组件渲染
139
+ - 提供更清晰的语义表达
140
+
141
+ ### `$` 函数
142
+
143
+ `$` 函数专门用于配置通配路由,用于处理未匹配的路由:
144
+
145
+ ```ts
146
+ export default defineRoutes(({ layout, page, $ }, fileRoutes) => {
147
+ return [
148
+ layout("blog/layout.tsx", "blog", [
149
+ page("blog/page.tsx", ""), // 生成路径:/blog
150
+ page("blog/[id]/page.tsx", ":id"), // 生成路径:/blog/:id
151
+ $("blog/$.tsx", "*"), // 通配路由,匹配 /blog 下的所有未匹配路径
152
+ ]),
153
+ ]
154
+ })
155
+ ```
156
+
157
+ **使用场景**:
158
+ - 自定义 404 页面
159
+ - 处理特定路径下的所有未匹配请求
160
+
161
+ :::tip
162
+ `$` 函数与约定式路由中的 `$.tsx` 文件功能相同,用于捕获未匹配的路由请求。
163
+ :::
164
+
165
+ ## 配置路由
166
+
167
+ ### 基本示例
168
+
169
+ ```ts
170
+ export default defineRoutes(({ page }, fileRoutes) => {
171
+ return [
172
+ // 使用 page 函数明确指定页面路由
173
+ page("home.tsx", "/"),
174
+ page("about.tsx", "about"),
175
+ page("contact.tsx", "contact"),
176
+ ]
177
+ })
178
+ ```
179
+
180
+ ### 无路径路由
181
+
182
+ 当不指定路径时,路由会继承父级路径:
183
+
184
+ ```ts
185
+ export default defineRoutes(({ layout, page }, fileRoutes) => {
186
+ return [
187
+ // 使用 layout 函数明确指定布局路由
188
+ // auth/layout.tsx 需要包含 <Outlet> 来渲染子路由
189
+ layout("auth/layout.tsx", [
190
+ page("login/page.tsx", "login"),
191
+ page("register/page.tsx", "register"),
192
+ ]),
193
+ ]
194
+ })
195
+ ```
196
+
197
+ 上述配置会生成:
198
+ - `/login` → `auth/layout.tsx` + `login/page.tsx`
199
+ - `/register` → `auth/layout.tsx` + `register/page.tsx`
200
+
201
+ ### 多路径指向同一组件
202
+
203
+ ```ts
204
+ export default defineRoutes(({ page }, fileRoutes) => {
205
+ return [
206
+ page("user.tsx", "user"),
207
+ page("user.tsx", "profile"),
208
+ page("user.tsx", "account"),
209
+ ]
210
+ })
211
+ ```
212
+
213
+ ### 动态路由
214
+
215
+ 配置式路由支持动态路由参数:
216
+
217
+ ```ts
218
+ export default defineRoutes(({ page }, fileRoutes) => {
219
+ return [
220
+ // 必需参数
221
+ page("blog/detail.tsx", "blog/:id"),
222
+
223
+ // 可选参数
224
+ page("blog/index.tsx", "blog/:slug?"),
225
+ ]
226
+ })
227
+ ```
228
+
229
+ ## 路由相关文件自动查找
230
+
231
+ 配置式路由会自动查找组件的配套文件,无需手动配置。对于 `modern.routes.[tj]s` 中指定的任意组件文件,Modern.js 会自动查找以下配套文件:
232
+
233
+ ```ts
234
+ // modern.routes.[tj]s
235
+ export default defineRoutes(({ route }, fileRoutes) => {
236
+ return [
237
+ route("pages/profile.tsx", "profile"),
238
+ route("pages/user/detail.tsx", "user/:id"),
239
+ ]
240
+ })
241
+ ```
242
+
243
+ Modern.js 会自动查找并加载:
244
+
245
+ - `pages/profile.data.ts` → 数据加载器
246
+ - `pages/profile.config.ts` → 路由配置
247
+ - `pages/profile.error.tsx` → 错误边界
248
+ - `pages/profile.loading.tsx` → Loading 组件
249
+
250
+ ### 查找规则
251
+
252
+ - **文件位置**:配套文件必须与组件文件在同一目录
253
+ - **文件命名**:配套文件名与组件文件名相同(不包括扩展名)
254
+ - **自动发现**:Modern.js 自动发现并加载这些文件
255
+
256
+ :::tip
257
+
258
+ 更多关于数据获取的详细信息,请参考 [数据获取](/guides/basic-features/data/data-fetch) 文档。关于 Loading 组件的使用,请参考 [约定式路由 - Loading](./routes.mdx#loading-experimental)。
259
+
260
+ :::
261
+
262
+
263
+ ## 路由合并
264
+
265
+ 配置式路由可以与约定式路由一起使用,你可以通过修改 `fileRoutes` 参数来实现路由的合并:
266
+
267
+ 1. **覆盖路由**:可以主动移除约定式路由并替换为配置式路由
268
+ 2. **补充路由**:可以在约定式路由基础上添加新的配置式路由
269
+ 3. **混合使用**:可以在约定式布局路由下添加配置式子路由
270
+
271
+ :::info
272
+
273
+ 当前路由结构可以通过 [`modern routes`](#调试路由) 命令查看
274
+
275
+ :::
276
+
277
+
278
+ ### 合并示例
279
+
280
+ 以下示例展示了配置式路由与约定式路由的合并方式:
281
+
282
+ ```ts
283
+ // modern.routes.ts
284
+ import { defineRoutes } from '@modern-js/runtime/config-routes';
285
+
286
+ export default defineRoutes(({ page }, fileRoutes) => {
287
+ // 场景1:覆盖约定式路由
288
+ // 移除原有的 shop 路由,替换为自定义组件
289
+ const shopPageIndex = fileRoutes[0].children?.findIndex(
290
+ route => route.id === 'three_shop/page',
291
+ );
292
+ fileRoutes[0].children?.splice(shopPageIndex!, 1);
293
+ fileRoutes[0].children?.push(page('routes/CustomShop.tsx', 'shop'));
294
+
295
+ // 场景2:补充约定式路由
296
+ // 添加配置式路由,无约定式路由对应
297
+ fileRoutes[0].children?.push(page('routes/Settings.tsx', 'settings'));
298
+
299
+ // 场景3:混合嵌套路由
300
+ // 在约定式布局路由下添加配置式子路由
301
+ const userRoute = fileRoutes[0].children?.find(
302
+ (route: any) => route.path === 'user',
303
+ );
304
+ if (userRoute?.children) {
305
+ userRoute.children.push(page('routes/user/CustomTab.tsx', 'custom-tab'));
306
+ }
307
+
308
+ // 场景4:自动发现配套文件
309
+ // Product.tsx 会自动发现 Product.data.ts 和 Product.error.tsx
310
+ fileRoutes[0].children?.push(page('routes/Product.tsx', 'product/:id'));
311
+
312
+ return fileRoutes;
313
+ });
314
+ ```
315
+ ## 调试路由
316
+
317
+ 由于路由合并后的最终结构可能不够直观,Modern.js 提供了调试命令来帮助你查看完整路由信息:
318
+
319
+ ```bash
320
+ # 生成路由结构分析报告
321
+ npx modern routes
322
+ ```
323
+
324
+ 该命令会在 `dist/routes-inspect.json` 文件中生成最终的路由结构,帮助你了解合并后的完整路由信息。
325
+
326
+ ### 报告文件示例
327
+
328
+ #### 单入口场景
329
+
330
+ ```json title="dist/routes-inspect.json"
331
+ {
332
+ "routes": [
333
+ {
334
+ "path": "/",
335
+ "component": "@_modern_js_src/routes/page",
336
+ "data": "@_modern_js_src/routes/page.data",
337
+ "clientData": "@_modern_js_src/routes/page.data.client",
338
+ "error": "@_modern_js_src/routes/page.error",
339
+ "loading": "@_modern_js_src/routes/page.loading"
340
+ },
341
+ {
342
+ "path": "/dashboard",
343
+ "component": "pages/admin",
344
+ "config": "pages/admin.config",
345
+ "error": "pages/admin.error"
346
+ },
347
+ {
348
+ "path": "/user",
349
+ "component": "layouts/user",
350
+ "children": [
351
+ {
352
+ "path": "/user/profile",
353
+ "component": "@_modern_js_src/routes/user/profile",
354
+ "data": "@_modern_js_src/routes/user/profile.data"
355
+ }
356
+ ]
357
+ },
358
+ {
359
+ "path": "@_modern_js_src/routes/blog/:id",
360
+ "component": "blog/detail",
361
+ "params": ["id"],
362
+ "data": "blog/detail.data",
363
+ "loading": "blog/detail.loading"
364
+ },
365
+ {
366
+ "path": "/files/*",
367
+ "component": "@_modern_js_src/routes/files/list"
368
+ }
369
+ ]
370
+ }
371
+ ```
372
+
373
+ #### 多入口场景
374
+
375
+ 在多入口项目中,报告文件会按照入口名称进行分组,其中 key 为 entryName:
376
+
377
+ ```json title="dist/routes-inspect.json"
378
+ {
379
+ "main": {
380
+ "routes": [
381
+ {
382
+ "path": "/",
383
+ "component": "@_modern_js_src/routes/page",
384
+ "data": "@_modern_js_src/routes/page.data",
385
+ "error": "@_modern_js_src/routes/page.error",
386
+ "loading": "@_modern_js_src/routes/page.loading"
387
+ },
388
+ {
389
+ "path": "/dashboard",
390
+ "component": "@_modern_js_src/routes/dashboard",
391
+ "config": "@_modern_js_src/routes/dashboard.config"
392
+ }
393
+ ]
394
+ },
395
+ "admin": {
396
+ "routes": [
397
+ {
398
+ "path": "/",
399
+ "component": "@_modern_js_src/routes/dashboard",
400
+ "data": "@_modern_js_src/routes/dashboard.data",
401
+ "clientData": "@_modern_js_src/routes/dashboard.data.client",
402
+ "config": "@_modern_js_src/routes/dashboard.config"
403
+ },
404
+ {
405
+ "path": "/users",
406
+ "component": "@_modern_js_src/routes/users",
407
+ "data": "@_modern_js_src/routes/users.data",
408
+ "error": "@_modern_js_src/routes/users.error",
409
+ "loading": "@_modern_js_src/routes/users.loading"
410
+ }
411
+ ]
412
+ }
413
+ }
414
+ ```
415
+
416
+ #### 路由相关文件字段说明
417
+
418
+ 报告中除了基本的路由信息外,还会显示每个路由找到的相关文件:
419
+
420
+ - **`data`**: 服务端数据加载文件(`.data.ts`),用于在服务端获取数据
421
+ - **`clientData`**: 客户端数据加载文件(`.data.client.ts`),用于在客户端重新获取数据
422
+ - **`error`**: 错误边界文件(`.error.tsx`),用于处理路由渲染错误
423
+ - **`loading`**: 加载状态组件文件(`.loading.tsx`),用于显示数据加载中的状态
424
+ - **`config`**: 路由配置文件(`.config.ts`),用于配置路由元数据
425
+
426
+ 这些字段都是可选的,只有在找到对应文件时才会在报告中显示。通过查看这些字段,你可以快速了解每个路由的完整文件结构。