@modern-js/main-doc 2.3.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (387) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/LICENSE +0 -123
  3. package/README.md +26 -0
  4. package/en/apis/app/commands/_category_.json +1 -4
  5. package/en/apis/app/commands/new.mdx +11 -10
  6. package/en/apis/app/commands/test.mdx +1 -1
  7. package/en/apis/app/hooks/_category_.json +1 -4
  8. package/en/apis/app/hooks/api/framework/lambda.mdx +1 -1
  9. package/en/apis/app/hooks/api/functions/api.mdx +1 -1
  10. package/en/apis/app/hooks/server/index_.mdx +2 -1
  11. package/en/apis/app/hooks/src/pages.mdx +7 -7
  12. package/en/apis/app/hooks/src/routes.mdx +1 -1
  13. package/en/apis/app/runtime/_category_.json +1 -5
  14. package/en/apis/app/runtime/app/define-config.mdx +2 -2
  15. package/en/apis/app/runtime/core/bootstrap.mdx +1 -1
  16. package/en/apis/app/runtime/core/create-app.mdx +2 -2
  17. package/en/apis/app/runtime/core/use-loader.mdx +4 -4
  18. package/en/apis/app/runtime/core/use-module-apps.mdx +2 -2
  19. package/en/apis/app/runtime/model/Provider.mdx +2 -2
  20. package/en/apis/app/runtime/model/auto-actions.mdx +2 -2
  21. package/en/apis/app/runtime/model/connect.mdx +5 -5
  22. package/en/apis/app/runtime/model/create-app.mdx +9 -9
  23. package/en/apis/app/runtime/model/create-store.mdx +3 -3
  24. package/en/apis/app/runtime/model/handle-effect.mdx +2 -2
  25. package/en/apis/app/runtime/model/model_.mdx +1 -1
  26. package/en/apis/app/runtime/model/use-local-model.mdx +1 -1
  27. package/en/apis/app/runtime/model/use-model.mdx +1 -1
  28. package/en/apis/app/runtime/model/use-static-model.mdx +4 -4
  29. package/en/apis/app/runtime/model/use-store.mdx +1 -1
  30. package/en/apis/app/runtime/router/router.mdx +1 -1
  31. package/en/apis/app/runtime/ssr/pre-render.mdx +1 -1
  32. package/en/apis/app/runtime/testing/render.mdx +1 -1
  33. package/en/apis/app/runtime/testing/renderApp.mdx +1 -1
  34. package/en/apis/app/runtime/utility/css-in-js.mdx +1 -1
  35. package/en/apis/app/runtime/utility/loadable.mdx +1 -1
  36. package/en/apis/app/runtime/web-server/hook.mdx +5 -5
  37. package/en/apis/app/runtime/web-server/middleware.mdx +6 -6
  38. package/en/components/global-proxy-config.mdx +3 -3
  39. package/en/components/init-app.mdx +1 -1
  40. package/en/configure/app/bff/_category_.json +4 -0
  41. package/en/configure/app/builder-plugins.mdx +3 -3
  42. package/en/configure/app/deploy/_category_.json +4 -0
  43. package/en/configure/app/dev/_category_.json +4 -0
  44. package/en/configure/app/dev/asset-prefix.mdx +1 -1
  45. package/en/configure/app/dev/hmr.mdx +1 -1
  46. package/en/configure/app/dev/https.mdx +1 -1
  47. package/en/configure/app/dev/port.mdx +1 -1
  48. package/en/configure/app/dev/progress-bar.mdx +1 -1
  49. package/en/configure/app/dev/start-url.mdx +1 -1
  50. package/en/configure/app/experiments/_category_.json +4 -0
  51. package/en/configure/app/experiments/lazy-compilation.mdx +1 -1
  52. package/en/configure/app/html/_category_.json +4 -0
  53. package/en/configure/app/html/app-icon.mdx +1 -1
  54. package/en/configure/app/html/crossorigin.mdx +1 -1
  55. package/en/configure/app/html/disable-html-folder.mdx +1 -1
  56. package/en/configure/app/html/favicon-by-entries.mdx +1 -1
  57. package/en/configure/app/html/favicon.mdx +1 -1
  58. package/en/configure/app/html/inject-by-entries.mdx +1 -1
  59. package/en/configure/app/html/inject.mdx +1 -1
  60. package/en/configure/app/html/meta-by-entries.mdx +1 -1
  61. package/en/configure/app/html/meta.mdx +1 -1
  62. package/en/configure/app/html/mount-id.mdx +1 -1
  63. package/en/configure/app/html/tags-by-entries.mdx +1 -1
  64. package/en/configure/app/html/tags.mdx +1 -1
  65. package/en/configure/app/html/template-by-entries.mdx +1 -1
  66. package/en/configure/app/html/template-parameters-by-entries.mdx +1 -1
  67. package/en/configure/app/html/template-parameters.mdx +1 -1
  68. package/en/configure/app/html/template.mdx +1 -1
  69. package/en/configure/app/html/title-by-entries.mdx +1 -1
  70. package/en/configure/app/html/title.mdx +1 -1
  71. package/en/configure/app/output/_category_.json +4 -0
  72. package/en/configure/app/output/asset-prefix.mdx +1 -1
  73. package/en/configure/app/output/assets-retry.mdx +1 -1
  74. package/en/configure/app/output/charset.mdx +1 -1
  75. package/en/configure/app/output/clean-dist-path.mdx +1 -1
  76. package/en/configure/app/output/convert-to-rem.mdx +1 -1
  77. package/en/configure/app/output/copy.mdx +1 -1
  78. package/en/configure/app/output/css-module-local-ident-name.mdx +1 -1
  79. package/en/configure/app/output/data-uri-limit.mdx +1 -1
  80. package/en/configure/app/output/disable-css-extract.mdx +1 -1
  81. package/en/configure/app/output/disable-css-module-extension.mdx +1 -1
  82. package/en/configure/app/output/disable-filename-hash.mdx +1 -1
  83. package/en/configure/app/output/disable-inline-runtime-chunk.mdx +1 -1
  84. package/en/configure/app/output/disable-minimize.mdx +1 -1
  85. package/en/configure/app/output/disable-source-map.mdx +1 -1
  86. package/en/configure/app/output/disable-ts-checker.mdx +1 -1
  87. package/en/configure/app/output/dist-path.mdx +1 -1
  88. package/en/configure/app/output/enable-asset-fallback.mdx +1 -1
  89. package/en/configure/app/output/enable-asset-manifest.mdx +1 -1
  90. package/en/configure/app/output/enable-css-module-tsdeclaration.mdx +1 -1
  91. package/en/configure/app/output/enable-inline-scripts.mdx +1 -1
  92. package/en/configure/app/output/enable-inline-styles.mdx +1 -1
  93. package/en/configure/app/output/enable-latest-decorators.mdx +1 -1
  94. package/en/configure/app/output/externals.mdx +1 -1
  95. package/en/configure/app/output/filename.mdx +1 -1
  96. package/en/configure/app/output/legal-comments.mdx +1 -1
  97. package/en/configure/app/output/override-browserslist.mdx +1 -1
  98. package/en/configure/app/output/polyfill.mdx +1 -1
  99. package/en/configure/app/output/ssg.mdx +2 -2
  100. package/en/configure/app/output/svg-default-export.mdx +1 -1
  101. package/en/configure/app/performance/_category_.json +4 -0
  102. package/en/configure/app/performance/build-cache.mdx +1 -1
  103. package/en/configure/app/performance/bundle-analyze.mdx +1 -1
  104. package/en/configure/app/performance/chunk-split.mdx +1 -1
  105. package/en/configure/app/performance/print-file-size.mdx +1 -1
  106. package/en/configure/app/performance/profile.mdx +1 -1
  107. package/en/configure/app/performance/remove-console.mdx +1 -1
  108. package/en/configure/app/performance/remove-moment-locale.mdx +1 -1
  109. package/en/configure/app/plugins.mdx +1 -1
  110. package/en/configure/app/runtime/_category_.json +4 -0
  111. package/en/configure/app/runtime/intro.mdx +2 -2
  112. package/en/configure/app/security/_category_.json +4 -0
  113. package/en/configure/app/security/check-syntax.mdx +1 -1
  114. package/en/configure/app/security/sri.mdx +1 -1
  115. package/en/configure/app/server/_category_.json +4 -0
  116. package/en/configure/app/server/base-url.mdx +3 -3
  117. package/en/configure/app/server/enable-framework-ext.mdx +1 -1
  118. package/en/configure/app/server/ssr-by-entries.mdx +1 -1
  119. package/en/configure/app/source/_category_.json +4 -0
  120. package/en/configure/app/source/alias.mdx +1 -1
  121. package/en/configure/app/source/compile-js-data-uri.mdx +1 -1
  122. package/en/configure/app/source/define.mdx +1 -1
  123. package/en/configure/app/source/design-system.mdx +5 -5
  124. package/en/configure/app/source/entries.mdx +3 -3
  125. package/en/configure/app/source/exclude.mdx +1 -1
  126. package/en/configure/app/source/global-vars.mdx +1 -1
  127. package/en/configure/app/source/include.mdx +1 -1
  128. package/en/configure/app/source/module-scopes.mdx +1 -1
  129. package/en/configure/app/source/pre-entry.mdx +1 -1
  130. package/en/configure/app/source/resolve-extension-prefix.mdx +1 -1
  131. package/en/configure/app/source/resolve-main-fields.mdx +1 -1
  132. package/en/configure/app/testing/_category_.json +4 -0
  133. package/en/configure/app/tools/_category_.json +4 -0
  134. package/en/configure/app/tools/autoprefixer.mdx +1 -1
  135. package/en/configure/app/tools/babel.mdx +1 -1
  136. package/en/configure/app/tools/css-extract.mdx +1 -1
  137. package/en/configure/app/tools/css-loader.mdx +1 -1
  138. package/en/configure/app/tools/dev-server.mdx +1 -1
  139. package/en/configure/app/tools/html-plugin.mdx +1 -1
  140. package/en/configure/app/tools/inspector.mdx +1 -1
  141. package/en/configure/app/tools/less.mdx +1 -1
  142. package/en/configure/app/tools/minify-css.mdx +1 -1
  143. package/en/configure/app/tools/postcss.mdx +1 -1
  144. package/en/configure/app/tools/pug.mdx +1 -1
  145. package/en/configure/app/tools/rspack.mdx +13 -0
  146. package/en/configure/app/tools/sass.mdx +1 -1
  147. package/en/configure/app/tools/style-loader.mdx +1 -1
  148. package/en/configure/app/tools/styled-components.mdx +1 -1
  149. package/en/configure/app/tools/tailwindcss.mdx +1 -1
  150. package/en/configure/app/tools/terser.mdx +1 -1
  151. package/en/configure/app/tools/ts-checker.mdx +1 -1
  152. package/en/configure/app/tools/ts-loader.mdx +1 -1
  153. package/en/configure/app/tools/webpack-chain.mdx +1 -1
  154. package/en/configure/app/tools/webpack.mdx +1 -1
  155. package/en/configure/app/usage.mdx +64 -1
  156. package/en/guides/advanced-features/_category_.json +5 -0
  157. package/en/guides/advanced-features/bff/bff-proxy.mdx +1 -1
  158. package/en/guides/advanced-features/bff/frameworks.mdx +1 -1
  159. package/en/guides/advanced-features/bff/function.mdx +3 -3
  160. package/en/guides/advanced-features/code-split.mdx +2 -2
  161. package/en/guides/advanced-features/compatibility.mdx +2 -3
  162. package/en/guides/advanced-features/eslint.mdx +4 -4
  163. package/en/guides/advanced-features/low-level.mdx +1 -1
  164. package/en/guides/advanced-features/ssg.mdx +4 -5
  165. package/en/guides/advanced-features/ssr.mdx +5 -5
  166. package/en/guides/advanced-features/testing.mdx +4 -5
  167. package/en/guides/advanced-features/web-server.mdx +0 -1
  168. package/en/guides/basic-features/_category_.json +5 -0
  169. package/en/guides/basic-features/alias.mdx +1 -1
  170. package/en/guides/basic-features/data-fetch.mdx +21 -8
  171. package/en/guides/basic-features/env-vars.mdx +1 -1
  172. package/en/guides/basic-features/html.mdx +11 -11
  173. package/en/guides/basic-features/mock.mdx +21 -1
  174. package/en/guides/basic-features/proxy.mdx +2 -2
  175. package/en/guides/basic-features/routes.mdx +33 -7
  176. package/en/guides/concept/_category_.json +5 -0
  177. package/en/guides/{basic-features → concept}/builder.mdx +2 -2
  178. package/en/guides/concept/entries.mdx +11 -11
  179. package/en/guides/css/_category_.json +5 -0
  180. package/en/guides/{basic-features/css → css}/css-in-js.mdx +0 -0
  181. package/en/guides/{basic-features/css → css}/css-modules.mdx +0 -0
  182. package/en/guides/{basic-features/css → css}/less-sass.mdx +1 -1
  183. package/en/guides/{basic-features/css → css}/postcss.mdx +0 -0
  184. package/en/guides/{basic-features/css → css}/tailwindcss.mdx +0 -0
  185. package/en/guides/get-started/_category_.json +5 -0
  186. package/en/guides/get-started/introduction.mdx +34 -0
  187. package/en/guides/get-started/quick-start.mdx +2 -2
  188. package/en/guides/get-started/upgrade.mdx +2 -1
  189. package/en/guides/topic-detail/_category_.json +2 -2
  190. package/en/guides/topic-detail/framework-plugin/hook.mdx +1 -1
  191. package/en/guides/topic-detail/generator/config/{mwa.mdx → app.mdx} +1 -1
  192. package/en/guides/topic-detail/generator/plugin/api/hook/onForged.mdx +1 -1
  193. package/en/guides/topic-detail/generator/plugin/api/new/createElement.mdx +1 -1
  194. package/en/guides/topic-detail/generator/plugin/api/new/enableFunc.mdx +1 -1
  195. package/en/guides/topic-detail/generator/plugin/api/new/introduce.mdx +1 -1
  196. package/en/guides/topic-detail/generator/plugin/develop.mdx +3 -3
  197. package/en/guides/topic-detail/micro-frontend/c02-development.mdx +128 -61
  198. package/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +72 -41
  199. package/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +1 -1
  200. package/en/guides/topic-detail/model/auto-actions.mdx +1 -1
  201. package/en/guides/topic-detail/model/define-model.mdx +1 -1
  202. package/en/guides/topic-detail/model/manage-effects.mdx +1 -1
  203. package/en/guides/topic-detail/model/model-communicate.mdx +1 -1
  204. package/en/guides/topic-detail/model/quick-start.mdx +2 -2
  205. package/en/guides/topic-detail/model/test-model.mdx +1 -1
  206. package/en/guides/topic-detail/model/use-model.mdx +3 -3
  207. package/en/guides/troubleshooting/_category_.json +2 -2
  208. package/en/guides/troubleshooting/cli.mdx +1 -1
  209. package/en/index.md +1 -1
  210. package/en/tutorials/first-app/_category_.json +1 -1
  211. package/en/tutorials/first-app/c01-start.mdx +0 -1
  212. package/en/tutorials/first-app/c03-css.mdx +1 -2
  213. package/en/tutorials/first-app/c06-model.mdx +1 -1
  214. package/en/tutorials/first-app/c07-container.mdx +1 -1
  215. package/en/tutorials/first-app/c08-entries.mdx +1 -2
  216. package/en/tutorials/foundations/introduction.mdx +17 -34
  217. package/package.json +3 -3
  218. package/scripts/config.ts +3 -1
  219. package/scripts/summary.en.json +1 -1
  220. package/scripts/summary.zh.json +1 -1
  221. package/zh/apis/app/commands/_category_.json +1 -4
  222. package/zh/apis/app/hooks/_category_.json +1 -4
  223. package/zh/apis/app/hooks/src/pages.mdx +1 -1
  224. package/zh/apis/app/hooks/src/routes.mdx +1 -1
  225. package/zh/apis/app/runtime/_category_.json +1 -5
  226. package/zh/apis/app/runtime/core/create-app.mdx +1 -1
  227. package/zh/apis/app/runtime/core/use-module-apps.mdx +81 -40
  228. package/zh/apis/app/runtime/model/Provider.mdx +2 -2
  229. package/zh/apis/app/runtime/model/create-app.mdx +7 -7
  230. package/zh/apis/app/runtime/model/create-store.mdx +2 -2
  231. package/zh/apis/app/runtime/model/use-local-model.mdx +1 -1
  232. package/zh/apis/app/runtime/model/use-static-model.mdx +1 -1
  233. package/zh/apis/app/runtime/model/use-store.mdx +1 -1
  234. package/zh/apis/app/runtime/testing/renderApp.mdx +1 -1
  235. package/zh/components/custom-router-micro-frontend.mdx +40 -0
  236. package/zh/components/enable-micro-frontend.mdx +12 -2
  237. package/zh/components/micro-runtime-config.mdx +9 -10
  238. package/zh/components/release-note.mdx +1 -1
  239. package/zh/configure/app/builder-plugins.mdx +3 -3
  240. package/zh/configure/app/dev/asset-prefix.mdx +1 -1
  241. package/zh/configure/app/dev/hmr.mdx +1 -1
  242. package/zh/configure/app/dev/https.mdx +1 -1
  243. package/zh/configure/app/dev/port.mdx +1 -1
  244. package/zh/configure/app/dev/progress-bar.mdx +1 -1
  245. package/zh/configure/app/dev/start-url.mdx +1 -1
  246. package/zh/configure/app/experiments/lazy-compilation.mdx +1 -1
  247. package/zh/configure/app/html/app-icon.mdx +1 -1
  248. package/zh/configure/app/html/crossorigin.mdx +1 -1
  249. package/zh/configure/app/html/disable-html-folder.mdx +1 -1
  250. package/zh/configure/app/html/favicon-by-entries.mdx +1 -1
  251. package/zh/configure/app/html/favicon.mdx +1 -1
  252. package/zh/configure/app/html/inject-by-entries.mdx +1 -1
  253. package/zh/configure/app/html/inject.mdx +1 -1
  254. package/zh/configure/app/html/meta-by-entries.mdx +1 -1
  255. package/zh/configure/app/html/meta.mdx +1 -1
  256. package/zh/configure/app/html/mount-id.mdx +1 -1
  257. package/zh/configure/app/html/tags-by-entries.mdx +1 -1
  258. package/zh/configure/app/html/tags.mdx +1 -1
  259. package/zh/configure/app/html/template-by-entries.mdx +1 -1
  260. package/zh/configure/app/html/template-parameters-by-entries.mdx +1 -1
  261. package/zh/configure/app/html/template-parameters.mdx +1 -1
  262. package/zh/configure/app/html/template.mdx +1 -1
  263. package/zh/configure/app/html/title-by-entries.mdx +1 -1
  264. package/zh/configure/app/html/title.mdx +1 -1
  265. package/zh/configure/app/output/asset-prefix.mdx +1 -1
  266. package/zh/configure/app/output/assets-retry.mdx +1 -1
  267. package/zh/configure/app/output/charset.mdx +1 -1
  268. package/zh/configure/app/output/clean-dist-path.mdx +1 -1
  269. package/zh/configure/app/output/convert-to-rem.mdx +1 -1
  270. package/zh/configure/app/output/copy.mdx +1 -1
  271. package/zh/configure/app/output/css-module-local-ident-name.mdx +1 -1
  272. package/zh/configure/app/output/data-uri-limit.mdx +1 -1
  273. package/zh/configure/app/output/disable-css-extract.mdx +1 -1
  274. package/zh/configure/app/output/disable-css-module-extension.mdx +1 -1
  275. package/zh/configure/app/output/disable-filename-hash.mdx +1 -1
  276. package/zh/configure/app/output/disable-inline-runtime-chunk.mdx +1 -1
  277. package/zh/configure/app/output/disable-minimize.mdx +1 -1
  278. package/zh/configure/app/output/disable-source-map.mdx +1 -1
  279. package/zh/configure/app/output/disable-ts-checker.mdx +1 -1
  280. package/zh/configure/app/output/dist-path.mdx +1 -1
  281. package/zh/configure/app/output/enable-asset-fallback.mdx +1 -1
  282. package/zh/configure/app/output/enable-asset-manifest.mdx +1 -1
  283. package/zh/configure/app/output/enable-css-module-tsdeclaration.mdx +1 -1
  284. package/zh/configure/app/output/enable-inline-scripts.mdx +1 -1
  285. package/zh/configure/app/output/enable-inline-styles.mdx +1 -1
  286. package/zh/configure/app/output/enable-latest-decorators.mdx +1 -1
  287. package/zh/configure/app/output/externals.mdx +1 -1
  288. package/zh/configure/app/output/filename.mdx +1 -1
  289. package/zh/configure/app/output/legal-comments.mdx +1 -1
  290. package/zh/configure/app/output/override-browserslist.mdx +1 -1
  291. package/zh/configure/app/output/polyfill.mdx +1 -1
  292. package/zh/configure/app/output/svg-default-export.mdx +1 -1
  293. package/zh/configure/app/performance/build-cache.mdx +1 -1
  294. package/zh/configure/app/performance/bundle-analyze.mdx +1 -1
  295. package/zh/configure/app/performance/chunk-split.mdx +1 -1
  296. package/zh/configure/app/performance/print-file-size.mdx +1 -1
  297. package/zh/configure/app/performance/profile.mdx +1 -1
  298. package/zh/configure/app/performance/remove-console.mdx +1 -1
  299. package/zh/configure/app/performance/remove-moment-locale.mdx +1 -1
  300. package/zh/configure/app/plugins.mdx +1 -1
  301. package/zh/configure/app/security/check-syntax.mdx +1 -1
  302. package/zh/configure/app/security/sri.mdx +1 -1
  303. package/zh/configure/app/server/ssr-by-entries.mdx +1 -1
  304. package/zh/configure/app/source/alias.mdx +1 -1
  305. package/zh/configure/app/source/compile-js-data-uri.mdx +1 -1
  306. package/zh/configure/app/source/define.mdx +1 -1
  307. package/zh/configure/app/source/exclude.mdx +1 -1
  308. package/zh/configure/app/source/global-vars.mdx +1 -1
  309. package/zh/configure/app/source/include.mdx +1 -1
  310. package/zh/configure/app/source/module-scopes.mdx +1 -1
  311. package/zh/configure/app/source/pre-entry.mdx +1 -1
  312. package/zh/configure/app/source/resolve-extension-prefix.mdx +1 -1
  313. package/zh/configure/app/source/resolve-main-fields.mdx +1 -1
  314. package/zh/configure/app/tools/autoprefixer.mdx +1 -1
  315. package/zh/configure/app/tools/babel.mdx +1 -1
  316. package/zh/configure/app/tools/css-extract.mdx +1 -1
  317. package/zh/configure/app/tools/css-loader.mdx +1 -1
  318. package/zh/configure/app/tools/dev-server.mdx +1 -1
  319. package/zh/configure/app/tools/html-plugin.mdx +1 -1
  320. package/zh/configure/app/tools/inspector.mdx +1 -1
  321. package/zh/configure/app/tools/less.mdx +1 -1
  322. package/zh/configure/app/tools/minify-css.mdx +1 -1
  323. package/zh/configure/app/tools/postcss.mdx +1 -1
  324. package/zh/configure/app/tools/pug.mdx +1 -1
  325. package/zh/configure/app/tools/rspack.mdx +13 -0
  326. package/zh/configure/app/tools/sass.mdx +1 -1
  327. package/zh/configure/app/tools/style-loader.mdx +1 -1
  328. package/zh/configure/app/tools/styled-components.mdx +1 -1
  329. package/zh/configure/app/tools/terser.mdx +1 -1
  330. package/zh/configure/app/tools/ts-checker.mdx +1 -1
  331. package/zh/configure/app/tools/ts-loader.mdx +1 -1
  332. package/zh/configure/app/tools/webpack-chain.mdx +1 -1
  333. package/zh/configure/app/tools/webpack.mdx +1 -1
  334. package/zh/configure/app/usage.mdx +64 -1
  335. package/zh/guides/advanced-features/_category_.json +2 -6
  336. package/zh/guides/advanced-features/compatibility.mdx +0 -1
  337. package/zh/guides/advanced-features/ssg.mdx +0 -1
  338. package/zh/guides/advanced-features/ssr.mdx +2 -2
  339. package/zh/guides/advanced-features/testing.mdx +0 -1
  340. package/zh/guides/advanced-features/web-server.mdx +0 -1
  341. package/zh/guides/basic-features/_category_.json +1 -5
  342. package/zh/guides/basic-features/alias.mdx +1 -1
  343. package/zh/guides/basic-features/data-fetch.mdx +35 -26
  344. package/zh/guides/basic-features/html.mdx +10 -9
  345. package/zh/guides/basic-features/mock.mdx +20 -0
  346. package/zh/guides/basic-features/routes.mdx +41 -9
  347. package/zh/guides/{basic-features → concept}/builder.mdx +2 -2
  348. package/zh/guides/concept/entries.mdx +11 -11
  349. package/zh/guides/css/_category_.json +5 -0
  350. package/zh/guides/{basic-features/css → css}/css-in-js.mdx +0 -0
  351. package/zh/guides/{basic-features/css → css}/css-modules.mdx +0 -0
  352. package/zh/guides/{basic-features/css → css}/less-sass.mdx +1 -1
  353. package/zh/guides/{basic-features/css → css}/postcss.mdx +5 -4
  354. package/zh/guides/{basic-features/css → css}/tailwindcss.mdx +0 -1
  355. package/zh/guides/get-started/introduction.mdx +31 -0
  356. package/zh/guides/get-started/quick-start.mdx +2 -3
  357. package/zh/guides/get-started/upgrade.mdx +2 -1
  358. package/zh/guides/topic-detail/_category_.json +2 -2
  359. package/zh/guides/topic-detail/generator/config/{mwa.mdx → app.mdx} +1 -1
  360. package/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +1 -1
  361. package/zh/guides/topic-detail/generator/plugin/api/new/createElement.mdx +1 -1
  362. package/zh/guides/topic-detail/generator/plugin/api/new/enableFunc.mdx +1 -1
  363. package/zh/guides/topic-detail/generator/plugin/api/new/introduce.mdx +2 -2
  364. package/zh/guides/topic-detail/generator/plugin/develop.mdx +3 -3
  365. package/zh/guides/topic-detail/micro-frontend/c02-development.mdx +155 -63
  366. package/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +71 -40
  367. package/zh/guides/topic-detail/model/model-communicate.mdx +1 -1
  368. package/zh/guides/troubleshooting/_category_.json +2 -2
  369. package/zh/index.md +1 -1
  370. package/zh/tutorials/first-app/_category_.json +1 -1
  371. package/zh/tutorials/first-app/c01-start.mdx +1 -2
  372. package/zh/tutorials/first-app/c03-css.mdx +1 -2
  373. package/zh/tutorials/first-app/c06-model.mdx +2 -2
  374. package/zh/tutorials/first-app/c07-container.mdx +1 -1
  375. package/zh/tutorials/first-app/c08-entries.mdx +2 -3
  376. package/zh/tutorials/foundations/introduction.mdx +14 -29
  377. package/en/apis/app/commands/index.mdx +0 -7
  378. package/en/apis/app/hooks/index.mdx +0 -7
  379. package/en/apis/app/runtime/index.mdx +0 -7
  380. package/en/guides/advanced-features/index.mdx +0 -7
  381. package/en/guides/basic-features/css/_category_.json +0 -4
  382. package/zh/apis/app/commands/index.mdx +0 -7
  383. package/zh/apis/app/hooks/index.mdx +0 -7
  384. package/zh/apis/app/runtime/index.mdx +0 -7
  385. package/zh/guides/advanced-features/index.mdx +0 -7
  386. package/zh/guides/basic-features/css/_category_.json +0 -4
  387. package/zh/guides/basic-features/index.mdx +0 -7
