@modern-js/main-doc 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (280) 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/configure/app/bff/_category_.json +4 -0
  40. package/en/configure/app/builder-plugins.mdx +3 -3
  41. package/en/configure/app/deploy/_category_.json +4 -0
  42. package/en/configure/app/dev/_category_.json +4 -0
  43. package/en/configure/app/dev/asset-prefix.mdx +1 -1
  44. package/en/configure/app/dev/hmr.mdx +1 -1
  45. package/en/configure/app/dev/https.mdx +1 -1
  46. package/en/configure/app/dev/port.mdx +1 -1
  47. package/en/configure/app/dev/progress-bar.mdx +1 -1
  48. package/en/configure/app/dev/start-url.mdx +1 -1
  49. package/en/configure/app/experiments/_category_.json +4 -0
  50. package/en/configure/app/experiments/lazy-compilation.mdx +1 -1
  51. package/en/configure/app/html/_category_.json +4 -0
  52. package/en/configure/app/html/app-icon.mdx +1 -1
  53. package/en/configure/app/html/crossorigin.mdx +1 -1
  54. package/en/configure/app/html/disable-html-folder.mdx +1 -1
  55. package/en/configure/app/html/favicon-by-entries.mdx +1 -1
  56. package/en/configure/app/html/favicon.mdx +1 -1
  57. package/en/configure/app/html/inject-by-entries.mdx +1 -1
  58. package/en/configure/app/html/inject.mdx +1 -1
  59. package/en/configure/app/html/meta-by-entries.mdx +1 -1
  60. package/en/configure/app/html/meta.mdx +1 -1
  61. package/en/configure/app/html/mount-id.mdx +1 -1
  62. package/en/configure/app/html/tags-by-entries.mdx +1 -1
  63. package/en/configure/app/html/tags.mdx +1 -1
  64. package/en/configure/app/html/template-by-entries.mdx +1 -1
  65. package/en/configure/app/html/template-parameters-by-entries.mdx +1 -1
  66. package/en/configure/app/html/template-parameters.mdx +1 -1
  67. package/en/configure/app/html/template.mdx +1 -1
  68. package/en/configure/app/html/title-by-entries.mdx +1 -1
  69. package/en/configure/app/html/title.mdx +1 -1
  70. package/en/configure/app/output/_category_.json +4 -0
  71. package/en/configure/app/output/asset-prefix.mdx +1 -1
  72. package/en/configure/app/output/assets-retry.mdx +1 -1
  73. package/en/configure/app/output/charset.mdx +1 -1
  74. package/en/configure/app/output/clean-dist-path.mdx +1 -1
  75. package/en/configure/app/output/convert-to-rem.mdx +1 -1
  76. package/en/configure/app/output/copy.mdx +1 -1
  77. package/en/configure/app/output/css-module-local-ident-name.mdx +1 -1
  78. package/en/configure/app/output/data-uri-limit.mdx +1 -1
  79. package/en/configure/app/output/disable-css-extract.mdx +1 -1
  80. package/en/configure/app/output/disable-css-module-extension.mdx +1 -1
  81. package/en/configure/app/output/disable-filename-hash.mdx +1 -1
  82. package/en/configure/app/output/disable-inline-runtime-chunk.mdx +1 -1
  83. package/en/configure/app/output/disable-minimize.mdx +1 -1
  84. package/en/configure/app/output/disable-source-map.mdx +1 -1
  85. package/en/configure/app/output/disable-ts-checker.mdx +1 -1
  86. package/en/configure/app/output/dist-path.mdx +1 -1
  87. package/en/configure/app/output/enable-asset-fallback.mdx +1 -1
  88. package/en/configure/app/output/enable-asset-manifest.mdx +1 -1
  89. package/en/configure/app/output/enable-css-module-tsdeclaration.mdx +1 -1
  90. package/en/configure/app/output/enable-inline-scripts.mdx +1 -1
  91. package/en/configure/app/output/enable-inline-styles.mdx +1 -1
  92. package/en/configure/app/output/enable-latest-decorators.mdx +1 -1
  93. package/en/configure/app/output/externals.mdx +1 -1
  94. package/en/configure/app/output/filename.mdx +1 -1
  95. package/en/configure/app/output/legal-comments.mdx +1 -1
  96. package/en/configure/app/output/override-browserslist.mdx +1 -1
  97. package/en/configure/app/output/polyfill.mdx +1 -1
  98. package/en/configure/app/output/ssg.mdx +2 -2
  99. package/en/configure/app/output/svg-default-export.mdx +1 -1
  100. package/en/configure/app/performance/_category_.json +4 -0
  101. package/en/configure/app/performance/build-cache.mdx +1 -1
  102. package/en/configure/app/performance/bundle-analyze.mdx +1 -1
  103. package/en/configure/app/performance/chunk-split.mdx +1 -1
  104. package/en/configure/app/performance/print-file-size.mdx +1 -1
  105. package/en/configure/app/performance/profile.mdx +1 -1
  106. package/en/configure/app/performance/remove-console.mdx +1 -1
  107. package/en/configure/app/performance/remove-moment-locale.mdx +1 -1
  108. package/en/configure/app/plugins.mdx +1 -1
  109. package/en/configure/app/runtime/_category_.json +4 -0
  110. package/en/configure/app/runtime/intro.mdx +2 -2
  111. package/en/configure/app/security/_category_.json +4 -0
  112. package/en/configure/app/security/check-syntax.mdx +1 -1
  113. package/en/configure/app/security/sri.mdx +1 -1
  114. package/en/configure/app/server/_category_.json +4 -0
  115. package/en/configure/app/server/base-url.mdx +3 -3
  116. package/en/configure/app/server/enable-framework-ext.mdx +1 -1
  117. package/en/configure/app/server/ssr-by-entries.mdx +1 -1
  118. package/en/configure/app/source/_category_.json +4 -0
  119. package/en/configure/app/source/alias.mdx +1 -1
  120. package/en/configure/app/source/compile-js-data-uri.mdx +1 -1
  121. package/en/configure/app/source/define.mdx +1 -1
  122. package/en/configure/app/source/design-system.mdx +5 -5
  123. package/en/configure/app/source/entries.mdx +3 -3
  124. package/en/configure/app/source/exclude.mdx +1 -1
  125. package/en/configure/app/source/global-vars.mdx +1 -1
  126. package/en/configure/app/source/include.mdx +1 -1
  127. package/en/configure/app/source/module-scopes.mdx +1 -1
  128. package/en/configure/app/source/pre-entry.mdx +1 -1
  129. package/en/configure/app/source/resolve-extension-prefix.mdx +1 -1
  130. package/en/configure/app/source/resolve-main-fields.mdx +1 -1
  131. package/en/configure/app/testing/_category_.json +4 -0
  132. package/en/configure/app/tools/_category_.json +4 -0
  133. package/en/configure/app/tools/autoprefixer.mdx +1 -1
  134. package/en/configure/app/tools/babel.mdx +1 -1
  135. package/en/configure/app/tools/css-extract.mdx +1 -1
  136. package/en/configure/app/tools/css-loader.mdx +1 -1
  137. package/en/configure/app/tools/dev-server.mdx +1 -1
  138. package/en/configure/app/tools/html-plugin.mdx +1 -1
  139. package/en/configure/app/tools/inspector.mdx +1 -1
  140. package/en/configure/app/tools/less.mdx +1 -1
  141. package/en/configure/app/tools/minify-css.mdx +1 -1
  142. package/en/configure/app/tools/postcss.mdx +1 -1
  143. package/en/configure/app/tools/pug.mdx +1 -1
  144. package/en/configure/app/tools/rspack.mdx +13 -0
  145. package/en/configure/app/tools/sass.mdx +1 -1
  146. package/en/configure/app/tools/style-loader.mdx +1 -1
  147. package/en/configure/app/tools/styled-components.mdx +1 -1
  148. package/en/configure/app/tools/tailwindcss.mdx +1 -1
  149. package/en/configure/app/tools/terser.mdx +1 -1
  150. package/en/configure/app/tools/ts-checker.mdx +1 -1
  151. package/en/configure/app/tools/ts-loader.mdx +1 -1
  152. package/en/configure/app/tools/webpack-chain.mdx +1 -1
  153. package/en/configure/app/tools/webpack.mdx +1 -1
  154. package/en/configure/app/usage.mdx +1 -1
  155. package/en/guides/advanced-features/_category_.json +2 -2
  156. package/en/guides/advanced-features/bff/bff-proxy.mdx +1 -1
  157. package/en/guides/advanced-features/bff/frameworks.mdx +1 -1
  158. package/en/guides/advanced-features/bff/function.mdx +3 -3
  159. package/en/guides/advanced-features/code-split.mdx +2 -2
  160. package/en/guides/advanced-features/compatibility.mdx +2 -3
  161. package/en/guides/advanced-features/eslint.mdx +4 -4
  162. package/en/guides/advanced-features/low-level.mdx +1 -1
  163. package/en/guides/advanced-features/ssg.mdx +4 -5
  164. package/en/guides/advanced-features/ssr.mdx +3 -3
  165. package/en/guides/advanced-features/testing.mdx +4 -5
  166. package/en/guides/advanced-features/web-server.mdx +0 -1
  167. package/en/guides/basic-features/alias.mdx +1 -1
  168. package/en/guides/basic-features/data-fetch.mdx +21 -8
  169. package/en/guides/basic-features/env-vars.mdx +1 -1
  170. package/en/guides/basic-features/html.mdx +11 -11
  171. package/en/guides/basic-features/mock.mdx +21 -1
  172. package/en/guides/basic-features/proxy.mdx +2 -2
  173. package/en/guides/basic-features/routes.mdx +6 -8
  174. package/en/guides/{basic-features → concept}/builder.mdx +1 -1
  175. package/en/guides/concept/entries.mdx +11 -11
  176. package/en/guides/css/_category_.json +5 -0
  177. package/en/guides/{basic-features/css → css}/css-in-js.mdx +0 -0
  178. package/en/guides/{basic-features/css → css}/css-modules.mdx +0 -0
  179. package/en/guides/{basic-features/css → css}/less-sass.mdx +1 -1
  180. package/en/guides/{basic-features/css → css}/postcss.mdx +0 -0
  181. package/en/guides/{basic-features/css → css}/tailwindcss.mdx +0 -0
  182. package/en/guides/get-started/introduction.mdx +34 -0
  183. package/en/guides/get-started/quick-start.mdx +2 -2
  184. package/en/guides/get-started/upgrade.mdx +2 -1
  185. package/en/guides/topic-detail/_category_.json +2 -2
  186. package/en/guides/topic-detail/framework-plugin/hook.mdx +1 -1
  187. package/en/guides/topic-detail/generator/plugin/api/hook/onForged.mdx +1 -1
  188. package/en/guides/topic-detail/generator/plugin/develop.mdx +1 -1
  189. package/en/guides/topic-detail/micro-frontend/c02-development.mdx +128 -61
  190. package/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +72 -41
  191. package/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +1 -1
  192. package/en/guides/topic-detail/model/auto-actions.mdx +1 -1
  193. package/en/guides/topic-detail/model/define-model.mdx +1 -1
  194. package/en/guides/topic-detail/model/manage-effects.mdx +1 -1
  195. package/en/guides/topic-detail/model/model-communicate.mdx +1 -1
  196. package/en/guides/topic-detail/model/quick-start.mdx +2 -2
  197. package/en/guides/topic-detail/model/test-model.mdx +1 -1
  198. package/en/guides/topic-detail/model/use-model.mdx +3 -3
  199. package/en/guides/troubleshooting/_category_.json +2 -2
  200. package/en/guides/troubleshooting/cli.mdx +1 -1
  201. package/en/index.md +1 -1
  202. package/en/tutorials/first-app/_category_.json +1 -1
  203. package/en/tutorials/first-app/c01-start.mdx +0 -1
  204. package/en/tutorials/first-app/c03-css.mdx +1 -2
  205. package/en/tutorials/first-app/c06-model.mdx +1 -1
  206. package/en/tutorials/first-app/c07-container.mdx +1 -1
  207. package/en/tutorials/first-app/c08-entries.mdx +1 -2
  208. package/en/tutorials/foundations/introduction.mdx +17 -34
  209. package/package.json +3 -3
  210. package/scripts/config.ts +3 -1
  211. package/scripts/summary.en.json +1 -1
  212. package/scripts/summary.zh.json +1 -1
  213. package/zh/apis/app/commands/_category_.json +1 -4
  214. package/zh/apis/app/hooks/_category_.json +1 -4
  215. package/zh/apis/app/hooks/src/pages.mdx +1 -1
  216. package/zh/apis/app/hooks/src/routes.mdx +1 -1
  217. package/zh/apis/app/runtime/_category_.json +1 -5
  218. package/zh/apis/app/runtime/core/create-app.mdx +1 -1
  219. package/zh/apis/app/runtime/core/use-module-apps.mdx +81 -40
  220. package/zh/apis/app/runtime/model/Provider.mdx +2 -2
  221. package/zh/apis/app/runtime/model/create-app.mdx +7 -7
  222. package/zh/apis/app/runtime/model/create-store.mdx +2 -2
  223. package/zh/apis/app/runtime/model/use-local-model.mdx +1 -1
  224. package/zh/apis/app/runtime/model/use-static-model.mdx +1 -1
  225. package/zh/apis/app/runtime/model/use-store.mdx +1 -1
  226. package/zh/apis/app/runtime/testing/renderApp.mdx +1 -1
  227. package/zh/components/micro-runtime-config.mdx +6 -6
  228. package/zh/components/release-note.mdx +1 -1
  229. package/zh/configure/app/builder-plugins.mdx +3 -3
  230. package/zh/configure/app/plugins.mdx +1 -1
  231. package/zh/configure/app/server/ssr-by-entries.mdx +1 -1
  232. package/zh/configure/app/tools/rspack.mdx +13 -0
  233. package/zh/configure/app/usage.mdx +1 -1
  234. package/zh/guides/advanced-features/_category_.json +2 -6
  235. package/zh/guides/advanced-features/compatibility.mdx +0 -1
  236. package/zh/guides/advanced-features/ssg.mdx +0 -1
  237. package/zh/guides/advanced-features/testing.mdx +0 -1
  238. package/zh/guides/advanced-features/web-server.mdx +0 -1
  239. package/zh/guides/basic-features/_category_.json +1 -5
  240. package/zh/guides/basic-features/alias.mdx +1 -1
  241. package/zh/guides/basic-features/data-fetch.mdx +35 -26
  242. package/zh/guides/basic-features/html.mdx +10 -9
  243. package/zh/guides/basic-features/mock.mdx +20 -0
  244. package/zh/guides/basic-features/routes.mdx +15 -10
  245. package/zh/guides/{basic-features → concept}/builder.mdx +2 -2
  246. package/zh/guides/concept/entries.mdx +11 -11
  247. package/zh/guides/css/_category_.json +5 -0
  248. package/zh/guides/{basic-features/css → css}/css-in-js.mdx +0 -0
  249. package/zh/guides/{basic-features/css → css}/css-modules.mdx +0 -0
  250. package/zh/guides/{basic-features/css → css}/less-sass.mdx +1 -1
  251. package/zh/guides/{basic-features/css → css}/postcss.mdx +5 -4
  252. package/zh/guides/{basic-features/css → css}/tailwindcss.mdx +0 -1
  253. package/zh/guides/get-started/introduction.mdx +31 -0
  254. package/zh/guides/get-started/quick-start.mdx +2 -3
  255. package/zh/guides/get-started/upgrade.mdx +2 -1
  256. package/zh/guides/topic-detail/_category_.json +2 -2
  257. package/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +1 -1
  258. package/zh/guides/topic-detail/micro-frontend/c02-development.mdx +25 -0
  259. package/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +15 -15
  260. package/zh/guides/topic-detail/model/model-communicate.mdx +1 -1
  261. package/zh/guides/troubleshooting/_category_.json +2 -2
  262. package/zh/index.md +1 -1
  263. package/zh/tutorials/first-app/_category_.json +1 -1
  264. package/zh/tutorials/first-app/c01-start.mdx +1 -2
  265. package/zh/tutorials/first-app/c03-css.mdx +1 -2
  266. package/zh/tutorials/first-app/c06-model.mdx +2 -2
  267. package/zh/tutorials/first-app/c07-container.mdx +1 -1
  268. package/zh/tutorials/first-app/c08-entries.mdx +2 -3
  269. package/zh/tutorials/foundations/introduction.mdx +14 -29
  270. package/en/apis/app/commands/index.mdx +0 -7
  271. package/en/apis/app/hooks/index.mdx +0 -7
  272. package/en/apis/app/runtime/index.mdx +0 -7
  273. package/en/guides/advanced-features/index.mdx +0 -7
  274. package/en/guides/basic-features/css/_category_.json +0 -4
  275. package/zh/apis/app/commands/index.mdx +0 -7
  276. package/zh/apis/app/hooks/index.mdx +0 -7
  277. package/zh/apis/app/runtime/index.mdx +0 -7
  278. package/zh/guides/advanced-features/index.mdx +0 -7
  279. package/zh/guides/basic-features/css/_category_.json +0 -4
  280. package/zh/guides/basic-features/index.mdx +0 -7
