@modern-js/main-doc 2.4.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (315) 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.mdx +297 -0
  5. package/en/apis/app/hooks/_category_.json +2 -5
  6. package/en/apis/app/hooks/api/framework/lambda.mdx +1 -1
  7. package/en/apis/app/hooks/api/functions/api.mdx +1 -1
  8. package/en/apis/app/hooks/server/index_.mdx +2 -1
  9. package/en/apis/app/hooks/src/pages.mdx +7 -7
  10. package/en/apis/app/hooks/src/routes.mdx +3 -3
  11. package/en/apis/app/runtime/_category_.json +1 -5
  12. package/en/apis/app/runtime/app/define-config.mdx +2 -2
  13. package/en/apis/app/runtime/core/bootstrap.mdx +1 -1
  14. package/en/apis/app/runtime/core/create-app.mdx +2 -2
  15. package/en/apis/app/runtime/core/use-loader.mdx +4 -4
  16. package/en/apis/app/runtime/core/use-module-apps.mdx +2 -2
  17. package/en/apis/app/runtime/model/Provider.mdx +2 -2
  18. package/en/apis/app/runtime/model/auto-actions.mdx +2 -2
  19. package/en/apis/app/runtime/model/connect.mdx +5 -5
  20. package/en/apis/app/runtime/model/create-app.mdx +9 -9
  21. package/en/apis/app/runtime/model/create-store.mdx +3 -3
  22. package/en/apis/app/runtime/model/handle-effect.mdx +2 -2
  23. package/en/apis/app/runtime/model/model_.mdx +1 -1
  24. package/en/apis/app/runtime/model/use-local-model.mdx +1 -1
  25. package/en/apis/app/runtime/model/use-model.mdx +1 -1
  26. package/en/apis/app/runtime/model/use-static-model.mdx +4 -4
  27. package/en/apis/app/runtime/model/use-store.mdx +1 -1
  28. package/en/apis/app/runtime/router/router.mdx +1 -1
  29. package/en/apis/app/runtime/ssr/pre-render.mdx +1 -1
  30. package/en/apis/app/runtime/testing/render.mdx +1 -1
  31. package/en/apis/app/runtime/testing/renderApp.mdx +1 -1
  32. package/en/apis/app/runtime/utility/css-in-js.mdx +1 -1
  33. package/en/apis/app/runtime/utility/loadable.mdx +1 -1
  34. package/en/apis/app/runtime/web-server/hook.mdx +5 -5
  35. package/en/apis/app/runtime/web-server/middleware.mdx +6 -6
  36. package/en/components/global-proxy-config.mdx +3 -3
  37. package/en/components/init-app.mdx +5 -5
  38. package/en/configure/app/bff/_category_.json +4 -0
  39. package/en/configure/app/bff/prefix.mdx +2 -3
  40. package/en/configure/app/bff/proxy.mdx +1 -1
  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/before-start-url.mdx +13 -0
  46. package/en/configure/app/dev/hmr.mdx +1 -1
  47. package/en/configure/app/dev/host.mdx +13 -0
  48. package/en/configure/app/dev/https.mdx +1 -1
  49. package/en/configure/app/dev/port.mdx +1 -1
  50. package/en/configure/app/dev/progress-bar.mdx +1 -1
  51. package/en/configure/app/dev/start-url.mdx +1 -1
  52. package/en/configure/app/experiments/_category_.json +4 -0
  53. package/en/configure/app/experiments/lazy-compilation.mdx +1 -1
  54. package/en/configure/app/html/_category_.json +4 -0
  55. package/en/configure/app/html/app-icon.mdx +1 -1
  56. package/en/configure/app/html/crossorigin.mdx +1 -1
  57. package/en/configure/app/html/disable-html-folder.mdx +1 -1
  58. package/en/configure/app/html/favicon-by-entries.mdx +1 -1
  59. package/en/configure/app/html/favicon.mdx +1 -1
  60. package/en/configure/app/html/inject-by-entries.mdx +1 -1
  61. package/en/configure/app/html/inject.mdx +1 -1
  62. package/en/configure/app/html/meta-by-entries.mdx +1 -1
  63. package/en/configure/app/html/meta.mdx +1 -1
  64. package/en/configure/app/html/mount-id.mdx +1 -1
  65. package/en/configure/app/html/tags-by-entries.mdx +1 -1
  66. package/en/configure/app/html/tags.mdx +1 -1
  67. package/en/configure/app/html/template-by-entries.mdx +1 -1
  68. package/en/configure/app/html/template-parameters-by-entries.mdx +1 -1
  69. package/en/configure/app/html/template-parameters.mdx +1 -1
  70. package/en/configure/app/html/template.mdx +1 -1
  71. package/en/configure/app/html/title-by-entries.mdx +1 -1
  72. package/en/configure/app/html/title.mdx +1 -1
  73. package/en/configure/app/output/_category_.json +4 -0
  74. package/en/configure/app/output/asset-prefix.mdx +1 -1
  75. package/en/configure/app/output/assets-retry.mdx +1 -1
  76. package/en/configure/app/output/charset.mdx +1 -1
  77. package/en/configure/app/output/clean-dist-path.mdx +1 -1
  78. package/en/configure/app/output/convert-to-rem.mdx +1 -1
  79. package/en/configure/app/output/copy.mdx +1 -1
  80. package/en/configure/app/output/css-module-local-ident-name.mdx +1 -1
  81. package/en/configure/app/output/data-uri-limit.mdx +1 -1
  82. package/en/configure/app/output/disable-css-extract.mdx +1 -1
  83. package/en/configure/app/output/disable-css-module-extension.mdx +1 -1
  84. package/en/configure/app/output/disable-filename-hash.mdx +1 -1
  85. package/en/configure/app/output/disable-inline-runtime-chunk.mdx +1 -1
  86. package/en/configure/app/output/disable-minimize.mdx +1 -1
  87. package/en/configure/app/output/disable-source-map.mdx +1 -1
  88. package/en/configure/app/output/disable-ts-checker.mdx +1 -1
  89. package/en/configure/app/output/dist-path.mdx +1 -1
  90. package/en/configure/app/output/enable-asset-fallback.mdx +1 -1
  91. package/en/configure/app/output/enable-asset-manifest.mdx +1 -1
  92. package/en/configure/app/output/enable-css-module-tsdeclaration.mdx +1 -1
  93. package/en/configure/app/output/enable-inline-scripts.mdx +1 -1
  94. package/en/configure/app/output/enable-inline-styles.mdx +1 -1
  95. package/en/configure/app/output/enable-latest-decorators.mdx +1 -1
  96. package/en/configure/app/output/externals.mdx +1 -1
  97. package/en/configure/app/output/filename.mdx +1 -1
  98. package/en/configure/app/output/legal-comments.mdx +1 -1
  99. package/en/configure/app/output/override-browserslist.mdx +1 -1
  100. package/en/configure/app/output/polyfill.mdx +1 -1
  101. package/en/configure/app/output/ssg.mdx +5 -5
  102. package/en/configure/app/output/svg-default-export.mdx +1 -1
  103. package/en/configure/app/performance/_category_.json +4 -0
  104. package/en/configure/app/performance/build-cache.mdx +1 -1
  105. package/en/configure/app/performance/bundle-analyze.mdx +1 -1
  106. package/en/configure/app/performance/chunk-split.mdx +1 -1
  107. package/en/configure/app/performance/print-file-size.mdx +1 -1
  108. package/en/configure/app/performance/profile.mdx +1 -1
  109. package/en/configure/app/performance/remove-console.mdx +1 -1
  110. package/en/configure/app/performance/remove-moment-locale.mdx +1 -1
  111. package/en/configure/app/plugins.mdx +1 -1
  112. package/en/configure/app/runtime/_category_.json +4 -0
  113. package/en/configure/app/runtime/intro.mdx +2 -2
  114. package/en/configure/app/runtime/master-app.mdx +1 -1
  115. package/en/configure/app/security/_category_.json +4 -0
  116. package/en/configure/app/security/check-syntax.mdx +1 -1
  117. package/en/configure/app/security/sri.mdx +1 -1
  118. package/en/configure/app/server/_category_.json +4 -0
  119. package/en/configure/app/server/base-url.mdx +3 -3
  120. package/en/configure/app/server/enable-framework-ext.mdx +1 -1
  121. package/en/configure/app/server/ssr-by-entries.mdx +1 -1
  122. package/en/configure/app/source/_category_.json +4 -0
  123. package/en/configure/app/source/alias.mdx +1 -1
  124. package/en/configure/app/source/compile-js-data-uri.mdx +1 -1
  125. package/en/configure/app/source/define.mdx +1 -1
  126. package/en/configure/app/source/design-system.mdx +5 -5
  127. package/en/configure/app/source/entries-dir.mdx +1 -1
  128. package/en/configure/app/source/entries.mdx +3 -3
  129. package/en/configure/app/source/exclude.mdx +1 -1
  130. package/en/configure/app/source/global-vars.mdx +1 -1
  131. package/en/configure/app/source/include.mdx +1 -1
  132. package/en/configure/app/source/module-scopes.mdx +1 -1
  133. package/en/configure/app/source/pre-entry.mdx +1 -1
  134. package/en/configure/app/source/resolve-extension-prefix.mdx +1 -1
  135. package/en/configure/app/source/resolve-main-fields.mdx +1 -1
  136. package/en/configure/app/testing/_category_.json +4 -0
  137. package/en/configure/app/testing/transformer.mdx +1 -1
  138. package/en/configure/app/tools/_category_.json +4 -0
  139. package/en/configure/app/tools/autoprefixer.mdx +1 -1
  140. package/en/configure/app/tools/babel.mdx +1 -1
  141. package/en/configure/app/tools/css-extract.mdx +1 -1
  142. package/en/configure/app/tools/css-loader.mdx +1 -1
  143. package/en/configure/app/tools/dev-server.mdx +1 -1
  144. package/en/configure/app/tools/html-plugin.mdx +1 -1
  145. package/en/configure/app/tools/inspector.mdx +1 -1
  146. package/en/configure/app/tools/jest.mdx +1 -1
  147. package/en/configure/app/tools/less.mdx +1 -1
  148. package/en/configure/app/tools/minify-css.mdx +1 -1
  149. package/en/configure/app/tools/postcss.mdx +1 -1
  150. package/en/configure/app/tools/pug.mdx +1 -1
  151. package/en/configure/app/tools/rspack.mdx +13 -0
  152. package/en/configure/app/tools/sass.mdx +1 -1
  153. package/en/configure/app/tools/style-loader.mdx +1 -1
  154. package/en/configure/app/tools/styled-components.mdx +1 -1
  155. package/en/configure/app/tools/tailwindcss.mdx +1 -1
  156. package/en/configure/app/tools/terser.mdx +1 -1
  157. package/en/configure/app/tools/ts-checker.mdx +1 -1
  158. package/en/configure/app/tools/ts-loader.mdx +1 -1
  159. package/en/configure/app/tools/webpack-chain.mdx +1 -1
  160. package/en/configure/app/tools/webpack.mdx +1 -1
  161. package/en/configure/app/usage.mdx +1 -1
  162. package/en/guides/advanced-features/_category_.json +2 -2
  163. package/en/guides/advanced-features/bff/bff-proxy.mdx +1 -1
  164. package/en/guides/advanced-features/bff/frameworks.mdx +1 -1
  165. package/en/guides/advanced-features/bff/function.mdx +3 -3
  166. package/en/guides/advanced-features/code-split.mdx +2 -2
  167. package/en/guides/advanced-features/compatibility.mdx +2 -3
  168. package/en/guides/advanced-features/eslint.mdx +4 -4
  169. package/en/guides/advanced-features/low-level.mdx +1 -1
  170. package/en/guides/advanced-features/rspack-start.mdx +69 -0
  171. package/en/guides/advanced-features/ssg.mdx +12 -13
  172. package/en/guides/advanced-features/ssr.mdx +3 -3
  173. package/en/guides/advanced-features/testing.mdx +4 -5
  174. package/en/guides/advanced-features/web-server.mdx +0 -1
  175. package/en/guides/basic-features/alias.mdx +5 -5
  176. package/en/guides/basic-features/data-fetch.mdx +25 -12
  177. package/en/guides/basic-features/env-vars.mdx +1 -1
  178. package/en/guides/basic-features/html.mdx +11 -11
  179. package/en/guides/basic-features/mock.mdx +21 -1
  180. package/en/guides/basic-features/proxy.mdx +2 -2
  181. package/en/guides/basic-features/routes.mdx +29 -15
  182. package/en/guides/{basic-features → concept}/builder.mdx +2 -2
  183. package/en/guides/concept/entries.mdx +11 -11
  184. package/en/guides/css/_category_.json +5 -0
  185. package/en/guides/{basic-features/css → css}/less-sass.mdx +1 -1
  186. package/en/guides/get-started/introduction.mdx +34 -0
  187. package/en/guides/get-started/quick-start.mdx +4 -4
  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/plugin/api/hook/onForged.mdx +1 -1
  192. package/en/guides/topic-detail/generator/plugin/develop.mdx +1 -1
  193. package/en/guides/topic-detail/micro-frontend/c02-development.mdx +128 -61
  194. package/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +73 -42
  195. package/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +1 -1
  196. package/en/guides/topic-detail/model/auto-actions.mdx +1 -1
  197. package/en/guides/topic-detail/model/define-model.mdx +1 -1
  198. package/en/guides/topic-detail/model/manage-effects.mdx +1 -1
  199. package/en/guides/topic-detail/model/model-communicate.mdx +1 -1
  200. package/en/guides/topic-detail/model/quick-start.mdx +2 -2
  201. package/en/guides/topic-detail/model/test-model.mdx +1 -1
  202. package/en/guides/topic-detail/model/use-model.mdx +3 -3
  203. package/en/guides/troubleshooting/_category_.json +2 -2
  204. package/en/guides/troubleshooting/cli.mdx +1 -1
  205. package/en/index.md +1 -1
  206. package/en/tutorials/first-app/_category_.json +1 -1
  207. package/en/tutorials/first-app/c01-start.mdx +0 -1
  208. package/en/tutorials/first-app/c03-css.mdx +1 -2
  209. package/en/tutorials/first-app/c06-model.mdx +1 -1
  210. package/en/tutorials/first-app/c07-container.mdx +18 -18
  211. package/en/tutorials/first-app/c08-entries.mdx +24 -25
  212. package/en/tutorials/foundations/introduction.mdx +17 -34
  213. package/package.json +3 -3
  214. package/scripts/config.ts +3 -1
  215. package/scripts/summary.en.json +1 -1
  216. package/scripts/summary.zh.json +1 -1
  217. package/zh/apis/app/commands.mdx +299 -0
  218. package/zh/apis/app/hooks/_category_.json +2 -5
  219. package/zh/apis/app/hooks/src/pages.mdx +1 -1
  220. package/zh/apis/app/hooks/src/routes.mdx +3 -3
  221. package/zh/apis/app/runtime/_category_.json +1 -5
  222. package/zh/apis/app/runtime/core/create-app.mdx +1 -1
  223. package/zh/apis/app/runtime/core/use-module-apps.mdx +81 -40
  224. package/zh/apis/app/runtime/model/Provider.mdx +2 -2
  225. package/zh/apis/app/runtime/model/create-app.mdx +7 -7
  226. package/zh/apis/app/runtime/model/create-store.mdx +2 -2
  227. package/zh/apis/app/runtime/model/use-local-model.mdx +1 -1
  228. package/zh/apis/app/runtime/model/use-static-model.mdx +1 -1
  229. package/zh/apis/app/runtime/model/use-store.mdx +1 -1
  230. package/zh/apis/app/runtime/testing/renderApp.mdx +1 -1
  231. package/zh/components/init-app.mdx +5 -5
  232. package/zh/components/micro-runtime-config.mdx +6 -6
  233. package/zh/components/release-note.mdx +1 -1
  234. package/zh/configure/app/bff/prefix.mdx +1 -1
  235. package/zh/configure/app/bff/proxy.mdx +1 -1
  236. package/zh/configure/app/builder-plugins.mdx +3 -3
  237. package/zh/configure/app/dev/before-start-url.mdx +13 -0
  238. package/zh/configure/app/dev/host.mdx +13 -0
  239. package/zh/configure/app/output/ssg.mdx +3 -3
  240. package/zh/configure/app/plugins.mdx +1 -1
  241. package/zh/configure/app/server/ssr-by-entries.mdx +1 -1
  242. package/zh/configure/app/source/entries-dir.mdx +1 -1
  243. package/zh/configure/app/tools/rspack.mdx +13 -0
  244. package/zh/configure/app/usage.mdx +1 -1
  245. package/zh/guides/advanced-features/_category_.json +2 -6
  246. package/zh/guides/advanced-features/compatibility.mdx +0 -1
  247. package/zh/guides/advanced-features/rspack-start.mdx +69 -0
  248. package/zh/guides/advanced-features/ssg.mdx +8 -9
  249. package/zh/guides/advanced-features/ssr.mdx +3 -2
  250. package/zh/guides/advanced-features/testing.mdx +0 -1
  251. package/zh/guides/advanced-features/web-server.mdx +0 -1
  252. package/zh/guides/basic-features/_category_.json +1 -5
  253. package/zh/guides/basic-features/alias.mdx +5 -5
  254. package/zh/guides/basic-features/data-fetch.mdx +39 -30
  255. package/zh/guides/basic-features/html.mdx +10 -9
  256. package/zh/guides/basic-features/mock.mdx +20 -0
  257. package/zh/guides/basic-features/routes.mdx +38 -17
  258. package/zh/guides/{basic-features → concept}/builder.mdx +4 -4
  259. package/zh/guides/concept/entries.mdx +11 -11
  260. package/zh/guides/css/_category_.json +5 -0
  261. package/zh/guides/{basic-features/css → css}/less-sass.mdx +1 -1
  262. package/zh/guides/{basic-features/css → css}/postcss.mdx +5 -4
  263. package/zh/guides/{basic-features/css → css}/tailwindcss.mdx +0 -1
  264. package/zh/guides/get-started/introduction.mdx +31 -0
  265. package/zh/guides/get-started/quick-start.mdx +4 -5
  266. package/zh/guides/get-started/upgrade.mdx +2 -1
  267. package/zh/guides/topic-detail/_category_.json +2 -2
  268. package/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +1 -1
  269. package/zh/guides/topic-detail/micro-frontend/c02-development.mdx +25 -0
  270. package/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +16 -16
  271. package/zh/guides/topic-detail/model/model-communicate.mdx +1 -1
  272. package/zh/guides/troubleshooting/_category_.json +2 -2
  273. package/zh/index.md +1 -1
  274. package/zh/tutorials/first-app/_category_.json +1 -1
  275. package/zh/tutorials/first-app/c01-start.mdx +1 -2
  276. package/zh/tutorials/first-app/c03-css.mdx +1 -2
  277. package/zh/tutorials/first-app/c06-model.mdx +2 -2
  278. package/zh/tutorials/first-app/c07-container.mdx +18 -18
  279. package/zh/tutorials/first-app/c08-entries.mdx +25 -26
  280. package/zh/tutorials/foundations/introduction.mdx +14 -29
  281. package/en/apis/app/commands/_category_.json +0 -8
  282. package/en/apis/app/commands/build.mdx +0 -39
  283. package/en/apis/app/commands/dev.mdx +0 -61
  284. package/en/apis/app/commands/index.mdx +0 -7
  285. package/en/apis/app/commands/inspect.mdx +0 -61
  286. package/en/apis/app/commands/lint.mdx +0 -19
  287. package/en/apis/app/commands/new.mdx +0 -54
  288. package/en/apis/app/commands/serve.mdx +0 -27
  289. package/en/apis/app/commands/test.mdx +0 -35
  290. package/en/apis/app/commands/upgrade.mdx +0 -18
  291. package/en/apis/app/hooks/index.mdx +0 -7
  292. package/en/apis/app/runtime/index.mdx +0 -7
  293. package/en/guides/advanced-features/index.mdx +0 -7
  294. package/en/guides/basic-features/css/_category_.json +0 -4
  295. package/zh/apis/app/commands/_category_.json +0 -8
  296. package/zh/apis/app/commands/build.mdx +0 -39
  297. package/zh/apis/app/commands/dev.mdx +0 -61
  298. package/zh/apis/app/commands/index.mdx +0 -7
  299. package/zh/apis/app/commands/inspect.mdx +0 -61
  300. package/zh/apis/app/commands/lint.mdx +0 -19
  301. package/zh/apis/app/commands/new.mdx +0 -54
  302. package/zh/apis/app/commands/serve.mdx +0 -27
  303. package/zh/apis/app/commands/test.mdx +0 -35
  304. package/zh/apis/app/commands/upgrade.mdx +0 -18
  305. package/zh/apis/app/hooks/index.mdx +0 -7
  306. package/zh/apis/app/runtime/index.mdx +0 -7
  307. package/zh/guides/advanced-features/index.mdx +0 -7
  308. package/zh/guides/basic-features/css/_category_.json +0 -4
  309. package/zh/guides/basic-features/index.mdx +0 -7
  310. /package/en/guides/{basic-features/css → css}/css-in-js.mdx +0 -0
  311. /package/en/guides/{basic-features/css → css}/css-modules.mdx +0 -0
  312. /package/en/guides/{basic-features/css → css}/postcss.mdx +0 -0
  313. /package/en/guides/{basic-features/css → css}/tailwindcss.mdx +0 -0
  314. /package/zh/guides/{basic-features/css → css}/css-in-js.mdx +0 -0
  315. /package/zh/guides/{basic-features/css → css}/css-modules.mdx +0 -0