@@ -5,7 +5,7 @@ sidebar_label: less
5
5
  # tools.less
6
6
 
7
7
  :::tip
8
- 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.less](https://modernjs.dev/builder/api/config-tools.html#tools-less)。
8
+ 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.less](https://modernjs.dev/builder/api/config-tools.html#toolsless)。
9
9
  :::
10
10
 
11
11
  import Main from '@modern-js/builder-doc/docs/zh/config/tools/less.md'
@@ -5,7 +5,7 @@ sidebar_label: minifyCss
5
5
  # tools.minifyCss
6
6
 
7
7
  :::tip
8
- 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.minifyCss](https://modernjs.dev/builder/api/config-tools.html#tools-minifycss)。
8
+ 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.minifyCss](https://modernjs.dev/builder/api/config-tools.html#toolsminifycss)。
9
9
  :::
10
10
 
11
11
  import Main from '@modern-js/builder-doc/docs/zh/config/tools/minifyCss.md'
@@ -5,7 +5,7 @@ sidebar_label: postcss
5
5
  # tools.postcss
6
6
 
7
7
  :::tip
8
- 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.postcss](https://modernjs.dev/builder/api/config-tools.html#tools-postcss)。
8
+ 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.postcss](https://modernjs.dev/builder/api/config-tools.html#toolspostcss)。
9
9
  :::
10
10
 
11
11
  import Main from '@modern-js/builder-doc/docs/zh/config/tools/postcss.md'
@@ -5,7 +5,7 @@ sidebar_label: pug
5
5
  # tools.pug
6
6
 
7
7
  :::tip
8
- 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.pug](https://modernjs.dev/builder/api/config-tools.html#tools-pug)。
8
+ 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.pug](https://modernjs.dev/builder/api/config-tools.html#toolspug)。
9
9
  :::
10
10
 
11
11
  import Main from '@modern-js/builder-doc/docs/zh/config/tools/pug.md'
@@ -0,0 +1,13 @@
1
+ ---
2
+ sidebar_label: rspack
3
+ ---
4
+
5
+ # tools.rspack
6
+
7
+ :::tip
8
+ 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.rspack](https://modernjs.dev/builder/api/config-tools.html#toolsrspack)。
9
+ :::
10
+
11
+ import Main from '@modern-js/builder-doc/docs/zh/config/tools/rspack.md'
12
+
13
+ <Main />
@@ -5,7 +5,7 @@ sidebar_label: sass
5
5
  # tools.sass
6
6
 
7
7
  :::tip
8
- 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.sass](https://modernjs.dev/builder/api/config-tools.html#tools-sass)。
8
+ 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.sass](https://modernjs.dev/builder/api/config-tools.html#toolssass)。
9
9
  :::
10
10
 
11
11
  import Main from '@modern-js/builder-doc/docs/zh/config/tools/sass.md'
@@ -5,7 +5,7 @@ sidebar_label: styleLoader
5
5
  # tools.styleLoader
6
6
 
7
7
  :::tip
8
- 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.styleLoader](https://modernjs.dev/builder/api/config-tools.html#tools-styleloader)。
8
+ 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.styleLoader](https://modernjs.dev/builder/api/config-tools.html#toolsstyleloader)。
9
9
  :::
10
10
 
11
11
  import Main from '@modern-js/builder-doc/docs/zh/config/tools/styleLoader.md'
@@ -5,7 +5,7 @@ sidebar_label: styledComponents
5
5
  # tools.styledComponents
6
6
 
7
7
  :::tip
8
- 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.styledComponents](https://modernjs.dev/builder/api/config-tools.html#tools-styledcomponents)。
8
+ 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.styledComponents](https://modernjs.dev/builder/api/config-tools.html#toolsstyledcomponents)。
9
9
  :::
10
10
 
11
11
  import Main from '@modern-js/builder-doc/docs/zh/config/tools/styledComponents.md'
@@ -5,7 +5,7 @@ sidebar_label: terser
5
5
  # tools.terser
6
6
 
7
7
  :::tip
8
- 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.terser](https://modernjs.dev/builder/api/config-tools.html#tools-terser)。
8
+ 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.terser](https://modernjs.dev/builder/api/config-tools.html#toolsterser)。
9
9
  :::
10
10
 
11
11
  import Main from '@modern-js/builder-doc/docs/zh/config/tools/terser.md'
@@ -5,7 +5,7 @@ sidebar_label: tsChecker
5
5
  # tools.tsChecker
6
6
 
7
7
  :::tip
8
- 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.tsChecker](https://modernjs.dev/builder/api/config-tools.html#tools-tschecker)。
8
+ 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.tsChecker](https://modernjs.dev/builder/api/config-tools.html#toolstschecker)。
9
9
  :::
10
10
 
11
11
  import Main from '@modern-js/builder-doc/docs/zh/config/tools/tsChecker.md'
@@ -5,7 +5,7 @@ sidebar_label: tsLoader
5
5
  # tools.tsLoader
6
6
 
7
7
  :::tip
8
- 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.tsLoader](https://modernjs.dev/builder/api/config-tools.html#tools-tsloader)。
8
+ 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.tsLoader](https://modernjs.dev/builder/api/config-tools.html#toolstsloader)。
9
9
  :::
10
10
 
11
11
  import Main from '@modern-js/builder-doc/docs/zh/config/tools/tsLoader.md'
@@ -5,7 +5,7 @@ sidebar_label: webpackChain
5
5
  # tools.webpackChain
6
6
 
7
7
  :::tip
8
- 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.webpackChain](https://modernjs.dev/builder/api/config-tools.html#tools-webpackchain)。
8
+ 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.webpackChain](https://modernjs.dev/builder/api/config-tools.html#toolswebpackchain)。
9
9
  :::
10
10
 
11
11
  import Main from '@modern-js/builder-doc/docs/zh/config/tools/webpackChain.md'
@@ -5,7 +5,7 @@ sidebar_label: webpack
5
5
  # tools.webpack
6
6
 
7
7
  :::tip
8
- 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.webpack](https://modernjs.dev/builder/api/config-tools.html#tools-webpack)。
8
+ 该配置由 Modern.js Builder 提供,更多信息可参考 [tools.webpack](https://modernjs.dev/builder/api/config-tools.html#toolswebpack)。
9
9
  :::
10
10
 
11
11
  import Main from '@modern-js/builder-doc/docs/zh/config/tools/webpack.md'
@@ -12,7 +12,7 @@ Modern.js 中有两种配置,一个是编译时配置,一个是服务端运
12
12
  - `package.json` 文件
13
13
 
14
14
  :::info
15
- 不支持同时在 package.json 中和 modern.config.ts 中配置同一个配置项,推荐优先在 modern.config.ts 中进行配置。如果 Modern.js 检测到重复配置导致的冲突,将会抛出警告。
15
+ Modern.js 不支持同时在 package.json 中和 modern.config.ts 中配置同一个配置项,推荐优先在 modern.config.ts 中进行配置。如果 Modern.js 检测到重复配置导致的冲突,将会抛出警告。
16
16
  :::
17
17
 
18
18
  服务端运行时配置可以在根路径下的 `modern.server-runtime.config.(ts|js|mjs)` 中自定义配置选项。
@@ -69,6 +69,69 @@ export default defineConfig({
69
69
  });
70
70
  ```
71
71
 
72
+ ### 导出配置函数
73
+
74
+ Modern.js 支持在配置文件中导出一个函数,你可以在函数中动态计算配置,并返回给 Modern.js。
75
+
76
+ ```js title="modern.config.js"
77
+ import { defineConfig } from '@modern-js/app-tools';
78
+
79
+ export default defineConfig(({ env, command }) => ({
80
+ source: {
81
+ alias: {
82
+ '@foo': env === 'development' ? './src/foo.dev.ts' : './src/foo.prod.ts',
83
+ },
84
+ },
85
+ }));
86
+ ```
87
+
88
+ 该函数接受以下入参:
89
+
90
+ - `env`:对应 `process.env.NODE_ENV` 的值。
91
+ - 当运行 `modern dev` 或 `modern start` 时,`env` 的值为 `development`。
92
+ - 当运行 `modern build` 或 `modern serve` 时,`env` 的值为 `production`。
93
+ - 当运行 `modern test` 时,`env` 的值为 `test`。
94
+ - `command`: 对应当前运行的命令,如 `dev`、`start`、`build`、`serve`。
95
+
96
+ ### 导出异步函数
97
+
98
+ Modern.js 也支持在配置文件中导出一个异步函数,你可以在函数中进行一些异步操作:
99
+
100
+ ```js title="modern.config.js"
101
+ import { defineConfig } from '@modern-js/app-tools';
102
+
103
+ export default defineConfig(async ({ env, command }) => {
104
+ const result = await someAsyncFunction();
105
+
106
+ return {
107
+ html: {
108
+ title: result,
109
+ },
110
+ };
111
+ });
112
+ ```
113
+
114
+ ### 指定配置文件
115
+
116
+ Modern.js 命令行支持通过 `--config` 选项来指定配置文件的名称。
117
+
118
+ 例如,你需要在执行 build 命令时使用 `modern.prod.config.ts` 文件,可以在 `package.json` 中添加如下配置:
119
+
120
+ ```json title="package.json"
121
+ {
122
+ "scripts": {
123
+ "dev": "modern modern",
124
+ "build": "modern build --config modern.prod.config.ts"
125
+ }
126
+ }
127
+ ```
128
+
129
+ 你也可以将 `--config` 选项缩写为 `-c`:
130
+
131
+ ```bash
132
+ $ modern build -c modern.prod.config.js
133
+ ```
134
+
72
135
  ## 在 package.json 中配置(不推荐)
73
136
 
74
137
  除了配置文件外,也可以在 `package.json` 中的 `modernConfig` 字段下设置配置选项,如:
@@ -1,9 +1,5 @@
1
1
  {
2
2
  "label": "进阶功能",
3
- "position": 4,
4
- "collapsed": true,
5
- "link": {
6
- "type": "doc",
7
- "id": "guides/advanced-features/index"
8
- }
3
+ "position": 6,
4
+ "collapsed": false
9
5
  }
@@ -55,7 +55,6 @@ Modern.js 中还提供了基于浏览器 [UA](https://developer.mozilla.org/zh-C
55
55
  ```ts title="modern.config.ts"
56
56
  import polyfillPlugin from '@modern-js/plugin-polyfill';
57
57
 
58
- // https://modernjs.dev/docs/apis/app/config
59
58
  export default defineConfig({
60
59
  plugins: [..., polyfillPlugin()],
61
60
  });
@@ -18,7 +18,6 @@ SSG(Static Site Generation)是一种基于数据与模板,在构建时渲
18
18
  ```ts title="modern.config.ts"
19
19
  import ssgPlugin from '@modern-js/plugin-ssg';
20
20
 
21
- // https://modernjs.dev/docs/apis/app/config
22
21
  export default defineConfig({
23
22
  output: {
24
23
  ssg: true,
@@ -242,11 +242,11 @@ if (process.env.MODERN_TARGET === 'browser') {
242
242
  例如在代码中引入了 `fs-extra`,这时候直接引用到组件中,会造成 CSR 加载报错。可以创建同名的 `.ts` 和 `.node.ts` 文件做一层代理:
243
243
 
244
244
  ```ts title="compat.ts"
245
- export { readFileSync } from 'fs-extra';
245
+ export const readFileSync: any = () => {};
246
246
  ```
247
247
 
248
248
  ```ts title="compat.node.ts"
249
- export const readFileSync: any = () => {};
249
+ export { readFileSync } from 'fs-extra';
250
250
  ```
251
251
 
252
252
  在文件中直接引入 `./compat`,此时 SSR 环境下会优先使用 `.node.ts` 后缀的文件,CSR 环境下会使用 `.ts` 后缀的文件。
@@ -20,7 +20,6 @@ Modern.js 默认继承了 [Jest](https://jestjs.io/) 的测试能力。
20
20
  ```ts title="modern.config.ts"
21
21
  import testPlugin from '@modern-js/plugin-testing';
22
22
 
23
- // https://modernjs.dev/docs/apis/app/config
24
23
  export default defineConfig({
25
24
  ...,
26
25
  plugins: [..., testPlugin()],
@@ -22,7 +22,6 @@ Modern.js 作为以客户端为中心的开发框架,对服务端的定制能
22
22
  ```ts title="modern.config.ts"
23
23
  import serverPlugin from '@modern-js/plugin-server';
24
24
 
25
- // https://modernjs.dev/docs/apis/app/config
26
25
  export default defineConfig({
27
26
  plugins: [..., serverPlugin()],
28
27
  });
@@ -1,9 +1,5 @@
1
1
  {
2
2
  "label": "基础功能",
3
3
  "position": 3,
4
- "collapsed": false,
5
- "link": {
6
- "type": "doc",
7
- "id": "guides/basic-features/index"
8
- }
4
+ "collapsed": false
9
5
  }
@@ -62,4 +62,4 @@ export default defineConfig({
62
62
  });
63
63
  ```
64
64
 
65
- 具体别名配置可以参考 [API 资料 - source.alias](/configure/app/source/alias)】。
65
+ 对于别名配置的具体用法,请参考 [source.alias 文档](/configure/app/source/alias)
@@ -2,6 +2,7 @@
2
2
  title: 数据获取
3
3
  sidebar_position: 3
4
4
  ---
5
+
5
6
  # 数据获取
6
7
 
7
8
  Modern.js 中提供了开箱即用的数据获取能力,开发者可以通过这些 API,在 CSR 和 SSR 环境同构的进行开发。
@@ -220,38 +221,46 @@ export default function UserLayout() {
220
221
 
221
222
  :::
222
223
 
224
+ 创建 `user/layout.loader.ts`,并添加以下代码:
225
+
226
+ ```ts title="routes/user/layout.loader.ts"
227
+ import { defer } from "@edenx/runtime/router"
228
+
229
+ const loader = () =>
230
+ defer({
231
+ userInfo: new Promise((resolve) => {
232
+ setTimeout(() => {
233
+ resolve({
234
+ age: 1,
235
+ name: 'user layout'
236
+ })
237
+ }, 1000)
238
+ })
239
+ })
240
+
241
+ export default loader;
242
+ ```
243
+
223
244
  在 `user/layout.tsx` 中添加以下代码:
224
245
 
225
246
  ```tsx title="routes/user/layout.tsx"
226
- import {
227
- Await,
228
- defer,
229
- useLoaderData,
230
- Outlet
231
- } from '@modern-js/runtime/router';
232
-
233
- export const loader = () => {
234
- return defer({
235
- // fetchUserInfo 是一个异步函数,返回用户信息
236
- userInfo: fetchUserInfo(),
237
- })
238
- }
247
+ import { Await, defer, useLoaderData, Outlet } from '@modern-js/runtime/router';
239
248
 
240
249
  export default function UserLayout() {
241
- const { userInfo } = useLoaderData() as {userInfo: Promise<UserInfo>};
250
+ const { userInfo } = useLoaderData() as { userInfo: Promise<UserInfo> };
242
251
  return (
243
252
  <div>
244
- <React.Suspense
245
- fallback={<p>Loading...</p>}
246
- >
247
- <Await resolve={userInfo} children={userInfo => (
248
- <div>
249
- <span>{userInfo.name}</span>
250
- <span>{userInfo.age}</span>
251
- <Outlet>
252
- </div>
253
- )}>
254
- </Await>
253
+ <React.Suspense fallback={<p>Loading...</p>}>
254
+ <Await
255
+ resolve={userInfo}
256
+ children={userInfo => (
257
+ <div>
258
+ <span>{userInfo.name}</span>
259
+ <span>{userInfo.age}</span>
260
+ <Outlet />
261
+ </div>
262
+ )}
263
+ ></Await>
255
264
  </React.Suspense>
256
265
  </div>
257
266
  );
@@ -265,7 +274,7 @@ defer 的具体用法请查看 [defer](https://reactrouter.com/en/main/guides/de
265
274
 
266
275
  :::
267
276
 
268
- {/* TODO 缓存相关 */}
277
+ {/* TODO 缓存相关 */}
269
278
 
270
279
  ### 错误用法
271
280
 
@@ -2,9 +2,10 @@
2
2
  title: HTML 模板
3
3
  sidebar_position: 9
4
4
  ---
5
+
5
6
  # HTML 模板
6
7
 
7
- Modern.js 提供了 **JSX 语法**和**HTML(Ejs) 语法**两种方式用于自定义 HTML 模板。
8
+ Modern.js 提供了 **JSX 语法**和 **HTML(EJS) 语法**两种方式用于自定义 HTML 模板。
8
9
 
9
10
  ## JSX 语法
10
11
 
@@ -14,14 +15,14 @@ Modern.js 约定,在 `src/` 目录下,或在入口目录下,可以创建 `
14
15
 
15
16
  ```bash
16
17
  .
17
- ├── src
18
- │   ├── Document.tsx
19
- │   ├── entry-a
20
-    │   ├── Document.tsx
21
-    │   └── routes
22
- │   ├── entry-b
23
-    │   └── routes
24
- │   └── modern-app-env.d.ts
18
+ └── src
19
+ ├── Document.tsx
20
+ ├── entry-a
21
+ ├── Document.tsx
22
+ └── routes
23
+ ├── entry-b
24
+ └── routes
25
+ └── modern-app-env.d.ts
25
26
  ```
26
27
 
27
28
  `entry-a` 会优先使用当前入口下的 `Docoument.[jt]sx` 文件。如果当前入口没有 `Document.[jt]sx` 文件,例如 `entry-b`,则会查找根目录下的 `Document.[jt]sx` 文件。
@@ -77,3 +77,23 @@ module.exports = {
77
77
  },
78
78
  };
79
79
  ```
80
+
81
+ ## 按需使用 Mock 服务
82
+
83
+ `config/mock/index.ts` 下还可以到处 `config` 对象,更精细的控制 Mock 服务。
84
+
85
+ ```ts
86
+ type MockConfig = {
87
+ enable: ((req: IncomingMessage, res: ServerResponse) => boolean) | boolean;
88
+ };
89
+
90
+ export const config = {
91
+ enable: false
92
+ }
93
+ ```
94
+
95
+ 目前仅支持 `enable` 配置,开发者可以通过该配置控制是否执行 Mock。
96
+
97
+ :::note
98
+ 修改 `config` 后无需重启服务,即刻生效。
99
+ :::
@@ -4,7 +4,7 @@ sidebar_position: 1
4
4
  ---
5
5
  # 路由
6
6
 
7
- Modern.js 内置了对 [React Router 6](https://reactrouter.com/en/main) 的**部分**支持,并提供了多种类型的路由模式。根据不同[入口](/guides/concept/entries)类型,将路由分为三种模式,分别是**约定式路由**,**自控式路由**和**其他路由方案**。
7
+ Modern.js 的路由基于 [React Router 6](https://reactrouter.com/en/main),并提供了多种类型的路由模式。根据不同 [入口](/guides/concept/entries) 类型,将路由分为三种模式,分别是**约定式路由**,**自控式路由**和**其他路由方案**。
8
8
 
9
9
  :::note
10
10
  本小节提到的路由,都是客户端路由,即 SPA 路由。
@@ -164,10 +164,37 @@ export default () => {
164
164
 
165
165
  `routes/[id]/page.tsx` 文件会转为 `/:id` 路由。除了可以确切匹配的 `/blog` 路由,其他所有 `/xxx` 都会匹配到该路由。
166
166
 
167
- 在组件中,可以通过 [useParams](/apis/app/runtime/router/#useparams) 获取对应命名的参数。
167
+ 在组件中,可以通过 [useParams](/apis/app/runtime/router/router#useparams) 获取对应命名的参数。
168
168
 
169
169
  在 loader 中,params 会作为 [loader](/guides/basic-features/data-fetch#loader-函数) 的入参,通过 `params.xxx` 可以获取。
170
170
 
171
+ ### 通配路由
172
+
173
+ 如果在 routes 目录下创建 `$.tsx` 文件,该文件会作为通配路由组件,当没有匹配的路由时,会渲染该路由组件。
174
+
175
+ :::note
176
+ `$.tsx` 可以认为是一种特殊的 `page` 路由组件,当前目录下有 `layout` 组件时,`$.tsx`,会作为 `layout` 的子组件渲染。
177
+ :::
178
+
179
+ 例如以下目录结构:
180
+ ```
181
+ └── routes
182
+ ├── $.tsx
183
+ ├── blog
184
+ │   └── page.tsx
185
+ └── page.tsx
186
+ ```
187
+
188
+ 当访问任何匹配不到的路径时,都会渲染 `routes/$.tsx` 组件,同样,`$.tsx` 中可以使用 [useParams](/apis/app/runtime/router/router#useparams) 捕获 url 的剩余部分。
189
+ ```ts title="$.tsx"
190
+ import { useParams } from '@modern-js/runtime/router';
191
+ // 当 path 是 `/aaa/bbb` 时
192
+ const params = useParams();
193
+ params['*'] // => 'aaa/bbb'
194
+ ```
195
+
196
+ `$.tsx` 可以加入到 `routes` 目录下的任意目录中,一个常见的使用示例是添加 `routes/$.tsx` 文件去定制任意层级的 404 页面。
197
+
171
198
  ### 无路径布局
172
199
 
173
200
  当目录名以 \_\_ 开头时,对应的目录名不会转换为实际的路由路径,例如以下文件目录:
@@ -275,7 +302,7 @@ Modern.js 建议必须有根 layout 和根 loading。
275
302
 
276
303
  {/* Todo API 路由 */}
277
304
 
278
- 在 `<ErrorBoundary>` 组件内,可以使用 [useRouteError](/apis/app/runtime/router/#useparams) 获取的错误的具体信息:
305
+ 在 `<ErrorBoundary>` 组件内,可以使用 [useRouteError](/apis/app/runtime/router/router#useparams) 获取的错误的具体信息:
279
306
 
280
307
  ```tsx
281
308
  import { useRouteError } from '@modern-js/runtime/router';
@@ -302,8 +329,15 @@ import type { AppConfig } from '@modern-js/runtime';
302
329
  export const config = (): AppConfig => {
303
330
  return {
304
331
  router: {
305
- supportHtml5History: false
306
- }
332
+ createRoutes() {
333
+ return [
334
+ {
335
+ path: 'edenx',
336
+ element: <div>edenx</div>,
337
+ },
338
+ ];
339
+ },
340
+ },
307
341
  }
308
342
  };
309
343
  ```
@@ -353,12 +387,10 @@ export default () => {
353
387
  配合 SSR 功能时,浏览器端可以获取到 SSR 时 `init` 返回的数据,开发者可以自行判断是否要在浏览器端重新获取数据来覆盖 SSR 数据,例如:
354
388
 
355
389
  ```tsx title="src/routes/layout.tsx"
356
- import {
357
- RuntimeContext,
358
- } from '@modern-js/runtime';
390
+ import { RuntimeContext } from '@modern-js/runtime';
359
391
 
360
392
  export const init = (context: RuntimeContext) => {
361
- if (process.env.JUPITER_TARGET === 'node') {
393
+ if (process.env.MODERN_TARGET === 'node') {
362
394
  return {
363
395
  message: 'Hello World By Server',
364
396
  }
@@ -1,8 +1,8 @@
1
1
  ---
2
- title: 构建能力
3
2
  sidebar_position: 2
4
3
  ---
5
- # 构建能力
4
+
5
+ # 构建引擎
6
6
 
7
7
  **Modern.js 的构建能力由 [Modern.js Builder](https://modernjs.dev/builder) 提供。**
8
8
 
@@ -1,7 +1,7 @@
1
1
  ---
2
- title: 入口
3
- sidebar_position: 2
2
+ sidebar_position: 1
4
3
  ---
4
+
5
5
  # 入口
6
6
 
7
7
  入口是 Modern.js 默认的文件约定,项目的每一个入口是一张独立的页面,对应一条**服务端路由**。
@@ -15,11 +15,11 @@ Modern.js 初始化的项目是单入口的,项目结构如下:
15
15
  ```
16
16
  .
17
17
  ├── src
18
-    ├── modern-app-env.d.ts
19
-    └── routes
20
-    ├── index.css
21
-    ├── layout.tsx
22
-    └── page.tsx
18
+ ├── modern-app-env.d.ts
19
+ └── routes
20
+ ├── index.css
21
+ ├── layout.tsx
22
+ └── page.tsx
23
23
  ├── package.json
24
24
  ├── modern.config.ts
25
25
  ├── pnpm-lock.yaml
@@ -41,10 +41,10 @@ Modern.js 可以很方便的将单入口切换成多入口。可以在项目下
41
41
  .
42
42
  ├── modern-app-env.d.ts
43
43
  ├── myapp
44
-    └── routes
45
-    ├── index.css
46
-    ├── layout.tsx
47
-    └── page.tsx
44
+ └── routes
45
+ ├── index.css
46
+ ├── layout.tsx
47
+ └── page.tsx
48
48
  └── new-entry
49
49
  └── routes
50
50
  ├── index.css
@@ -0,0 +1,5 @@
1
+ {
2
+ "label": "CSS 开发方案",
3
+ "position": 5,
4
+ "collapsed": false
5
+ }
@@ -12,6 +12,6 @@ sidebar_position: 4
12
12
  - 如果需要自定义 [sass-loader](https://github.com/webpack-contrib/sass-loader) 的配置,请参考 [tools.less](/configure/app/tools/sass) 配置项。
13
13
 
14
14
  :::tip 提示
15
- 经过 Less 和 Sass 预编译后的 CSS 文件,仍然会经过 Modern.js 内置的 [PostCSS](https://postcss.org/) 的转换,具备良好的浏览器兼容性。相关内容请参考【[PostCSS](/guides/basic-features/css/postcss)】。
15
+ 经过 Less 和 Sass 预编译后的 CSS 文件,仍然会经过 Modern.js 内置的 [PostCSS](https://postcss.org/) 的转换,具备良好的浏览器兼容性。相关内容请参考【[PostCSS](/guides/css/postcss)】。
16
16
 
17
17
  :::
@@ -10,10 +10,11 @@ sidebar_position: 3
10
10
 
11
11
  1. [Autoprefixer](https://github.com/postcss/autoprefixer) 根据需要支持的浏览器范围,会自动为 CSS 规则添加需要的浏览器厂商前缀。Modern.js 默认支持的浏览器范围为:`['> 0.01%', 'not dead', 'not op_mini all']`。
12
12
 
13
- :::info
14
- - 【支持的浏览器范围为:`> 0.01%`】是指浏览器市场份额大于 0.01%。
15
- - `not dead` 是指不包含官方不再支持的浏览器和过去24个月没有更新的浏览器。
16
- - `not op_mini all` 是指不包含 Opera Mini。
13
+ :::info 注意
14
+
15
+ - 【支持的浏览器范围为:`> 0.01%`】是指浏览器市场份额大于 0.01%。
16
+ - `not dead` 是指不包含官方不再支持的浏览器和过去 24 个月没有更新的浏览器。
17
+ - `not op_mini all` 是指不包含 Opera Mini。
17
18
 
18
19
  :::
19
20
 
@@ -18,7 +18,6 @@ sidebar_position: 2
18
18
  ```ts title="modern.config.ts"
19
19
  import tailwindcssPlugin from '@modern-js/plugin-tailwindcss';
20
20
 
21
- // https://modernjs.dev/docs/apis/app/config
22
21
  export default defineConfig({
23
22
  plugins: [..., tailwindcssPlugin()],
24
23
  });