@@ -16,7 +16,7 @@ Reduck 在 MVC 模式中,扮演 M(Model) 的角色,React UI Component 对应
16
16
 
17
17
  Modern.js 的状态管理解决方案,是通过内置 Reduck 实现的。在 Modern.js 中使用 Reduck,不仅免去了手动集成的环节,而且所有 Reduck API 都可以从 Modern.js 的 Runtime 包中直接导入使用,具有更好的一致性体验。
18
18
 
19
- :::info
19
+ :::info
20
20
  1. Modern.js 中使用 Reduck API,需要先设置 [runtime.state](/configure/app/runtime/state) 以启用状态管理插件。
21
21
  2. Reduck 也可以脱离 Modern.js 作为状态管理库[单独使用](/guides/topic-detail/model/use-out-of-modernjs)。
22
22
 
@@ -101,7 +101,7 @@ function Counter() {
101
101
 
102
102
  `useModel` 获取 `countModel` 的 `state` 和 `actions`,组件展示当前计算器的值,点击 `add` 按钮,计数器自增 1。
103
103
 
104
- :::info
104
+ :::info
105
105
  由于使用的案例比较简单,这里并没有严格按照 MVC 模式进行分层,组件 `Counter` 同时起到了 V 和 C 两层的作用。
106
106
 
107
107
  :::
@@ -35,7 +35,7 @@ describe('test model', () => {
35
35
  });
36
36
  ```
37
37
 
38
- :::info
38
+ :::info
39
39
  这里使用的 [`createStore`](/apis/app/runtime/model/create-store) 是从 `@modern-js/runtime/testing` 导入的,内部会使用 [`runtime.state`](/configure/app/runtime/state) 的配置去创建 `store`。
40
40
 
41
41
  :::
@@ -111,7 +111,7 @@ const [state, actions] = useModel(
111
111
 
112
112
  通过 `useStaticModel` 获取 Model ,将 Model 中的状态作为静态状态使用。可以保证组件每次访问到的 Model 的 State 都是最新值,但是 Model 的 State 的变化,并不会引起当前组件的重新渲染。
113
113
 
114
- :::info
114
+ :::info
115
115
  `useStaticModel` 的使用方式和 `useModel` 完全一致。
116
116
 
117
117
  :::
@@ -169,7 +169,7 @@ function ThreeComponent() {
169
169
 
170
170
  通过 `useLocalModel` 获取 Model ,将 Model 中的状态作为局部状态使用。此时 Model State 的变化,只会引起当前组件的重新渲染,但是不会引起其他使用了该 Model 的组件重新渲染。效果和通过 React 的 `useState` 管理状态类似,但是可以将状态的管理逻辑从组件中解耦,统一收敛到 Model 层。
171
171
 
172
- :::info
172
+ :::info
173
173
  `useLocalModel` 的使用方式和 `useModel` 完全一致。
174
174
 
175
175
  :::
@@ -241,7 +241,7 @@ setInterval(() => {
241
241
 
242
242
  完整的示例代码可以在[这里](https://github.com/modern-js-dev/modern-js-examples/tree/main/series/tutorials/runtime-api/model/counter-model-outof-react)查看。
243
243
 
244
- :::info
244
+ :::info
245
245
  如果是通过 [`createStore`](/apis/app/runtime/model/create-store) 手动创建的 Store 对象,无需通过 `useStore` 在组件内获取,即可直接使用。
246
246
 
247
247
  :::
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "label": "FAQ",
3
- "position": 6,
4
- "collapsed": true
3
+ "position": 10,
4
+ "collapsed": false
5
5
  }
@@ -50,7 +50,7 @@ In the following `package.json` configuration:
50
50
 
51
51
  If you need to execute `modern command --option`,
52
52
 
53
- When using pnpm, you need to execute the `pnpm run command -- --option`。
53
+ When using pnpm, you need to execute the `pnpm run command -- --option`.
54
54
 
55
55
  This is because pnpm does not handle command parameters the same as Yarn, but is similar to npm: when not adding a `--` character string, the parameters of pnpm are passed; when using a `--` character string, the parameters of the execution script are passed.
56
56
 
package/en/index.md CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  pageType: home
3
3
  ---
4
- # index
4
+ # Modern.js - A Progressive React Framework for modern web development
@@ -1,5 +1,5 @@
1
1
  {
2
- "label": "First App",
2
+ "label": "Tutorial",
3
3
  "position": 2,
4
4
  "collapsed": false
5
5
  }
@@ -84,7 +84,6 @@ Next, we modify the `modern.config.ts` in the project to enable the SSR capabili
84
84
  ```ts
85
85
  import appTools, { defineConfig } from '@modern-js/app-tools';
86
86
 
87
- // https://modernjs.dev/docs/apis/app/config
88
87
  export default defineConfig({
89
88
  runtime: {
90
89
  router: true,
@@ -124,7 +124,6 @@ Register the Tailwind plugin in `modern.config.ts`:
124
124
  import appTools, { defineConfig } from '@modern-js/app-tools';
125
125
  import tailwindcssPlugin from '@modern-js/plugin-tailwindcss';
126
126
 
127
- // https://modernjs.dev/docs/apis/app/config
128
127
  export default defineConfig({
129
128
  runtime: {
130
129
  router: true,
@@ -294,7 +293,7 @@ A Utility Class named `custom-text-gray` is implemented in `src/routes/styles/ut
294
293
  ```
295
294
 
296
295
  :::info note
297
- Modern.js integrates with [PostCSS](/guides/basic-features/css/postcss) and supports modern CSS syntax features such as [custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties).
296
+ Modern.js integrates with [PostCSS](/guides/css/postcss) and supports modern CSS syntax features such as [custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties).
298
297
 
299
298
  :::
300
299
 
@@ -11,7 +11,7 @@ In this chapter, we will further implement the functions of the project, such as
11
11
  Therefore, we will start to write some business logic that has nothing to do with the UI at all. If we continue to write in the component code, more and more noodle code will be generated. To this end, we introduced a code module called **Model** to decoupling these business logic and UI.
12
12
 
13
13
  :::info note
14
- To use the Model API, you need to opt in [runtime.state](/docs/configure/app/runtime/state):
14
+ To use the Model API, you need to opt in [runtime.state](/configure/app/runtime/state):
15
15
 
16
16
  ```ts title="modern.config.ts"
17
17
  import { defineConfig } from '@modern-js/app-tools';
@@ -277,6 +277,6 @@ The refactoring is complete, and the current project structure is:
277
277
 
278
278
  The **view components** in `components/` dir are in the form of directories, such as `Avatar/index.tsx`. And the **container components** in `containers/` dir are in the form of single files, such as `contacts.tsx`. **This is a best practice we recommend**.
279
279
 
280
- As mentioned in the chapter [Add UI component](./c02-component.md), the view component is in the form of a directory, because the view component is responsible for the implementation of UI display and interaction details, and can evolve in complexity. In the form of a directory, it is convenient to add sub-files, including dedicated resources (pictures, etc.), dedicated sub-components, CSS files, etc. You can reconstruct at will within this directory, considering only the smallest parts.
280
+ As mentioned in the chapter [Add UI component](./c02-component.mdx), the view component is in the form of a directory, because the view component is responsible for the implementation of UI display and interaction details, and can evolve in complexity. In the form of a directory, it is convenient to add sub-files, including dedicated resources (pictures, etc.), dedicated sub-components, CSS files, etc. You can reconstruct at will within this directory, considering only the smallest parts.
281
281
 
282
282
  The container component is only responsible for linkage and is a glue layer. The sophisticated business logic and implementation details are handed over to the View layer and the Model layer for implementation. The container component itself should be kept simple and clear, and should not contain complex implementation details, so there should be no internal structure. The single-file form is not only more concise, but also acts as a constraint, reminding developers not to write complicated container components.
@@ -93,11 +93,10 @@ In the Modern.js configuration file, we can write our own code to control the co
93
93
 
94
94
  Now, modify the `modern.config.ts` to add something:
95
95
 
96
- ```ts
96
+ ```ts title="modern.config.ts"
97
97
  import appTools, { defineConfig } from '@modern-js/app-tools';
98
98
  import tailwindcssPlugin from '@modern-js/plugin-tailwindcss';
99
99
 
100
- // https://modernjs.dev/docs/apis/app/config
101
100
  export default defineConfig({
102
101
  runtime: {
103
102
  router: true,
@@ -1,47 +1,30 @@
1
1
  ---
2
- title: Introduce
2
+ title: Introduction
3
3
  sidebar_position: 1
4
4
  ---
5
- # Introduce
5
+
6
+ # Introduction
6
7
 
7
8
  Welcome to Modern.js tutorials!
8
9
 
9
10
  After reading this section, you will have an initial understanding of Modern.js and use Modern.js to create your first application.
10
11
 
11
- :::note Follow
12
- Join our Lark group to ask questions and learn about the latest news.
13
-
14
- :::
15
-
16
- ## What is Modern.js
17
-
18
- **Modern.js** is a progressive modern web development framework based on React.
19
-
20
- The framework has a variety of built-in out-of-the-box tools, excellent build performance, zero-configuration rendering paradigm switching, and integrated API calls. Starting from three solutions (Application solutions, Module solutions, Monorepo solutions), it supports front-end research and development of a complete period.
21
-
22
- Modern.js is ByteDance's underlying front-end framework, which has directly or indirectly served thousands of applications, including middle and back-end, PC Web, H5 and other application scenarios. The framework covers a full life cycle, has a complete plugin system, and provides a high degree of customization capabilities. Support custom solutions exclusive to business lines through generator plugin, customize various functional extensions and business requirements, and help developers build applications faster.
23
-
24
- ## Why Modern.js
25
-
26
- Modern.js can provide developers with the ultimate **Development Experience**,make the app better **User Experience**。
27
-
28
- In the process of developing React applications, developers often need to design implementations for certain functions, or use other libraries and frameworks to solve these problems。
29
-
30
- Modern.js support all the configuration and tools required by React applications, and have built-in **additional functions and optimizations**. Developers can use React to build the UI of the application, and then gradually adopt Modern.js functions to solve common application requirements, such as routing, data fetch, state management, etc.
31
-
32
- It mainly contains the following features:
12
+ ## What is Modern.js?
33
13
 
34
- - 🪜 **Progressive**:Create projects with the most streamlined templates, gradually turn on plugin capabilities through generators, and customize solutions.
35
- - 🏠 **Integration**:The development is unique to the production environment Web Server, CSR and SSR are isomorphic development, and the function as the API service call.
36
- - 📦 **Out Of The Box**:Default TS support, built-in build core, ESLint, debugging tools, full functionality can be tested.
37
- - 🌏 **Ecology**:Self-developed state management, micro frontend, module packaging, Monorepo solution and other peripheral requirements.
38
- - 🕸 **Routing Modes**:Contains controlled routing, routing based on file conventions (nested routing), configurable routing, etc。
39
- - 🚀 **Independently Build Core**:Support a variety of packaging tools, deep optimization bundle.
14
+ If you don't know Modern.js yet, please can read [Modern.js Introduction](/guides/get-started/introduction) first.
40
15
 
41
- ## Next
16
+ ## Tutorial
42
17
 
43
- {/* If you are a front-end beginner, you may find these concepts a bit complicated. We provide some [JavaScript and React](/tutorials/foundations/basic) learning materials, you can do some understanding of them first。
18
+ We have prepared a tutorial on creating a "contact list app" that you can follow step by step to create an app and learn about the following practices in Modern.js:
44
19
 
45
- If you are an experienced developer and want to know how to use Modern.js, you can try [Create your first app](/tutorials/first-app/c01-start), or read [Guide](/guides/get-started/quick-start). */}
20
+ - Creating a project
21
+ - Using the antd component library
22
+ - Integrating Tailwind CSS
23
+ - Client-side routing
24
+ - Data fetching
25
+ - State Management
26
+ - Container components
27
+ - New portal
28
+ - ...
46
29
 
47
- If you want to know how to use Modern.js, you can try [Create your first app](/tutorials/first-app/c01-start), or read [Guide](/guides/get-started/quick-start).
30
+ Translated with www.DeepL.com/Translator (free version)
package/package.json CHANGED
@@ -11,13 +11,13 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.4.0",
14
+ "version": "2.5.0",
15
15
  "publishConfig": {
16
16
  "registry": "https://registry.npmjs.org/",
17
17
  "access": "public"
18
18
  },
19
19
  "peerDependencies": {
20
- "@modern-js/builder-doc": "^2.4.0"
20
+ "@modern-js/builder-doc": "^2.5.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "ts-node": "^10",
@@ -25,7 +25,7 @@
25
25
  "fs-extra": "^10",
26
26
  "@types/node": "^16",
27
27
  "@types/fs-extra": "^9",
28
- "@modern-js/builder-doc": "2.4.0"
28
+ "@modern-js/builder-doc": "2.5.0"
29
29
  },
30
30
  "scripts": {
31
31
  "build": "npx ts-node ./scripts/sync.ts"
package/scripts/config.ts CHANGED
@@ -27,7 +27,9 @@ sidebar_label: ${name}
27
27
  :::tip
28
28
  ${
29
29
  tip[lng]
30
- } [${dirname}.${name}](https://modernjs.dev/builder${langPrefix}/api/config-${dirname}.html#${dirname}${name.toLowerCase()})
30
+ } [${dirname}.${name}](https://modernjs.dev/builder${langPrefix}/api/config-${dirname}.html#${dirname}${name.toLowerCase()})${
31
+ lng === 'en' ? '.' : '。'
32
+ }
31
33
  :::
32
34
 
33
35
  import Main from '@modern-js/builder-doc/docs/${lng}/config/${dirname}/${name}.md'
@@ -1 +1 @@
1
- [{"name":"assetPrefix","dirname":"dev"},{"name":"hmr","dirname":"dev"},{"name":"https","dirname":"dev"},{"name":"port","dirname":"dev"},{"name":"progressBar","dirname":"dev"},{"name":"startUrl","dirname":"dev"},{"name":"lazyCompilation","dirname":"experiments"},{"name":"appIcon","dirname":"html"},{"name":"crossorigin","dirname":"html"},{"name":"disableHtmlFolder","dirname":"html"},{"name":"favicon","dirname":"html"},{"name":"faviconByEntries","dirname":"html"},{"name":"inject","dirname":"html"},{"name":"injectByEntries","dirname":"html"},{"name":"meta","dirname":"html"},{"name":"metaByEntries","dirname":"html"},{"name":"mountId","dirname":"html"},{"name":"tags","dirname":"html"},{"name":"tagsByEntries","dirname":"html"},{"name":"template","dirname":"html"},{"name":"templateByEntries","dirname":"html"},{"name":"templateParameters","dirname":"html"},{"name":"templateParametersByEntries","dirname":"html"},{"name":"title","dirname":"html"},{"name":"titleByEntries","dirname":"html"},{"name":"assetPrefix","dirname":"output"},{"name":"assetsRetry","dirname":"output"},{"name":"charset","dirname":"output"},{"name":"cleanDistPath","dirname":"output"},{"name":"convertToRem","dirname":"output"},{"name":"copy","dirname":"output"},{"name":"cssModuleLocalIdentName","dirname":"output"},{"name":"dataUriLimit","dirname":"output"},{"name":"disableCssExtract","dirname":"output"},{"name":"disableCssModuleExtension","dirname":"output"},{"name":"disableFilenameHash","dirname":"output"},{"name":"disableInlineRuntimeChunk","dirname":"output"},{"name":"disableMinimize","dirname":"output"},{"name":"disableSourceMap","dirname":"output"},{"name":"disableTsChecker","dirname":"output"},{"name":"distPath","dirname":"output"},{"name":"enableAssetFallback","dirname":"output"},{"name":"enableAssetManifest","dirname":"output"},{"name":"enableCssModuleTSDeclaration","dirname":"output"},{"name":"enableInlineScripts","dirname":"output"},{"name":"enableInlineStyles","dirname":"output"},{"name":"enableLatestDecorators","dirname":"output"},{"name":"externals","dirname":"output"},{"name":"filename","dirname":"output"},{"name":"legalComments","dirname":"output"},{"name":"overrideBrowserslist","dirname":"output"},{"name":"polyfill","dirname":"output"},{"name":"svgDefaultExport","dirname":"output"},{"name":"buildCache","dirname":"performance"},{"name":"bundleAnalyze","dirname":"performance"},{"name":"chunkSplit","dirname":"performance"},{"name":"printFileSize","dirname":"performance"},{"name":"profile","dirname":"performance"},{"name":"removeConsole","dirname":"performance"},{"name":"removeMomentLocale","dirname":"performance"},{"name":"checkSyntax","dirname":"security"},{"name":"sri","dirname":"security"},{"name":"alias","dirname":"source"},{"name":"compileJsDataURI","dirname":"source"},{"name":"define","dirname":"source"},{"name":"exclude","dirname":"source"},{"name":"globalVars","dirname":"source"},{"name":"include","dirname":"source"},{"name":"moduleScopes","dirname":"source"},{"name":"preEntry","dirname":"source"},{"name":"resolveExtensionPrefix","dirname":"source"},{"name":"resolveMainFields","dirname":"source"},{"name":"autoprefixer","dirname":"tools"},{"name":"babel","dirname":"tools"},{"name":"cssExtract","dirname":"tools"},{"name":"cssLoader","dirname":"tools"},{"name":"devServer","dirname":"tools"},{"name":"htmlPlugin","dirname":"tools"},{"name":"inspector","dirname":"tools"},{"name":"less","dirname":"tools"},{"name":"minifyCss","dirname":"tools"},{"name":"postcss","dirname":"tools"},{"name":"pug","dirname":"tools"},{"name":"sass","dirname":"tools"},{"name":"styleLoader","dirname":"tools"},{"name":"styledComponents","dirname":"tools"},{"name":"terser","dirname":"tools"},{"name":"tsChecker","dirname":"tools"},{"name":"tsLoader","dirname":"tools"},{"name":"webpack","dirname":"tools"},{"name":"webpackChain","dirname":"tools"}]
1
+ [{"name":"assetPrefix","dirname":"dev"},{"name":"hmr","dirname":"dev"},{"name":"https","dirname":"dev"},{"name":"port","dirname":"dev"},{"name":"progressBar","dirname":"dev"},{"name":"startUrl","dirname":"dev"},{"name":"lazyCompilation","dirname":"experiments"},{"name":"appIcon","dirname":"html"},{"name":"crossorigin","dirname":"html"},{"name":"disableHtmlFolder","dirname":"html"},{"name":"favicon","dirname":"html"},{"name":"faviconByEntries","dirname":"html"},{"name":"inject","dirname":"html"},{"name":"injectByEntries","dirname":"html"},{"name":"meta","dirname":"html"},{"name":"metaByEntries","dirname":"html"},{"name":"mountId","dirname":"html"},{"name":"tags","dirname":"html"},{"name":"tagsByEntries","dirname":"html"},{"name":"template","dirname":"html"},{"name":"templateByEntries","dirname":"html"},{"name":"templateParameters","dirname":"html"},{"name":"templateParametersByEntries","dirname":"html"},{"name":"title","dirname":"html"},{"name":"titleByEntries","dirname":"html"},{"name":"assetPrefix","dirname":"output"},{"name":"assetsRetry","dirname":"output"},{"name":"charset","dirname":"output"},{"name":"cleanDistPath","dirname":"output"},{"name":"convertToRem","dirname":"output"},{"name":"copy","dirname":"output"},{"name":"cssModuleLocalIdentName","dirname":"output"},{"name":"dataUriLimit","dirname":"output"},{"name":"disableCssExtract","dirname":"output"},{"name":"disableCssModuleExtension","dirname":"output"},{"name":"disableFilenameHash","dirname":"output"},{"name":"disableInlineRuntimeChunk","dirname":"output"},{"name":"disableMinimize","dirname":"output"},{"name":"disableSourceMap","dirname":"output"},{"name":"disableTsChecker","dirname":"output"},{"name":"distPath","dirname":"output"},{"name":"enableAssetFallback","dirname":"output"},{"name":"enableAssetManifest","dirname":"output"},{"name":"enableCssModuleTSDeclaration","dirname":"output"},{"name":"enableInlineScripts","dirname":"output"},{"name":"enableInlineStyles","dirname":"output"},{"name":"enableLatestDecorators","dirname":"output"},{"name":"externals","dirname":"output"},{"name":"filename","dirname":"output"},{"name":"legalComments","dirname":"output"},{"name":"overrideBrowserslist","dirname":"output"},{"name":"polyfill","dirname":"output"},{"name":"svgDefaultExport","dirname":"output"},{"name":"buildCache","dirname":"performance"},{"name":"bundleAnalyze","dirname":"performance"},{"name":"chunkSplit","dirname":"performance"},{"name":"printFileSize","dirname":"performance"},{"name":"profile","dirname":"performance"},{"name":"removeConsole","dirname":"performance"},{"name":"removeMomentLocale","dirname":"performance"},{"name":"checkSyntax","dirname":"security"},{"name":"sri","dirname":"security"},{"name":"alias","dirname":"source"},{"name":"compileJsDataURI","dirname":"source"},{"name":"define","dirname":"source"},{"name":"exclude","dirname":"source"},{"name":"globalVars","dirname":"source"},{"name":"include","dirname":"source"},{"name":"moduleScopes","dirname":"source"},{"name":"preEntry","dirname":"source"},{"name":"resolveExtensionPrefix","dirname":"source"},{"name":"resolveMainFields","dirname":"source"},{"name":"autoprefixer","dirname":"tools"},{"name":"babel","dirname":"tools"},{"name":"cssExtract","dirname":"tools"},{"name":"cssLoader","dirname":"tools"},{"name":"devServer","dirname":"tools"},{"name":"htmlPlugin","dirname":"tools"},{"name":"inspector","dirname":"tools"},{"name":"less","dirname":"tools"},{"name":"minifyCss","dirname":"tools"},{"name":"postcss","dirname":"tools"},{"name":"pug","dirname":"tools"},{"name":"rspack","dirname":"tools"},{"name":"sass","dirname":"tools"},{"name":"styleLoader","dirname":"tools"},{"name":"styledComponents","dirname":"tools"},{"name":"terser","dirname":"tools"},{"name":"tsChecker","dirname":"tools"},{"name":"tsLoader","dirname":"tools"},{"name":"webpack","dirname":"tools"},{"name":"webpackChain","dirname":"tools"}]
@@ -1 +1 @@
1
- [{"name":"assetPrefix","dirname":"dev"},{"name":"hmr","dirname":"dev"},{"name":"https","dirname":"dev"},{"name":"port","dirname":"dev"},{"name":"progressBar","dirname":"dev"},{"name":"startUrl","dirname":"dev"},{"name":"lazyCompilation","dirname":"experiments"},{"name":"appIcon","dirname":"html"},{"name":"crossorigin","dirname":"html"},{"name":"disableHtmlFolder","dirname":"html"},{"name":"favicon","dirname":"html"},{"name":"faviconByEntries","dirname":"html"},{"name":"inject","dirname":"html"},{"name":"injectByEntries","dirname":"html"},{"name":"meta","dirname":"html"},{"name":"metaByEntries","dirname":"html"},{"name":"mountId","dirname":"html"},{"name":"tags","dirname":"html"},{"name":"tagsByEntries","dirname":"html"},{"name":"template","dirname":"html"},{"name":"templateByEntries","dirname":"html"},{"name":"templateParameters","dirname":"html"},{"name":"templateParametersByEntries","dirname":"html"},{"name":"title","dirname":"html"},{"name":"titleByEntries","dirname":"html"},{"name":"assetPrefix","dirname":"output"},{"name":"assetsRetry","dirname":"output"},{"name":"charset","dirname":"output"},{"name":"cleanDistPath","dirname":"output"},{"name":"convertToRem","dirname":"output"},{"name":"copy","dirname":"output"},{"name":"cssModuleLocalIdentName","dirname":"output"},{"name":"dataUriLimit","dirname":"output"},{"name":"disableCssExtract","dirname":"output"},{"name":"disableCssModuleExtension","dirname":"output"},{"name":"disableFilenameHash","dirname":"output"},{"name":"disableInlineRuntimeChunk","dirname":"output"},{"name":"disableMinimize","dirname":"output"},{"name":"disableSourceMap","dirname":"output"},{"name":"disableTsChecker","dirname":"output"},{"name":"distPath","dirname":"output"},{"name":"enableAssetFallback","dirname":"output"},{"name":"enableAssetManifest","dirname":"output"},{"name":"enableCssModuleTSDeclaration","dirname":"output"},{"name":"enableInlineScripts","dirname":"output"},{"name":"enableInlineStyles","dirname":"output"},{"name":"enableLatestDecorators","dirname":"output"},{"name":"externals","dirname":"output"},{"name":"filename","dirname":"output"},{"name":"legalComments","dirname":"output"},{"name":"overrideBrowserslist","dirname":"output"},{"name":"polyfill","dirname":"output"},{"name":"svgDefaultExport","dirname":"output"},{"name":"buildCache","dirname":"performance"},{"name":"bundleAnalyze","dirname":"performance"},{"name":"chunkSplit","dirname":"performance"},{"name":"printFileSize","dirname":"performance"},{"name":"profile","dirname":"performance"},{"name":"removeConsole","dirname":"performance"},{"name":"removeMomentLocale","dirname":"performance"},{"name":"checkSyntax","dirname":"security"},{"name":"sri","dirname":"security"},{"name":"alias","dirname":"source"},{"name":"compileJsDataURI","dirname":"source"},{"name":"define","dirname":"source"},{"name":"exclude","dirname":"source"},{"name":"globalVars","dirname":"source"},{"name":"include","dirname":"source"},{"name":"moduleScopes","dirname":"source"},{"name":"preEntry","dirname":"source"},{"name":"resolveExtensionPrefix","dirname":"source"},{"name":"resolveMainFields","dirname":"source"},{"name":"autoprefixer","dirname":"tools"},{"name":"babel","dirname":"tools"},{"name":"cssExtract","dirname":"tools"},{"name":"cssLoader","dirname":"tools"},{"name":"devServer","dirname":"tools"},{"name":"htmlPlugin","dirname":"tools"},{"name":"inspector","dirname":"tools"},{"name":"less","dirname":"tools"},{"name":"minifyCss","dirname":"tools"},{"name":"postcss","dirname":"tools"},{"name":"pug","dirname":"tools"},{"name":"sass","dirname":"tools"},{"name":"styleLoader","dirname":"tools"},{"name":"styledComponents","dirname":"tools"},{"name":"terser","dirname":"tools"},{"name":"tsChecker","dirname":"tools"},{"name":"tsLoader","dirname":"tools"},{"name":"webpack","dirname":"tools"},{"name":"webpackChain","dirname":"tools"}]
1
+ [{"name":"assetPrefix","dirname":"dev"},{"name":"hmr","dirname":"dev"},{"name":"https","dirname":"dev"},{"name":"port","dirname":"dev"},{"name":"progressBar","dirname":"dev"},{"name":"startUrl","dirname":"dev"},{"name":"lazyCompilation","dirname":"experiments"},{"name":"appIcon","dirname":"html"},{"name":"crossorigin","dirname":"html"},{"name":"disableHtmlFolder","dirname":"html"},{"name":"favicon","dirname":"html"},{"name":"faviconByEntries","dirname":"html"},{"name":"inject","dirname":"html"},{"name":"injectByEntries","dirname":"html"},{"name":"meta","dirname":"html"},{"name":"metaByEntries","dirname":"html"},{"name":"mountId","dirname":"html"},{"name":"tags","dirname":"html"},{"name":"tagsByEntries","dirname":"html"},{"name":"template","dirname":"html"},{"name":"templateByEntries","dirname":"html"},{"name":"templateParameters","dirname":"html"},{"name":"templateParametersByEntries","dirname":"html"},{"name":"title","dirname":"html"},{"name":"titleByEntries","dirname":"html"},{"name":"assetPrefix","dirname":"output"},{"name":"assetsRetry","dirname":"output"},{"name":"charset","dirname":"output"},{"name":"cleanDistPath","dirname":"output"},{"name":"convertToRem","dirname":"output"},{"name":"copy","dirname":"output"},{"name":"cssModuleLocalIdentName","dirname":"output"},{"name":"dataUriLimit","dirname":"output"},{"name":"disableCssExtract","dirname":"output"},{"name":"disableCssModuleExtension","dirname":"output"},{"name":"disableFilenameHash","dirname":"output"},{"name":"disableInlineRuntimeChunk","dirname":"output"},{"name":"disableMinimize","dirname":"output"},{"name":"disableSourceMap","dirname":"output"},{"name":"disableTsChecker","dirname":"output"},{"name":"distPath","dirname":"output"},{"name":"enableAssetFallback","dirname":"output"},{"name":"enableAssetManifest","dirname":"output"},{"name":"enableCssModuleTSDeclaration","dirname":"output"},{"name":"enableInlineScripts","dirname":"output"},{"name":"enableInlineStyles","dirname":"output"},{"name":"enableLatestDecorators","dirname":"output"},{"name":"externals","dirname":"output"},{"name":"filename","dirname":"output"},{"name":"legalComments","dirname":"output"},{"name":"overrideBrowserslist","dirname":"output"},{"name":"polyfill","dirname":"output"},{"name":"svgDefaultExport","dirname":"output"},{"name":"buildCache","dirname":"performance"},{"name":"bundleAnalyze","dirname":"performance"},{"name":"chunkSplit","dirname":"performance"},{"name":"printFileSize","dirname":"performance"},{"name":"profile","dirname":"performance"},{"name":"removeConsole","dirname":"performance"},{"name":"removeMomentLocale","dirname":"performance"},{"name":"checkSyntax","dirname":"security"},{"name":"sri","dirname":"security"},{"name":"alias","dirname":"source"},{"name":"compileJsDataURI","dirname":"source"},{"name":"define","dirname":"source"},{"name":"exclude","dirname":"source"},{"name":"globalVars","dirname":"source"},{"name":"include","dirname":"source"},{"name":"moduleScopes","dirname":"source"},{"name":"preEntry","dirname":"source"},{"name":"resolveExtensionPrefix","dirname":"source"},{"name":"resolveMainFields","dirname":"source"},{"name":"autoprefixer","dirname":"tools"},{"name":"babel","dirname":"tools"},{"name":"cssExtract","dirname":"tools"},{"name":"cssLoader","dirname":"tools"},{"name":"devServer","dirname":"tools"},{"name":"htmlPlugin","dirname":"tools"},{"name":"inspector","dirname":"tools"},{"name":"less","dirname":"tools"},{"name":"minifyCss","dirname":"tools"},{"name":"postcss","dirname":"tools"},{"name":"pug","dirname":"tools"},{"name":"rspack","dirname":"tools"},{"name":"sass","dirname":"tools"},{"name":"styleLoader","dirname":"tools"},{"name":"styledComponents","dirname":"tools"},{"name":"terser","dirname":"tools"},{"name":"tsChecker","dirname":"tools"},{"name":"tsLoader","dirname":"tools"},{"name":"webpack","dirname":"tools"},{"name":"webpackChain","dirname":"tools"}]
@@ -1,8 +1,5 @@
1
1
  {
2
2
  "label": "命令",
3
3
  "position": 0,
4
- "link": {
5
- "type": "doc",
6
- "id": "apis/app/commands/index"
7
- }
4
+ "collapsed": false
8
5
  }
@@ -1,8 +1,5 @@
1
1
  {
2
2
  "label": "文件约定",
3
3
  "position": 1,
4
- "link": {
5
- "type": "doc",
6
- "id": "apis/app/hooks/index"
7
- }
4
+ "collapsed": false
8
5
  }
@@ -117,7 +117,7 @@ export default const App = ({Component, ...pageProps}:{ Component: React.Compone
117
117
  - 页面变化时,保留全局布局的状态
118
118
  - 添加全局样式
119
119
  - ComponentDidCatch 错误处理
120
- - 使用 `defineConfig`(/docs/apis/app/runtime/app/define-config) 动态配置运行时配置。
120
+ - 使用 [defineConfig](/apis/app/runtime/app/define-config) 动态配置运行时配置。
121
121
 
122
122
  :::
123
123
 
@@ -52,7 +52,7 @@ sidebar_position: 2
52
52
 
53
53
  `routes/[id]/page.tsx` 文件会转为 `/:id` 路由。除了可以确切匹配的 `/blog` 路由,其他所有 `/xxx` 都会匹配到该路由。
54
54
 
55
- 在组件中,可以通过 [useParams](/apis/app/runtime/router/#useparams) 获取对应命名的参数。
55
+ 在组件中,可以通过 [useParams](/apis/app/runtime/router/router#useparams) 获取对应命名的参数。
56
56
 
57
57
  在 loader 中,params 会作为 [loader](/guides/basic-features/data-fetch#loader-函数) 的入参,通过 `params` 的属性可以获取到对应的参数。
58
58
 
@@ -1,9 +1,5 @@
1
1
  {
2
2
  "label": "运行时",
3
3
  "position": 3,
4
- "collapsed": false,
5
- "link": {
6
- "type": "doc",
7
- "id": "apis/app/runtime/index"
8
- }
4
+ "collapsed": false
9
5
  }
@@ -28,4 +28,4 @@ function createApp(options: { plugins: Plugin[] }): React.ComponentType<any>;
28
28
 
29
29
  ### 创建自定义入口
30
30
 
31
- 详见 [`bootstrap`](./bootstrap.md)。
31
+ 详见 [`bootstrap`](./bootstrap.mdx)。
@@ -25,20 +25,31 @@ import EnableMicroFrontend from "@site-docs/components/enable-micro-frontend";
25
25
 
26
26
  <EnableMicroFrontend />
27
27
 
28
+ 这里演示主应用为自控式路由的场景,全部场景参考 [体验微前端](/guides/topic-detail/micro-frontend/c02-development.html)
28
29
  ```tsx title=App.tsx
29
30
  function App() {
30
- const { Home, Contact } = useModuleApps();
31
+ const { apps, MApp, Table, Dashboard } = useModuleApps();
32
+
33
+ // 使用的不是 MApp 组件,需要使用 createBrowserRouter 来创建路由
34
+ const router = createBrowserRouter(
35
+ createRoutesFromElements(
36
+ <Route path="/" element={<AppLayout />}>
37
+ <Route key={'table'} path={'table/*'} element={<Table />} />
38
+ <Route key={'dashboard'} path={'dashboard/*'} element={<Dashboard />} />
39
+ </Route>
40
+ )
41
+ );
31
42
 
32
43
  return (
33
- <div>
34
- Master APP
35
- <Route exact path="/home">
36
- <Home />
37
- </Route>
38
- <Route exact path="/home">
39
- <Contact />
40
- </Route>
41
- </div>
44
+ // 方法一:使用 MApp 自动根据配置的 activeWhen 参数加载子应用(本项目配置在 modern.config.ts 中)
45
+ // <BrowserRouter>
46
+ // <MApp />
47
+ // </BrowserRouter>
48
+
49
+ // 方法二:手动写 Route 组件方式加载子应用,方便于需要鉴权等需要前置操作的场景
50
+ <>
51
+ <RouterProvider router={router} />
52
+ </>
42
53
  );
43
54
  }
44
55
 
@@ -47,11 +58,11 @@ defineConfig(App, {
47
58
  apps: [
48
59
  {
49
60
  // name 区分大小写,name 提供的是什么 useModuleApps 返回的就是什么
50
- name: 'Home',
61
+ name: 'Table',
51
62
  entry: 'http://127.0.0.1:8081/',
52
63
  },
53
64
  {
54
- name: 'Contact',
65
+ name: 'Dashboard',
55
66
  entry: 'http://localhost:8082',
56
67
  },
57
68
  ],
@@ -59,7 +70,7 @@ defineConfig(App, {
59
70
  });
60
71
  ```
61
72
 
62
- 通过 `useModuleApps()` 获取到 `Home` 和 `Contact` 子应用组件(名称和配置里的 `name` 字段对应),之后就可以像使用普通的 React 组件一样去加载子应用。
73
+ 通过 `useModuleApps()` 获取到 `Table` 和 `Dashboard` 子应用组件(名称和配置里的 `name` 字段对应),之后就可以像使用普通的 React 组件一样去加载子应用。
63
74
 
64
75
  ### 集中式路由
65
76
 
@@ -89,13 +100,13 @@ defineConfig(App, {
89
100
  apps: [
90
101
  {
91
102
  // name 区分大小写,name 提供的是什么 useModuleApps 返回的就是什么
92
- name: 'Dashboard',
93
- activeWhen: '/dashboard',
103
+ name: 'Table',
104
+ activeWhen: '/table',
94
105
  entry: 'http://127.0.0.1:8081/',
95
106
  },
96
107
  {
97
- name: 'TableList',
98
- activeWhen: '/table',
108
+ name: 'Dashboard',
109
+ activeWhen: '/dashboard',
99
110
  entry: 'http://localhost:8082',
100
111
  },
101
112
  ],
@@ -103,36 +114,66 @@ defineConfig(App, {
103
114
  });
104
115
  ```
105
116
 
106
- 这样启动应用后,访问 `/dashboard` 路由,会渲染 `Dashboard` 子应用,访问 `/table` 路由,会渲染 `TableList` 子应用。
117
+ 这样启动应用后,访问 `/dashboard` 路由,会渲染 `Dashboard` 子应用,访问 `/table` 路由,会渲染 `Table` 子应用。
107
118
 
108
119
  ## 加载动画
109
120
 
110
121
  可以通过以下方式,自定义组件加载过程的过渡动画。
111
122
 
112
- ```tsx title=App.tsx
113
- function App() {
114
- const { Home } = useModuleApps();
123
+ ```js title="App.tsx"
124
+ import { useModuleApps } from '@modern-js/plugin-garfish/runtime';
115
125
 
116
- return (
117
- <div>
118
- Master APP
119
- <Route exact path="/home">
120
- <Home
121
- loadable={{
122
- loading: ({ pastDelay, error }: any) => {
123
- if (error) {
124
- console.error(error);
125
- return <div>error: {error?.message}</div>;
126
- } else if (pastDelay) {
127
- return <div>loading</div>;
128
- } else {
129
- return null;
126
+ import { RouterProvider, Route, createBrowserRouter, createRoutesFromElements, BrowserRouter, Link, Outlet } from '@modern-js/runtime/router';
127
+
128
+ const AppLayout = () => (
129
+ <>
130
+ <div><Link to={'/table'}>加载约定式路由子应用</Link></div>
131
+ <div><Link to={'/dashboard'}>加载自控式路由子应用</Link></div>
132
+ <div><Link to={'/'}>卸载子应用</Link></div>
133
+ <Outlet />
134
+ </>
135
+ )
136
+
137
+ export default () => {
138
+ const { apps } = useModuleApps();
139
+
140
+ // 使用的不是 MApp 组件,需要使用 createBrowserRouter 来创建路由
141
+ const router = createBrowserRouter(
142
+ createRoutesFromElements(
143
+ <Route path="/" element={<AppLayout />}>
144
+ {apps.map(app => {
145
+ const { Component } = app;
146
+ // 模糊匹配,path 需要写成类似 abc/* 的模式
147
+ return (
148
+ <Route
149
+ key={app.name}
150
+ path={`${app.name.toLowerCase()}/*`}
151
+ element={
152
+ <Component
153
+ loadable={{
154
+ loading: ({ pastDelay, error }: any) => {
155
+ if (error) {
156
+ return <div>error: {error?.message}</div>;
157
+ } else if (pastDelay) {
158
+ return <div>loading</div>;
159
+ } else {
160
+ return null;
161
+ }
162
+ },
163
+ }}
164
+ />
130
165
  }
131
- },
132
- }}
133
- />
166
+ />
167
+ )
168
+ })}
134
169
  </Route>
135
- </div>
170
+ )
136
171
  );
137
- }
172
+
173
+ return (
174
+ <>
175
+ <RouterProvider router={router} />
176
+ </>
177
+ );
178
+ };
138
179
  ```
@@ -21,8 +21,8 @@ interface ProviderProps {
21
21
 
22
22
  ### 参数
23
23
 
24
- - store:[`createStore`](./create-store.md) 创建的 Store 对象。
25
- - config:创建 Reduck Store 的配置,同 [`createApp`](./create-app.md) 的 `config` 参数。
24
+ - store:[`createStore`](./create-store.mdx) 创建的 Store 对象。
25
+ - config:创建 Reduck Store 的配置,同 [`createApp`](./create-app.mdx) 的 `config` 参数。
26
26
 
27
27
  ## 示例
28
28
 
@@ -29,19 +29,19 @@ function createApp(config: AppConfig): object;
29
29
  ### 参数
30
30
 
31
31
  - config:`Record<string, any>`
32
- - StoreConfig:同 [`createStore`](./create-store.md) 的参数。
32
+ - StoreConfig:同 [`createStore`](./create-store.mdx) 的参数。
33
33
  - devTools:默认值为 true。是否开启 Redux DevTools,当为对象类型时,支持配置 Redux DevTools 的 [Options](https://github.com/reduxjs/redux-devtools/blob/main/extension/docs/API/Arguments.md)。
34
- - autoActions:默认值为 true。是否[自动生成 Actions](./auto-actions.md)。
34
+ - autoActions:默认值为 true。是否[自动生成 Actions](./auto-actions.mdx)。
35
35
 
36
36
  ### 返回值
37
37
 
38
38
  Reduck App,有以下属性组成:
39
39
 
40
- - Provider:为应用局部的组件树注入共享 Store 的组件。用法同 [`Provider`](./Provider.md)。
41
- - useModel:获取应用局部 Store 挂载的 Model 对象。用法同 [`useModel`](./use-model.md)。
42
- - useStaticModel:获取应用局部 Store 挂载的 Model 对象。用法同 [`useStaticModel`](./use-static-model.md)。
43
- - useLocalModel:获取应用局部 Store 挂载的 Model 对象。用法同 [`useLocalModel`](./use-local-model.md)。
44
- - useStore:获取应用局部使用的 Store 对象。用法同 [`useStore`](./use-store.md)。
40
+ - Provider:为应用局部的组件树注入共享 Store 的组件。用法同 [`Provider`](./Provider.mdx)。
41
+ - useModel:获取应用局部 Store 挂载的 Model 对象。用法同 [`useModel`](./use-model.mdx)。
42
+ - useStaticModel:获取应用局部 Store 挂载的 Model 对象。用法同 [`useStaticModel`](./use-static-model.mdx)。
43
+ - useLocalModel:获取应用局部 Store 挂载的 Model 对象。用法同 [`useLocalModel`](./use-local-model.mdx)。
44
+ - useStore:获取应用局部使用的 Store 对象。用法同 [`useStore`](./use-store.mdx)。
45
45
 
46
46
  ## 示例
47
47
 
@@ -10,7 +10,7 @@ import ReduckTip from "@site-docs/components/reduck-tip"
10
10
 
11
11
  `createStore` 用于创建一个 Store 对象。Reduck 的 Store 基于 Redux 的 [Store](https://redux.js.org/api/store) 实现,用于存储应用的状态,同时提供一组用于管理状态和 Model 的方法。
12
12
 
13
- 一般情况下,不需要使用这个 API,只有需要完全掌控 Store 的创建时,才会使用这个 API。例如,自定义一个 Store,传入 [`Provider`](./Provider.md) 组件使用。
13
+ 一般情况下,不需要使用这个 API,只有需要完全掌控 Store 的创建时,才会使用这个 API。例如,自定义一个 Store,传入 [`Provider`](./Provider.mdx) 组件使用。
14
14
 
15
15
  ## 函数签名
16
16
 
@@ -44,7 +44,7 @@ function createStore(config: StoreConfig): ReduckStore;
44
44
 
45
45
  Reduck Store 对象:
46
46
 
47
- - use:动态挂载和获取 Model 对象。用法与 [`useModel`](./use-model.md) 相同,但可以在 React 组件外使用。
47
+ - use:动态挂载和获取 Model 对象。用法与 [`useModel`](./use-model.mdx) 相同,但可以在 React 组件外使用。
48
48
  - unmount:卸载 Model 对象,Model 的 State 会从 Store 中清除。
49
49
  - ReduxStore:Redux Store 对象具有的方法,[详见](https://redux.js.org/tutorials/fundamentals/part-4-store#redux-store)。
50
50