@@ -88,7 +88,7 @@ export default function App() {
88
88
  ```
89
89
 
90
90
  :::info 补充信息
91
- Modern.js 默认开启 [自动生成 actions](./auto-actions.md),所以 `stepModel` 中虽然没有手动定义 Actions,但可以使用自动生成的 `setState`。
91
+ Modern.js 默认开启 [自动生成 actions](./auto-actions.mdx),所以 `stepModel` 中虽然没有手动定义 Actions,但可以使用自动生成的 `setState`。
92
92
 
93
93
  :::
94
94
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "label": "常见问题",
3
- "position": 6,
4
- "collapsed": true
3
+ "position": 10,
4
+ "collapsed": false
5
5
  }
package/zh/index.md CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  pageType: home
3
3
  ---
4
- # index
4
+ # Modern.js - 基于 React 的渐进式现代 Web 开发框架
@@ -1,5 +1,5 @@
1
1
  {
2
- "label": "联系人列表应用",
2
+ "label": "实战教程",
3
3
  "position": 2,
4
4
  "collapsed": false
5
5
  }
@@ -81,10 +81,9 @@ rm src/routes/index.css
81
81
 
82
82
  接下来,我们修改项目中的 `modern.config.ts`,开启 SSR 能力:
83
83
 
84
- ```ts
84
+ ```ts title="modern.config.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 @@ Modern.js 集成了主流、轻量、通用的 Utility Class 工具库 [Tailwind
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 @@ import '../styles/utils.css';
294
293
  ```
295
294
 
296
295
  :::info
297
- Modern.js 集成了 [PostCSS](/guides/basic-features/css/postcss),支持现代 CSS 语法特性,比如 [custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)。
296
+ Modern.js 集成了 [PostCSS](/guides/css/postcss),支持现代 CSS 语法特性,比如 [custom properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)。
298
297
 
299
298
  :::
300
299
 
@@ -10,8 +10,8 @@ title: 添加业务模型(状态管理)
10
10
 
11
11
  因此会开始编写一些跟 UI 完全无关的业务逻辑,如果继续写在组件代码中,会产生越来越多的面条式代码。为此,我们引入了一种叫做 **业务模型(Model)** 的代码模块,将这些业务逻辑和 UI 解耦。
12
12
 
13
- :::info
14
- 使用状态管理相关 API,需要先启用配置项 [runtime.state](/docs/configure/app/runtime/state):
13
+ :::info 注意
14
+ 使用状态管理相关 API,需要先启用配置项 [runtime.state](/configure/app/runtime/state):
15
15
 
16
16
  ```ts title="modern.config.ts"
17
17
  import { defineConfig } from '@modern-js/app-tools';
@@ -255,28 +255,28 @@ export default Index;
255
255
  ├── package.json
256
256
  ├── pnpm-lock.yaml
257
257
  ├── src
258
-    ├── components
259
-       ├── Avatar
260
-          └── index.tsx
261
-       └── Item
262
-       └── index.tsx
263
-    ├── containers
264
-       └── Contacts.tsx
265
-    ├── models
266
-       └── contacts.ts
267
-    ├── modern-app-env.d.ts
268
-    ├── routes
269
-       ├── archives
270
-          └── page.tsx
271
-       ├── layout.tsx
272
-       └── page.tsx
273
-    └── styles
274
-    └── utils.css
258
+ ├── components
259
+ ├── Avatar
260
+ └── index.tsx
261
+ └── Item
262
+ └── index.tsx
263
+ ├── containers
264
+ └── Contacts.tsx
265
+ ├── models
266
+ └── contacts.ts
267
+ ├── modern-app-env.d.ts
268
+ ├── routes
269
+ ├── archives
270
+ └── page.tsx
271
+ ├── layout.tsx
272
+ └── page.tsx
273
+ └── styles
274
+ └── utils.css
275
275
  └── tsconfig.json
276
276
  ```
277
277
 
278
278
  `components/` 里的**视图组件**,都是目录形式,如 `Avatar/index.tsx`。而 `containers/` 里的**容器组件**,都是单文件形式,如 `contacts.tsx`。**这是我们推荐的一种最佳实践**。
279
279
 
280
- 在 ​ [添加 UI 组件(Component)](./c02-component.md) 章节提到过,视图组件用目录形式,是因为视图组件负责实现 UI 展示和交互细节,可以演变的复杂。用目录形式,可以方便增加子文件,包括专用的资源(图片等)、专用子组件、CSS 文件等。在这个目录内部可以随意重构,只考虑最小局部。
280
+ 在 ​ [添加 UI 组件(Component)](./c02-component.mdx) 章节提到过,视图组件用目录形式,是因为视图组件负责实现 UI 展示和交互细节,可以演变的复杂。用目录形式,可以方便增加子文件,包括专用的资源(图片等)、专用子组件、CSS 文件等。在这个目录内部可以随意重构,只考虑最小局部。
281
281
 
282
282
  而容器组件只负责连接,是一个胶水层,复杂的业务逻辑和实现细节都交给 View 层和 Model 层去实现。容器组件自己应该保持简单清晰,不应该包含复杂实现细节,所以不应该有内部结构。采用单文件形式不但更简洁,也能起到约束作用,提醒开发者不要把容器组件写复杂。
@@ -29,29 +29,29 @@ title: 添加应用入口
29
29
  ├── package.json
30
30
  ├── pnpm-lock.yaml
31
31
  ├── src
32
-    ├── modern-app-env.d.ts
33
-    ├── landing-page
34
-       └── routes
35
-       ├── index.css
36
-       ├── layout.tsx
37
-       └── page.tsx
38
-    └── myapp
39
-    ├── components
40
-       ├── Avatar
41
-          └── index.tsx
42
-       └── Item
43
-       └── index.tsx
44
-    ├── containers
45
-       └── Contacts.tsx
46
-    ├── models
47
-       └── contacts.ts
48
-    ├── routes
49
-       ├── archives
50
-          └── page.tsx
51
-       ├── layout.tsx
52
-       └── page.tsx
53
-    └── styles
54
-    └── utils.css
32
+ ├── modern-app-env.d.ts
33
+ ├── landing-page
34
+ └── routes
35
+ ├── index.css
36
+ ├── layout.tsx
37
+ └── page.tsx
38
+ └── myapp
39
+ ├── components
40
+ ├── Avatar
41
+ └── index.tsx
42
+ └── Item
43
+ └── index.tsx
44
+ ├── containers
45
+ └── Contacts.tsx
46
+ ├── models
47
+ └── contacts.ts
48
+ ├── routes
49
+ ├── archives
50
+ └── page.tsx
51
+ ├── layout.tsx
52
+ └── page.tsx
53
+ └── styles
54
+ └── utils.css
55
55
  └── tsconfig.json
56
56
  ```
57
57
 
@@ -91,13 +91,12 @@ mv src/myapp src/contacts
91
91
 
92
92
  我们可以在 Modern.js 配置文件里,自己写代码来控制项目的配置。
93
93
 
94
- 现在,修改 `modern.config.ts` 里面添加内容:
94
+ 现在,修改 `modern.config.ts`,添加内容:
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,
@@ -2,44 +2,29 @@
2
2
  title: 介绍
3
3
  sidebar_position: 1
4
4
  ---
5
+
5
6
  # 介绍
6
7
 
7
8
  欢迎来到 Modern.js 教程!
8
9
 
9
10
  阅读本栏目后,你将初步理解 Modern.js,并使用 Modern.js 创建第一个应用。
10
11
 
11
- :::note 关注
12
- 加入我们的飞书群,咨询相关问题,了解最新动态。
13
-
14
- :::
15
-
16
12
  ## Modern.js 是什么
17
13
 
18
- **Modern.js** 是基于 React 的渐进式现代 Web 开发框架。
19
-
20
- 框架内置多种开箱即用的开发工具,拥有极致的构建性能,支持零配置的渲染范式切换,一体化的 API 调用。并从三种工程方案出发(应用工程方案、模块工程方案,Monorepo 工程方案),支持全链路的前端研发。
21
-
22
- Modern.js 是字节跳动的底层前端研发框架,已经直接或间接的服务上千个应用,包括中后台、PC Web、H5 等多种应用场景。框架覆盖完整的生命周期,拥有完善的插件体系,提供高度定制能力。支持通过生成器插件自定义业务线专属的工程方案,定制各种功能扩展和业务需求,帮助开发者更快速的搭建应用。
23
-
24
- ## 为什么使用 Modern.js
25
-
26
- Modern.js 能为开发者提供极致的**开发体验(Development Experience)**,让应用拥有更好的**用户体验(User Experience)**。
27
-
28
- 在开发 React 应用过程中,开发者通常需要去为某些功能去设计实现方案,或是使用其他的库、框架来解决这些问题。Modern.js 支持 React 应用所需要的所有配置和工具,并内置**额外的功能和优化**。开发者可以使用 React 构建应用的 UI,然后逐步采用 Modern.js 的功能来解决常见的应用需求,如路由、数据获取、状态管理等。
29
-
30
- 它主要包含以下特点:
31
-
32
- - 🪜 **渐进式**:使用最精简的模板创建项目,通过生成器逐步开启插件功能,定制解决方案。
33
- - 🏠 **一体化**:开发与生产环境 Web Server 唯一,CSR 和 SSR 同构开发,函数即接口的 API 服务调用。
34
- - 📦 **开箱即用**:默认 TS 支持,内置构建、ESLint、调试工具,全功能可测试。
35
- - 🌏 **周边生态**:自研状态管理、微前端、模块打包、Monorepo 方案等周边需求。
36
- - 🕸 **多种路由模式**:包含自控路由、基于文件约定的路由(嵌套路由)等。
37
- - 🚀 **独立构建核心**:支持多种打包工具,深度优化构建产物。
14
+ 如果你对 Modern.js 还不了解,可以先阅读 [Modern.js 介绍](/guides/get-started/introduction)。
38
15
 
39
- ## 下一步
16
+ ## 实战教程
40
17
 
41
- {/* 如果你是前端初学者,可能会觉得这些概念有些复杂。我们提供了一些 [JavaScript 和 React](/tutorials/foundations/basic) 的学习资料,你可以先对它们做些了解。
18
+ 我们准备了一个创建「联系人列表应用」的实战教程,你可以按照教程一步步创建一个应用,并了解到 Modern.js 中的以下实践:
42
19
 
43
- 如果你是有经验的开发者,希望了解如何使用 Modern.js,你可以尝试[创建第一个应用](/tutorials/first-app/c01-start),或是阅读[指南](/guides/get-started/quick-start)。 */}
20
+ - 创建项目
21
+ - 使用 antd 组件库
22
+ - 集成 Tailwind CSS
23
+ - 客户端路由
24
+ - 数据获取
25
+ - 状态管理
26
+ - 容器组件
27
+ - 新建入口
28
+ - ...
44
29
 
45
- 如果你希望了解如何使用 Modern.js,可以尝试[创建第一个应用](/tutorials/first-app/c01-start),或是阅读[指南](/guides/get-started/quick-start)。
30
+ 下面就让我们从 [创建项目](tutorials/first-app/c01-start) 开始吧!
@@ -1,8 +0,0 @@
1
- {
2
- "label": "Commands",
3
- "position": 0,
4
- "link": {
5
- "type": "doc",
6
- "id": "apis/app/commands/index"
7
- }
8
- }
@@ -1,39 +0,0 @@
1
- ---
2
- sidebar_position: 5
3
- ---
4
- # build
5
-
6
- ```bash
7
- Usage: modern build [options]
8
-
9
- build application
10
-
11
- Options:
12
- -c --config <config> configuration file path, which can be a relative path or an absolute path
13
- -h, --help show command help
14
- --analyze analyze the bundle and view size of each module
15
- ```
16
-
17
- `modern build` command will by default build production in `dist/`.
18
-
19
- you can configure the [`output.distPath`](/configure/app/output/dist-path) specifies the output directory for the product.
20
-
21
- ## Analyze Bundle
22
-
23
- execute `npx modern build --analyze` command,can produce an HTML file that analyzes the volume of the bundle while packaging the production code:
24
-
25
- ```
26
- Bundle Analyzer saved report to /example/dist/report.html
27
- File sizes after production build:
28
-
29
- 122.35 KB dist/static/js/885.1d4fbe5a.js
30
- 2.3 KB dist/static/js/main.4b8e8d64.js
31
- 761 B dist/static/js/runtime-main.edb7cf35.js
32
- 645 B dist/static/css/main.0dd3ecc1.css
33
- ```
34
-
35
- Open the above HTML file in the browser, you can see the tile diagram of the packaged product, and perform package volume analysis and optimization:
36
-
37
- <img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/aphqeh7uhohpquloj/modern-js/mwa-build-analyze-8784f762c1ab0cb20935829d5f912c4c.png" />
38
-
39
- > this features based on [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer).
@@ -1,61 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- ---
4
-
5
- # dev / start
6
-
7
- ```bash
8
- Usage: modern dev / modern start [options]
9
-
10
- Development commands
11
-
12
- Options:
13
- -e --entry <entry> compiler by entry
14
- -c --config <config> configuration file path, which can be a relative path or an absolute path
15
- -h, --help show command help
16
- --analyze analyze the bundle and view size of each module
17
- --api-only only start API service
18
- ```
19
-
20
- `modern dev` start a development server,watch file change,default support React Fast Refresh:
21
-
22
- `modern start` is an alias of `modern dev` command, the usage of the two are exactly the same.
23
-
24
- ```bash
25
- $ modern dev
26
-
27
- info Starting dev server...
28
- info App running at:
29
-
30
- > Local: http://localhost:8080/
31
- > Network: http://192.168.0.1:8080/
32
- ```
33
-
34
- ## Compile Partial Pages
35
-
36
- In multi-page (MPA) projects, the `--entry` option can be added to specify one or more pages to compile. In this way, only part of the code in the project will be compiled, and the dev startup speed will be faster.
37
-
38
- For example, execute `modern dev --entry`, the entry selector will be displayed in the command line interface:
39
-
40
- ```bash
41
- $ modern dev --entry
42
-
43
- ? Please select the entry that needs to be built
44
- ❯ ◯ foo
45
- ◯ bar
46
- ◯ baz
47
- ```
48
-
49
- For example, if you select the `foo` entry, only the code related to the `foo` entry will be compiled, and the code of other pages will not be compiled.
50
-
51
- ### Specify the page by parameter
52
-
53
- You can also specify the page name through parameters after `--entry`, and the names of multiple pages can be separated by commas.
54
-
55
- ```bash
56
- # Compile foo page
57
- modern dev --entry foo
58
-
59
- # Compile foo and bar pages
60
- modern dev --entry foo,bar
61
- ```
@@ -1,7 +0,0 @@
1
- ---
2
- type: ref
3
- ---
4
-
5
- # Commands
6
-
7
- This section covers all commands.
@@ -1,61 +0,0 @@
1
- ---
2
- sidebar_position: 7
3
- ---
4
- # inspect
5
-
6
- ```
7
- Usage: modern inspect [options]
8
-
9
- Options:
10
- --env <env> view the configuration in the target environment (default: "development")
11
- --output <output> Specify the path to output in the dist (default: "/")
12
- --verbose Show the full function in the result
13
- -c --config <config> configuration file path, which can be a relative path or an absolute path
14
- -h, --help show command help
15
- ```
16
-
17
- `modern inspect` command used to view the [Modern.js Builder config](https://modernjs.dev/builder/en/guide/basic/builder-config.html) and webpack config of the project.
18
-
19
- After executing the command `npx modern inspect` in the project root directory, the following files will be generated in the `dist` directory of the project:
20
-
21
- - `builder.config.js`: The Modern.js Builder config to use at build time.
22
- - `webpack.config.web.js`: The webpack config used by to use at build time.
23
-
24
- ```bash
25
- ➜ npx modern inspect
26
-
27
- Inspect config succeed, open following files to view the content:
28
-
29
- - Builder Config: /root/my-project/dist/builder.config.js
30
- - Webpack Config (web): /root/my-project/dist/webpack.config.web.js
31
- ```
32
-
33
- ## Configuration Env
34
-
35
- By default, the inspect command will output the development configs, you can use the `--env production` option to output the production configs:
36
-
37
- ```bash
38
- modern inspect --env production
39
- ```
40
-
41
- ## Verbose content
42
-
43
- By default, the inspect command will omit the function content in the config object, you can use the `--verbose` option to output the full content of the function:
44
-
45
- ```bash
46
- modern inspect --verbose
47
- ```
48
-
49
- ### SSR Configuration
50
-
51
- If the project has enabled SSR, an additional `webpack.config.node.js` file will be generated in the `dist/`, corresponding to the webpack configuration at SSR build time.
52
-
53
- ```bash
54
- ➜ npx modern inspect
55
-
56
- Inspect config succeed, open following files to view the content:
57
-
58
- - Builder Config: /root/my-project/dist/builder.config.js
59
- - Webpack Config (web): /root/my-project/dist/webpack.config.web.js
60
- - Webpack Config (node): /root/my-project/dist/webpack.config.node.js
61
- ```
@@ -1,19 +0,0 @@
1
- ---
2
- sidebar_position: 4
3
- title: lint
4
- ---
5
- # lint
6
-
7
- ```bash
8
- Usage: modern lint [options] [...files]
9
-
10
- lint and fix source files
11
-
12
- Options:
13
- --no-fix disable auto fix source file
14
- -h, --help display help for command
15
- ```
16
-
17
- Run ESLint to check the syntax of the code. Normally, only the part of the code modified by this commit needs to be checked by `lint-staged` during the `git commit` phase.
18
-
19
- - `--no-fix` close auto fix by lint.
@@ -1,54 +0,0 @@
1
- ---
2
- sidebar_position: 2
3
- ---
4
- # new
5
-
6
- ```bash
7
- Usage: modern new [options]
8
-
9
- Execution Generator in App
10
-
11
- Options:
12
- -d, --debug using debug mode to log something (default: false)
13
- -c, --config <config> set default generator config(json string)
14
- --dist-tag <tag> use specified tag version for its generator
15
- --registry set npm registry url to run npm command
16
- -h, --help show command help
17
- ```
18
-
19
- The `modern new` command is used to enable features to an existing project.
20
-
21
- For example, add application entry, enable some optional features such as Tailwind CSS, micro frontend, etc.
22
-
23
- ### Add Entry
24
-
25
- In the project, execute the `new` command to add entries as follows:
26
-
27
- ```bash
28
- $ npx modern new
29
- ? 请选择你想要的操作 创建工程元素
30
- ? 创建工程元素 新建「应用入口」
31
- ? 请填写入口名称 entry
32
- ```
33
-
34
- ### Enable Features
35
-
36
- In the project, execute the `new` command to enable features as follows:
37
-
38
- ```bash
39
- $ npx modern new
40
- ? 请选择你想要的操作 启用可选功能
41
- ? 启用可选功能 (Use arrow keys)
42
- ❯ 启用 Tailwind CSS 支持
43
- 启用「BFF」功能
44
- 启用「微前端」模式
45
- 启用「单元测试 / 集成测试」功能
46
- 启用「Visual Testing (Storybook)」模式
47
- ```
48
-
49
- :::caution
50
- The `--config` parameter needs to use a JSON string.
51
-
52
- pnpm does not support the use of JSON strings as parameter values currently. Use `npm new` to turn on.【[Relate Issue](https://github.com/pnpm/pnpm/issues/3876)】
53
-
54
- :::
@@ -1,27 +0,0 @@
1
- ---
2
- sidebar_position: 6
3
- ---
4
- # serve
5
-
6
- ```bash
7
- Usage: modern serve [options]
8
-
9
- run server
10
-
11
- Options:
12
- -c --config <config> configuration file path, which can be a relative path or an absolute path
13
- -h, --help show command help
14
- --api-only only run API service
15
- ```
16
-
17
- Usually use the `modern serve` command to enable project run in the production environment, and you need to execute the [`build'](/apis/app/commands/build) command in advance to build the product.
18
-
19
- By default, the project will run in `localhost:8080`, you can modify the Server port number with `server.port`:
20
-
21
- ```js
22
- export default defineConfig({
23
- server: {
24
- port: 8081,
25
- },
26
- });
27
- ```
@@ -1,35 +0,0 @@
1
- ---
2
- sidebar_position: 3
3
- ---
4
- # test
5
-
6
- ```bash
7
- Usage: modern test [options]
8
-
9
- Options:
10
- -h, --help show command help
11
- ```
12
-
13
- :::caution
14
- `modern test` command need to execute the `new` command in advance to enable the `unit test/integration test`.
15
-
16
- :::
17
-
18
- `modern test` command will automatically run the test cases, the effect is as follows:
19
-
20
- ```bash
21
- $ npx modern test
22
- PASS src/tests/index.test.ts
23
- The add method
24
- ✓ should work fine. (2ms)
25
-
26
- Test Suites: 1 passed, 1 total
27
- Tests: 1 passed, 1 total
28
- Snapshots: 0 total
29
- Time: 0.994 s, estimated 1 s
30
- ```
31
-
32
- :::info
33
- files match `*.test.(js|ts)` in `api/` or `src/` will be recognized as test cases by default。
34
-
35
- :::
@@ -1,18 +0,0 @@
1
- ---
2
- sidebar_position: 8
3
- ---
4
- # upgrade
5
-
6
- ```
7
- Usage: modern upgrade [options]
8
-
9
- upgrade Modern.js to latest version.
10
-
11
- Options:
12
- --registry <registry> specify npm registry (default: "")
13
- -d,--debug using debug mode to log something (default: false)
14
- --cwd <cwd> app directory (default: "")
15
- -h, --help show command help
16
- ```
17
-
18
- Execute the command `npx modern upgrade` in the project, by default, dependencies in the `package.json` are updated to the latest version.
@@ -1,7 +0,0 @@
1
- ---
2
- type: ref
3
- ---
4
-
5
- # Convention
6
-
7
- This section covers all documentation conventions.
@@ -1,7 +0,0 @@
1
- ---
2
- type: ref
3
- ---
4
-
5
- # Runtime
6
-
7
- This section covers all APIs using `@modern-js/runtime`.
@@ -1,7 +0,0 @@
1
- ---
2
- type: ref
3
- ---
4
-
5
- # Advanced Features
6
-
7
- This section covers advanced features of Modern.js.
@@ -1,4 +0,0 @@
1
- {
2
- "label": "CSS Solutions",
3
- "position": 4
4
- }
@@ -1,8 +0,0 @@
1
- {
2
- "label": "命令",
3
- "position": 0,
4
- "link": {
5
- "type": "doc",
6
- "id": "apis/app/commands/index"
7
- }
8
- }