@modern-js/main-doc 0.0.0-next-20221116121040

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (531) hide show
  1. package/.eslintrc.js +12 -0
  2. package/CHANGELOG.md +15 -0
  3. package/LICENSE +144 -0
  4. package/en/configure/app/dev/asset-prefix.md +13 -0
  5. package/en/configure/app/dev/hmr.md +13 -0
  6. package/en/configure/app/dev/https.md +13 -0
  7. package/en/configure/app/dev/port.md +13 -0
  8. package/en/configure/app/dev/progress-bar.md +13 -0
  9. package/en/configure/app/dev/start-url.md +13 -0
  10. package/en/configure/app/html/app-icon.md +13 -0
  11. package/en/configure/app/html/crossorigin.md +13 -0
  12. package/en/configure/app/html/disable-html-folder.md +13 -0
  13. package/en/configure/app/html/favicon-by-entries.md +13 -0
  14. package/en/configure/app/html/favicon.md +13 -0
  15. package/en/configure/app/html/inject-by-entries.md +13 -0
  16. package/en/configure/app/html/inject.md +13 -0
  17. package/en/configure/app/html/meta-by-entries.md +13 -0
  18. package/en/configure/app/html/meta.md +13 -0
  19. package/en/configure/app/html/mount-id.md +13 -0
  20. package/en/configure/app/html/template-by-entries.md +13 -0
  21. package/en/configure/app/html/template-parameters-by-entries.md +13 -0
  22. package/en/configure/app/html/template-parameters.md +13 -0
  23. package/en/configure/app/html/template.md +13 -0
  24. package/en/configure/app/html/title-by-entries.md +13 -0
  25. package/en/configure/app/html/title.md +13 -0
  26. package/en/configure/app/output/asset-prefix.md +13 -0
  27. package/en/configure/app/output/assets-retry.md +13 -0
  28. package/en/configure/app/output/charset.md +13 -0
  29. package/en/configure/app/output/clean-dist-path.md +13 -0
  30. package/en/configure/app/output/convert-to-rem.md +13 -0
  31. package/en/configure/app/output/copy.md +13 -0
  32. package/en/configure/app/output/css-module-local-ident-name.md +13 -0
  33. package/en/configure/app/output/data-uri-limit.md +13 -0
  34. package/en/configure/app/output/disable-css-module-extension.md +13 -0
  35. package/en/configure/app/output/disable-filename-hash.md +13 -0
  36. package/en/configure/app/output/disable-inline-runtime-chunk.md +13 -0
  37. package/en/configure/app/output/disable-minimize.md +13 -0
  38. package/en/configure/app/output/disable-source-map.md +13 -0
  39. package/en/configure/app/output/dist-path.md +13 -0
  40. package/en/configure/app/output/enable-asset-fallback.md +13 -0
  41. package/en/configure/app/output/enable-asset-manifest.md +13 -0
  42. package/en/configure/app/output/enable-css-module-tsdeclaration.md +13 -0
  43. package/en/configure/app/output/enable-inline-scripts.md +13 -0
  44. package/en/configure/app/output/enable-inline-styles.md +13 -0
  45. package/en/configure/app/output/enable-latest-decorators.md +13 -0
  46. package/en/configure/app/output/externals.md +13 -0
  47. package/en/configure/app/output/filename.md +13 -0
  48. package/en/configure/app/output/legal-comments.md +13 -0
  49. package/en/configure/app/output/override-browserslist.md +13 -0
  50. package/en/configure/app/output/polyfill.md +13 -0
  51. package/en/configure/app/output/svg-default-export.md +13 -0
  52. package/en/configure/app/performance/build-cache.md +13 -0
  53. package/en/configure/app/performance/bundle-analyze.md +13 -0
  54. package/en/configure/app/performance/chunk-split.md +13 -0
  55. package/en/configure/app/performance/print-file-size.md +13 -0
  56. package/en/configure/app/performance/profile.md +13 -0
  57. package/en/configure/app/performance/remove-console.md +13 -0
  58. package/en/configure/app/performance/remove-moment-locale.md +13 -0
  59. package/en/configure/app/security/sri.md +13 -0
  60. package/en/configure/app/source/alias.md +13 -0
  61. package/en/configure/app/source/compile-js-data-uri.md +13 -0
  62. package/en/configure/app/source/define.md +13 -0
  63. package/en/configure/app/source/global-vars.md +13 -0
  64. package/en/configure/app/source/include.md +13 -0
  65. package/en/configure/app/source/module-scopes.md +13 -0
  66. package/en/configure/app/source/pre-entry.md +13 -0
  67. package/en/configure/app/source/resolve-extension-prefix.md +13 -0
  68. package/en/configure/app/source/resolve-main-fields.md +13 -0
  69. package/en/configure/app/tools/autoprefixer.md +13 -0
  70. package/en/configure/app/tools/babel.md +13 -0
  71. package/en/configure/app/tools/css-extract.md +13 -0
  72. package/en/configure/app/tools/css-loader.md +13 -0
  73. package/en/configure/app/tools/dev-server.md +13 -0
  74. package/en/configure/app/tools/html-plugin.md +13 -0
  75. package/en/configure/app/tools/inspector.md +13 -0
  76. package/en/configure/app/tools/less.md +13 -0
  77. package/en/configure/app/tools/minify-css.md +13 -0
  78. package/en/configure/app/tools/postcss.md +13 -0
  79. package/en/configure/app/tools/pug.md +13 -0
  80. package/en/configure/app/tools/sass.md +13 -0
  81. package/en/configure/app/tools/style-loader.md +13 -0
  82. package/en/configure/app/tools/styled-components.md +13 -0
  83. package/en/configure/app/tools/terser.md +13 -0
  84. package/en/configure/app/tools/ts-checker.md +13 -0
  85. package/en/configure/app/tools/ts-loader.md +13 -0
  86. package/en/configure/app/tools/webpack-chain.md +13 -0
  87. package/en/configure/app/tools/webpack.md +13 -0
  88. package/en/tutorials/foundations/_category_.json +5 -0
  89. package/en/tutorials/foundations/basic.md +8 -0
  90. package/en/tutorials/foundations/introduction.md +43 -0
  91. package/package.json +30 -0
  92. package/scripts/gen-config.ts +60 -0
  93. package/scripts/sync.ts +36 -0
  94. package/tsconfig.json +7 -0
  95. package/zh/apis/app/commands/_category_.json +8 -0
  96. package/zh/apis/app/commands/build.md +44 -0
  97. package/zh/apis/app/commands/dev.md +31 -0
  98. package/zh/apis/app/commands/index.md +12 -0
  99. package/zh/apis/app/commands/inspect.md +39 -0
  100. package/zh/apis/app/commands/lint.md +22 -0
  101. package/zh/apis/app/commands/new.md +59 -0
  102. package/zh/apis/app/commands/start.md +32 -0
  103. package/zh/apis/app/commands/test.md +36 -0
  104. package/zh/apis/app/commands/upgrade.md +23 -0
  105. package/zh/apis/app/hooks/_category_.json +8 -0
  106. package/zh/apis/app/hooks/api/_category_.json +4 -0
  107. package/zh/apis/app/hooks/api/framework/_category_.json +4 -0
  108. package/zh/apis/app/hooks/api/framework/app.md +100 -0
  109. package/zh/apis/app/hooks/api/framework/lambda.md +79 -0
  110. package/zh/apis/app/hooks/api/functions/_category_.json +4 -0
  111. package/zh/apis/app/hooks/api/functions/api.md +50 -0
  112. package/zh/apis/app/hooks/api/functions/app.md +10 -0
  113. package/zh/apis/app/hooks/api/functions/common.md +10 -0
  114. package/zh/apis/app/hooks/api/test.md +12 -0
  115. package/zh/apis/app/hooks/config/_category_.json +4 -0
  116. package/zh/apis/app/hooks/config/html.md +10 -0
  117. package/zh/apis/app/hooks/config/icon.md +17 -0
  118. package/zh/apis/app/hooks/config/mock.md +12 -0
  119. package/zh/apis/app/hooks/config/public.md +30 -0
  120. package/zh/apis/app/hooks/config/storybook.md +14 -0
  121. package/zh/apis/app/hooks/config/upload.md +48 -0
  122. package/zh/apis/app/hooks/index.md +12 -0
  123. package/zh/apis/app/hooks/modern-config.md +10 -0
  124. package/zh/apis/app/hooks/server/_category_.json +4 -0
  125. package/zh/apis/app/hooks/server/index.md +14 -0
  126. package/zh/apis/app/hooks/server/test.md +12 -0
  127. package/zh/apis/app/hooks/shared.md +8 -0
  128. package/zh/apis/app/hooks/src/_category_.json +4 -0
  129. package/zh/apis/app/hooks/src/app.md +41 -0
  130. package/zh/apis/app/hooks/src/error.md +10 -0
  131. package/zh/apis/app/hooks/src/eslint.md +9 -0
  132. package/zh/apis/app/hooks/src/index.md +35 -0
  133. package/zh/apis/app/hooks/src/pages.md +183 -0
  134. package/zh/apis/app/hooks/src/stories.md +14 -0
  135. package/zh/apis/app/hooks/src/test.md +12 -0
  136. package/zh/apis/app/overview.md +11 -0
  137. package/zh/apis/app/runtime/_category_.json +9 -0
  138. package/zh/apis/app/runtime/app/_category_.json +4 -0
  139. package/zh/apis/app/runtime/app/bootstrap.md +83 -0
  140. package/zh/apis/app/runtime/app/create-app.md +47 -0
  141. package/zh/apis/app/runtime/app/define-config.md +57 -0
  142. package/zh/apis/app/runtime/app/head.md +43 -0
  143. package/zh/apis/app/runtime/app/no-ssr.md +41 -0
  144. package/zh/apis/app/runtime/app/pre-render.md +77 -0
  145. package/zh/apis/app/runtime/app/use-module-app.md +60 -0
  146. package/zh/apis/app/runtime/app/use-module-apps.md +64 -0
  147. package/zh/apis/app/runtime/app/use-runtime-context.md +39 -0
  148. package/zh/apis/app/runtime/bff-server/_category_.json +4 -0
  149. package/zh/apis/app/runtime/bff-server/after-lambda-registed.md +35 -0
  150. package/zh/apis/app/runtime/bff-server/hook.md +120 -0
  151. package/zh/apis/app/runtime/bff-server/use-context.md +70 -0
  152. package/zh/apis/app/runtime/container/_category_.json +4 -0
  153. package/zh/apis/app/runtime/container/router.md +492 -0
  154. package/zh/apis/app/runtime/container/use-loader.md +64 -0
  155. package/zh/apis/app/runtime/default-alias.md +26 -0
  156. package/zh/apis/app/runtime/env.md +68 -0
  157. package/zh/apis/app/runtime/index.md +12 -0
  158. package/zh/apis/app/runtime/model/Provider.md +36 -0
  159. package/zh/apis/app/runtime/model/_category_.json +4 -0
  160. package/zh/apis/app/runtime/model/auto-actions.md +121 -0
  161. package/zh/apis/app/runtime/model/connect.md +134 -0
  162. package/zh/apis/app/runtime/model/create-app.md +74 -0
  163. package/zh/apis/app/runtime/model/create-store.md +60 -0
  164. package/zh/apis/app/runtime/model/handle-effect.md +106 -0
  165. package/zh/apis/app/runtime/model/model_.md +199 -0
  166. package/zh/apis/app/runtime/model/use-local-model.md +28 -0
  167. package/zh/apis/app/runtime/model/use-model.md +87 -0
  168. package/zh/apis/app/runtime/model/use-static-model.md +47 -0
  169. package/zh/apis/app/runtime/model/use-store.md +48 -0
  170. package/zh/apis/app/runtime/plugin/_category_.json +4 -0
  171. package/zh/apis/app/runtime/plugin/abstract.md +26 -0
  172. package/zh/apis/app/runtime/plugin/hook-api.md +896 -0
  173. package/zh/apis/app/runtime/plugin/hook.md +170 -0
  174. package/zh/apis/app/runtime/plugin/plugin-api.md +117 -0
  175. package/zh/apis/app/runtime/testing/_category_.json +4 -0
  176. package/zh/apis/app/runtime/testing/act.md +34 -0
  177. package/zh/apis/app/runtime/testing/cleanup.md +37 -0
  178. package/zh/apis/app/runtime/testing/render.md +52 -0
  179. package/zh/apis/app/runtime/testing/renderApp.md +31 -0
  180. package/zh/apis/app/runtime/utility/_category_.json +4 -0
  181. package/zh/apis/app/runtime/utility/css-in-js.md +60 -0
  182. package/zh/apis/app/runtime/utility/loadable/_category_.json +4 -0
  183. package/zh/apis/app/runtime/utility/loadable/lazy.md +29 -0
  184. package/zh/apis/app/runtime/utility/loadable/loadable-component.md +61 -0
  185. package/zh/apis/app/runtime/utility/loadable/loadable-library.md +67 -0
  186. package/zh/apis/app/runtime/utility/loadable/loadable_.md +110 -0
  187. package/zh/apis/app/runtime/web-server/_category_.json +4 -0
  188. package/zh/apis/app/runtime/web-server/hook.md +121 -0
  189. package/zh/apis/generator/overview.md +32 -0
  190. package/zh/apis/generator/plugin/_category_.json +4 -0
  191. package/zh/apis/generator/plugin/file/_category_.json +4 -0
  192. package/zh/apis/generator/plugin/file/addFile.md +52 -0
  193. package/zh/apis/generator/plugin/file/addHelper.md +26 -0
  194. package/zh/apis/generator/plugin/file/addManyFile.md +55 -0
  195. package/zh/apis/generator/plugin/file/addPartial.md +26 -0
  196. package/zh/apis/generator/plugin/file/introduce.md +37 -0
  197. package/zh/apis/generator/plugin/file/rmDir.md +24 -0
  198. package/zh/apis/generator/plugin/file/rmFile.md +24 -0
  199. package/zh/apis/generator/plugin/file/updateJSONFile.md +52 -0
  200. package/zh/apis/generator/plugin/file/updateModernConfig.md +26 -0
  201. package/zh/apis/generator/plugin/file/updateTextRawFile.md +33 -0
  202. package/zh/apis/generator/plugin/git/_category_.json +4 -0
  203. package/zh/apis/generator/plugin/git/gitAddAndCommit.md +20 -0
  204. package/zh/apis/generator/plugin/git/initGitRepo.md +16 -0
  205. package/zh/apis/generator/plugin/git/isInGitRepo.md +16 -0
  206. package/zh/apis/generator/plugin/hook/_category_.json +4 -0
  207. package/zh/apis/generator/plugin/hook/afterForged.md +35 -0
  208. package/zh/apis/generator/plugin/hook/onForged.md +35 -0
  209. package/zh/apis/generator/plugin/info/_category_.json +4 -0
  210. package/zh/apis/generator/plugin/info/isFileExit.md +22 -0
  211. package/zh/apis/generator/plugin/info/locale.md +17 -0
  212. package/zh/apis/generator/plugin/info/readDir.md +22 -0
  213. package/zh/apis/generator/plugin/input/_category_.json +4 -0
  214. package/zh/apis/generator/plugin/input/addInputAfter.md +48 -0
  215. package/zh/apis/generator/plugin/input/addInputBefore.md +48 -0
  216. package/zh/apis/generator/plugin/input/addOptionAfter.md +45 -0
  217. package/zh/apis/generator/plugin/input/addOptionBefore.md +45 -0
  218. package/zh/apis/generator/plugin/input/setInput.md +42 -0
  219. package/zh/apis/generator/plugin/input/setInputValue.md +28 -0
  220. package/zh/apis/generator/plugin/input/type.md +101 -0
  221. package/zh/apis/generator/plugin/introduce.md +93 -0
  222. package/zh/apis/generator/plugin/new/_category_.json +4 -0
  223. package/zh/apis/generator/plugin/new/createElement.md +33 -0
  224. package/zh/apis/generator/plugin/new/createSubProject.md +35 -0
  225. package/zh/apis/generator/plugin/new/enableFunc.md +46 -0
  226. package/zh/apis/generator/plugin/new/introduce.md +15 -0
  227. package/zh/apis/generator/plugin/npm/_category_.json +4 -0
  228. package/zh/apis/generator/plugin/npm/install.md +16 -0
  229. package/zh/apis/monorepo/commands/_category_.json +8 -0
  230. package/zh/apis/monorepo/commands/bump.md +42 -0
  231. package/zh/apis/monorepo/commands/change.md +58 -0
  232. package/zh/apis/monorepo/commands/clear.md +27 -0
  233. package/zh/apis/monorepo/commands/deploy.md +39 -0
  234. package/zh/apis/monorepo/commands/gen-release-note.md +35 -0
  235. package/zh/apis/monorepo/commands/index.md +12 -0
  236. package/zh/apis/monorepo/commands/lint.md +21 -0
  237. package/zh/apis/monorepo/commands/new.md +41 -0
  238. package/zh/apis/monorepo/commands/pre.md +68 -0
  239. package/zh/apis/monorepo/commands/release.md +20 -0
  240. package/zh/apis/monorepo/commands/upgrade.md +23 -0
  241. package/zh/apis/monorepo/hooks/_category_.json +8 -0
  242. package/zh/apis/monorepo/hooks/apps.md +12 -0
  243. package/zh/apis/monorepo/hooks/code-workspace.md +10 -0
  244. package/zh/apis/monorepo/hooks/examples.md +14 -0
  245. package/zh/apis/monorepo/hooks/features.md +14 -0
  246. package/zh/apis/monorepo/hooks/index.md +12 -0
  247. package/zh/apis/monorepo/hooks/packages.md +14 -0
  248. package/zh/apis/monorepo/hooks/pnpm-workspace.md +10 -0
  249. package/zh/apis/monorepo/hooks/pnpmfile.md +10 -0
  250. package/zh/apis/monorepo/overview.md +11 -0
  251. package/zh/community/index.md +3 -0
  252. package/zh/components/command-tip.md +57 -0
  253. package/zh/components/deploy.md +60 -0
  254. package/zh/components/dev-ide.md +1 -0
  255. package/zh/components/entry-name.md +15 -0
  256. package/zh/components/env-prepare.md +1 -0
  257. package/zh/components/launch-bff-choices.md +6 -0
  258. package/zh/components/reduck-tip.md +5 -0
  259. package/zh/configure/app/bff/_category_.json +4 -0
  260. package/zh/configure/app/bff/fetcher.md +32 -0
  261. package/zh/configure/app/bff/prefix.md +38 -0
  262. package/zh/configure/app/bff/proxy.md +76 -0
  263. package/zh/configure/app/dev/_category_.json +4 -0
  264. package/zh/configure/app/dev/asset-prefix.md +13 -0
  265. package/zh/configure/app/dev/hmr.md +13 -0
  266. package/zh/configure/app/dev/https.md +13 -0
  267. package/zh/configure/app/dev/port.md +13 -0
  268. package/zh/configure/app/dev/progress-bar.md +13 -0
  269. package/zh/configure/app/dev/proxy.md +79 -0
  270. package/zh/configure/app/dev/start-url.md +13 -0
  271. package/zh/configure/app/dev/with-master-app.md +35 -0
  272. package/zh/configure/app/html/app-icon.md +13 -0
  273. package/zh/configure/app/html/crossorigin.md +13 -0
  274. package/zh/configure/app/html/disable-html-folder.md +13 -0
  275. package/zh/configure/app/html/favicon-by-entries.md +13 -0
  276. package/zh/configure/app/html/favicon.md +13 -0
  277. package/zh/configure/app/html/inject-by-entries.md +13 -0
  278. package/zh/configure/app/html/inject.md +13 -0
  279. package/zh/configure/app/html/meta-by-entries.md +13 -0
  280. package/zh/configure/app/html/meta.md +13 -0
  281. package/zh/configure/app/html/mount-id.md +13 -0
  282. package/zh/configure/app/html/template-by-entries.md +13 -0
  283. package/zh/configure/app/html/template-parameters-by-entries.md +13 -0
  284. package/zh/configure/app/html/template-parameters.md +13 -0
  285. package/zh/configure/app/html/template.md +13 -0
  286. package/zh/configure/app/html/title-by-entries.md +13 -0
  287. package/zh/configure/app/html/title.md +13 -0
  288. package/zh/configure/app/output/_category_.json +4 -0
  289. package/zh/configure/app/output/asset-prefix.md +13 -0
  290. package/zh/configure/app/output/assets-retry.md +13 -0
  291. package/zh/configure/app/output/charset.md +13 -0
  292. package/zh/configure/app/output/clean-dist-path.md +13 -0
  293. package/zh/configure/app/output/convert-to-rem.md +13 -0
  294. package/zh/configure/app/output/copy.md +13 -0
  295. package/zh/configure/app/output/css-module-local-ident-name.md +13 -0
  296. package/zh/configure/app/output/data-uri-limit.md +13 -0
  297. package/zh/configure/app/output/disable-css-module-extension.md +13 -0
  298. package/zh/configure/app/output/disable-filename-hash.md +13 -0
  299. package/zh/configure/app/output/disable-inline-runtime-chunk.md +13 -0
  300. package/zh/configure/app/output/disable-minimize.md +13 -0
  301. package/zh/configure/app/output/disable-node-polyfill.md +24 -0
  302. package/zh/configure/app/output/disable-source-map.md +13 -0
  303. package/zh/configure/app/output/dist-path.md +13 -0
  304. package/zh/configure/app/output/enable-asset-fallback.md +13 -0
  305. package/zh/configure/app/output/enable-asset-manifest.md +13 -0
  306. package/zh/configure/app/output/enable-css-module-tsdeclaration.md +13 -0
  307. package/zh/configure/app/output/enable-inline-scripts.md +13 -0
  308. package/zh/configure/app/output/enable-inline-styles.md +13 -0
  309. package/zh/configure/app/output/enable-latest-decorators.md +13 -0
  310. package/zh/configure/app/output/enable-modern-mode.md +26 -0
  311. package/zh/configure/app/output/externals.md +13 -0
  312. package/zh/configure/app/output/filename.md +13 -0
  313. package/zh/configure/app/output/legal-comments.md +13 -0
  314. package/zh/configure/app/output/override-browserslist.md +13 -0
  315. package/zh/configure/app/output/polyfill.md +13 -0
  316. package/zh/configure/app/output/ssg.md +226 -0
  317. package/zh/configure/app/output/svg-default-export.md +13 -0
  318. package/zh/configure/app/performance/build-cache.md +13 -0
  319. package/zh/configure/app/performance/bundle-analyze.md +13 -0
  320. package/zh/configure/app/performance/chunk-split.md +13 -0
  321. package/zh/configure/app/performance/print-file-size.md +13 -0
  322. package/zh/configure/app/performance/profile.md +13 -0
  323. package/zh/configure/app/performance/remove-console.md +13 -0
  324. package/zh/configure/app/performance/remove-moment-locale.md +13 -0
  325. package/zh/configure/app/plugins.md +74 -0
  326. package/zh/configure/app/runtime/_category_.json +4 -0
  327. package/zh/configure/app/runtime/master-app.md +72 -0
  328. package/zh/configure/app/runtime/router.md +54 -0
  329. package/zh/configure/app/runtime/state.md +45 -0
  330. package/zh/configure/app/security/sri.md +13 -0
  331. package/zh/configure/app/server/_category_.json +4 -0
  332. package/zh/configure/app/server/base-url.md +36 -0
  333. package/zh/configure/app/server/port.md +21 -0
  334. package/zh/configure/app/server/public-routes.md +29 -0
  335. package/zh/configure/app/server/routes.md +92 -0
  336. package/zh/configure/app/server/ssr-by-entries.md +32 -0
  337. package/zh/configure/app/server/ssr.md +24 -0
  338. package/zh/configure/app/source/_category_.json +4 -0
  339. package/zh/configure/app/source/alias.md +13 -0
  340. package/zh/configure/app/source/compile-js-data-uri.md +13 -0
  341. package/zh/configure/app/source/config-dir.md +15 -0
  342. package/zh/configure/app/source/define.md +13 -0
  343. package/zh/configure/app/source/design-system.md +1156 -0
  344. package/zh/configure/app/source/disable-default-entries.md +23 -0
  345. package/zh/configure/app/source/enable-async-entry.md +53 -0
  346. package/zh/configure/app/source/entries-dir.md +42 -0
  347. package/zh/configure/app/source/entries.md +55 -0
  348. package/zh/configure/app/source/global-vars.md +13 -0
  349. package/zh/configure/app/source/include.md +13 -0
  350. package/zh/configure/app/source/module-scopes.md +13 -0
  351. package/zh/configure/app/source/pre-entry.md +13 -0
  352. package/zh/configure/app/source/resolve-extension-prefix.md +13 -0
  353. package/zh/configure/app/source/resolve-main-fields.md +13 -0
  354. package/zh/configure/app/testing/_category_.json +4 -0
  355. package/zh/configure/app/testing/transformer.md +17 -0
  356. package/zh/configure/app/tools/_category_.json +4 -0
  357. package/zh/configure/app/tools/autoprefixer.md +13 -0
  358. package/zh/configure/app/tools/babel.md +13 -0
  359. package/zh/configure/app/tools/css-extract.md +13 -0
  360. package/zh/configure/app/tools/css-loader.md +13 -0
  361. package/zh/configure/app/tools/dev-server.md +13 -0
  362. package/zh/configure/app/tools/esbuild.md +61 -0
  363. package/zh/configure/app/tools/html-plugin.md +13 -0
  364. package/zh/configure/app/tools/inspector.md +13 -0
  365. package/zh/configure/app/tools/jest.md +41 -0
  366. package/zh/configure/app/tools/less.md +13 -0
  367. package/zh/configure/app/tools/minify-css.md +13 -0
  368. package/zh/configure/app/tools/postcss.md +13 -0
  369. package/zh/configure/app/tools/pug.md +13 -0
  370. package/zh/configure/app/tools/sass.md +13 -0
  371. package/zh/configure/app/tools/style-loader.md +13 -0
  372. package/zh/configure/app/tools/styled-components.md +13 -0
  373. package/zh/configure/app/tools/tailwindcss.md +48 -0
  374. package/zh/configure/app/tools/terser.md +13 -0
  375. package/zh/configure/app/tools/ts-checker.md +13 -0
  376. package/zh/configure/app/tools/ts-loader.md +13 -0
  377. package/zh/configure/app/tools/webpack-chain.md +13 -0
  378. package/zh/configure/app/tools/webpack.md +13 -0
  379. package/zh/configure/app/usage.md +81 -0
  380. package/zh/configure/generator/introduce.md +113 -0
  381. package/zh/configure/generator/module.md +43 -0
  382. package/zh/configure/generator/monorepo.md +28 -0
  383. package/zh/configure/generator/mwa.md +127 -0
  384. package/zh/guides/advanced-features/_category_.json +9 -0
  385. package/zh/guides/advanced-features/bff/_category_.json +4 -0
  386. package/zh/guides/advanced-features/bff/bff-proxy.md +25 -0
  387. package/zh/guides/advanced-features/bff/bff-server.md +142 -0
  388. package/zh/guides/advanced-features/bff/frameworks.md +348 -0
  389. package/zh/guides/advanced-features/bff/function.md +236 -0
  390. package/zh/guides/advanced-features/code-split.md +68 -0
  391. package/zh/guides/advanced-features/compatibility.md +89 -0
  392. package/zh/guides/advanced-features/custom-app.md +4 -0
  393. package/zh/guides/advanced-features/eslint.md +146 -0
  394. package/zh/guides/advanced-features/index.md +12 -0
  395. package/zh/guides/advanced-features/low-level.md +44 -0
  396. package/zh/guides/advanced-features/ssg.md +151 -0
  397. package/zh/guides/advanced-features/ssr.md +186 -0
  398. package/zh/guides/advanced-features/testing.md +4 -0
  399. package/zh/guides/advanced-features/typescript.md +4 -0
  400. package/zh/guides/advanced-features/web-server.md +135 -0
  401. package/zh/guides/basic-features/_category_.json +9 -0
  402. package/zh/guides/basic-features/alias.md +67 -0
  403. package/zh/guides/basic-features/css/_category_.json +4 -0
  404. package/zh/guides/basic-features/css/css-in-js.md +38 -0
  405. package/zh/guides/basic-features/css/css-modules.md +86 -0
  406. package/zh/guides/basic-features/css/less-sass.md +29 -0
  407. package/zh/guides/basic-features/css/postcss.md +81 -0
  408. package/zh/guides/basic-features/css/tailwindcss.md +98 -0
  409. package/zh/guides/basic-features/data-fetch.md +4 -0
  410. package/zh/guides/basic-features/env-vars.md +83 -0
  411. package/zh/guides/basic-features/html.md +128 -0
  412. package/zh/guides/basic-features/image.md +43 -0
  413. package/zh/guides/basic-features/index.md +12 -0
  414. package/zh/guides/basic-features/mock.md +85 -0
  415. package/zh/guides/basic-features/proxy.md +85 -0
  416. package/zh/guides/basic-features/routes.md +4 -0
  417. package/zh/guides/concept/_category_.json +5 -0
  418. package/zh/guides/concept/entries.md +4 -0
  419. package/zh/guides/concept/integrated.md +4 -0
  420. package/zh/guides/concept/lifecycle.md +4 -0
  421. package/zh/guides/concept/solutions.md +4 -0
  422. package/zh/guides/get-started/_category_.json +5 -0
  423. package/zh/guides/get-started/quick-start.md +4 -0
  424. package/zh/guides/get-started/upgrade.md +4 -0
  425. package/zh/guides/overview.md +11 -0
  426. package/zh/guides/topic-detail/_category_.json +5 -0
  427. package/zh/guides/topic-detail/changesets/_category_.json +4 -0
  428. package/zh/guides/topic-detail/changesets/add.md +125 -0
  429. package/zh/guides/topic-detail/changesets/changelog.md +239 -0
  430. package/zh/guides/topic-detail/changesets/commit.md +272 -0
  431. package/zh/guides/topic-detail/changesets/config.md +146 -0
  432. package/zh/guides/topic-detail/changesets/github.md +168 -0
  433. package/zh/guides/topic-detail/changesets/introduce.md +57 -0
  434. package/zh/guides/topic-detail/changesets/release-note.md +262 -0
  435. package/zh/guides/topic-detail/changesets/release-pre.md +49 -0
  436. package/zh/guides/topic-detail/changesets/release.md +228 -0
  437. package/zh/guides/topic-detail/compile-speed.md +182 -0
  438. package/zh/guides/topic-detail/framework-plugin/_category_.json +4 -0
  439. package/zh/guides/topic-detail/framework-plugin/abstract.md +27 -0
  440. package/zh/guides/topic-detail/framework-plugin/extend.md +163 -0
  441. package/zh/guides/topic-detail/framework-plugin/implement.md +188 -0
  442. package/zh/guides/topic-detail/framework-plugin/relationship.md +119 -0
  443. package/zh/guides/topic-detail/generator-plugin/_category_.json +4 -0
  444. package/zh/guides/topic-detail/generator-plugin/abstract.md +23 -0
  445. package/zh/guides/topic-detail/generator-plugin/develop.md +120 -0
  446. package/zh/guides/topic-detail/generator-plugin/use.md +61 -0
  447. package/zh/guides/topic-detail/micro-frontend/_category_.json +4 -0
  448. package/zh/guides/topic-detail/micro-frontend/communicate.md +39 -0
  449. package/zh/guides/topic-detail/micro-frontend/debugging.md +168 -0
  450. package/zh/guides/topic-detail/micro-frontend/introduction.md +13 -0
  451. package/zh/guides/topic-detail/micro-frontend/mixed-stack.md +24 -0
  452. package/zh/guides/topic-detail/micro-frontend/route-mode.md +110 -0
  453. package/zh/guides/topic-detail/model/_category_.json +4 -0
  454. package/zh/guides/topic-detail/model/auto-actions.md +90 -0
  455. package/zh/guides/topic-detail/model/computed-state.md +151 -0
  456. package/zh/guides/topic-detail/model/define-model.md +66 -0
  457. package/zh/guides/topic-detail/model/faq.md +43 -0
  458. package/zh/guides/topic-detail/model/manage-effects.md +259 -0
  459. package/zh/guides/topic-detail/model/model-communicate.md +219 -0
  460. package/zh/guides/topic-detail/model/performance.md +173 -0
  461. package/zh/guides/topic-detail/model/quick-start.md +112 -0
  462. package/zh/guides/topic-detail/model/redux-integration.md +21 -0
  463. package/zh/guides/topic-detail/model/test-model.md +43 -0
  464. package/zh/guides/topic-detail/model/typescript-best-practice.md +71 -0
  465. package/zh/guides/topic-detail/model/use-model.md +244 -0
  466. package/zh/guides/topic-detail/model/use-out-of-modernjs.md +51 -0
  467. package/zh/guides/topic-detail/monorepo/_category_.json +4 -0
  468. package/zh/guides/topic-detail/monorepo/create-sub-project.md +64 -0
  469. package/zh/guides/topic-detail/monorepo/deploy.md +43 -0
  470. package/zh/guides/topic-detail/monorepo/intro.md +15 -0
  471. package/zh/guides/topic-detail/monorepo/publish.md +68 -0
  472. package/zh/guides/topic-detail/monorepo/sub-project-interface.md +170 -0
  473. package/zh/guides/troubleshooting/_category_.json +5 -0
  474. package/zh/guides/troubleshooting/compile.md +379 -0
  475. package/zh/guides/troubleshooting/dependencies.md +168 -0
  476. package/zh/tutorials/first-app/_category_.json +5 -0
  477. package/zh/tutorials/first-app/c01-getting-started/1.1-prerequisites.md +25 -0
  478. package/zh/tutorials/first-app/c01-getting-started/1.2-minimal-mwa.md +118 -0
  479. package/zh/tutorials/first-app/c01-getting-started/1.3-dev-command.md +29 -0
  480. package/zh/tutorials/first-app/c01-getting-started/1.4-enable-ssr.md +44 -0
  481. package/zh/tutorials/first-app/c01-getting-started/1.5-start-command.md +18 -0
  482. package/zh/tutorials/first-app/c01-getting-started/1.6-create-repo.md +31 -0
  483. package/zh/tutorials/first-app/c01-getting-started/_category_.json +3 -0
  484. package/zh/tutorials/first-app/c02-generator-and-studio/2.1-generator.md +87 -0
  485. package/zh/tutorials/first-app/c02-generator-and-studio/2.2-boilerplates.md +28 -0
  486. package/zh/tutorials/first-app/c02-generator-and-studio/2.3-configuration.md +21 -0
  487. package/zh/tutorials/first-app/c02-generator-and-studio/_category_.json +3 -0
  488. package/zh/tutorials/first-app/c03-ide/3.1-setting-up.md +55 -0
  489. package/zh/tutorials/first-app/c03-ide/3.2-hints-in-ide.md +66 -0
  490. package/zh/tutorials/first-app/c03-ide/3.3-autofix-in-ide.md +11 -0
  491. package/zh/tutorials/first-app/c03-ide/3.4-autofix-in-cli.md +63 -0
  492. package/zh/tutorials/first-app/c03-ide/_category_.json +3 -0
  493. package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.1-use-es6-plus.md +67 -0
  494. package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.2-use-typescript.md +111 -0
  495. package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.3-compatibility.md +67 -0
  496. package/zh/tutorials/first-app/c04-es6-plus-and-ts/_category_.json +3 -0
  497. package/zh/tutorials/first-app/c05-component/5.1-use-ui-library.md +68 -0
  498. package/zh/tutorials/first-app/c05-component/5.2-use-standalone-component.md +92 -0
  499. package/zh/tutorials/first-app/c05-component/_category_.json +3 -0
  500. package/zh/tutorials/first-app/c06-css-and-component/6.1-css-in-js.md +110 -0
  501. package/zh/tutorials/first-app/c06-css-and-component/6.2-utility-class.md +148 -0
  502. package/zh/tutorials/first-app/c06-css-and-component/6.3-postcss.md +84 -0
  503. package/zh/tutorials/first-app/c06-css-and-component/6.4-design-system.md +83 -0
  504. package/zh/tutorials/first-app/c06-css-and-component/6.5-storybook.md +77 -0
  505. package/zh/tutorials/first-app/c06-css-and-component/6.6-testing.md +113 -0
  506. package/zh/tutorials/first-app/c06-css-and-component/_category_.json +3 -0
  507. package/zh/tutorials/first-app/c07-app-entry/7.1-intro.md +64 -0
  508. package/zh/tutorials/first-app/c07-app-entry/7.2-add-entry-in-cli.md +104 -0
  509. package/zh/tutorials/first-app/c07-app-entry/7.3-manage-entries-by-hand.md +74 -0
  510. package/zh/tutorials/first-app/c07-app-entry/_category_.json +3 -0
  511. package/zh/tutorials/first-app/c08-client-side-routing/8.1-code-based-routing.md +153 -0
  512. package/zh/tutorials/first-app/c08-client-side-routing/8.2-file-based-routing.md +318 -0
  513. package/zh/tutorials/first-app/c08-client-side-routing/_category_.json +3 -0
  514. package/zh/tutorials/first-app/c09-bff/9.1-serverless.md +30 -0
  515. package/zh/tutorials/first-app/c09-bff/9.2-enable-bff.md +93 -0
  516. package/zh/tutorials/first-app/c09-bff/9.3-fetch-bff.md +205 -0
  517. package/zh/tutorials/first-app/c09-bff/_category_.json +3 -0
  518. package/zh/tutorials/first-app/c10-model/10.1-application-architecture.md +23 -0
  519. package/zh/tutorials/first-app/c10-model/10.2-add-model.md +185 -0
  520. package/zh/tutorials/first-app/c10-model/10.3-use-model.md +54 -0
  521. package/zh/tutorials/first-app/c10-model/10.4-testing.md +69 -0
  522. package/zh/tutorials/first-app/c10-model/_category_.json +3 -0
  523. package/zh/tutorials/first-app/c11-container/11.1-use-model-with-app-state.md +274 -0
  524. package/zh/tutorials/first-app/c11-container/11.2-add-container.md +106 -0
  525. package/zh/tutorials/first-app/c11-container/11.3-use-loader.md +61 -0
  526. package/zh/tutorials/first-app/c11-container/11.4-testing.md +56 -0
  527. package/zh/tutorials/first-app/c11-container/_category_.json +3 -0
  528. package/zh/tutorials/first-app/overview.md +11 -0
  529. package/zh/tutorials/foundations/_category_.json +5 -0
  530. package/zh/tutorials/foundations/basic.md +8 -0
  531. package/zh/tutorials/foundations/introduction.md +41 -0
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: tools.styleLoader
3
+ sidebar_label: styleLoader
4
+ sidebar_position: 1
5
+ ---
6
+
7
+ :::info BUILDER
8
+ This configuration is Modern.js Builder configuration, there may be links that cannot be redirected. for details, please refer to [tools.styleLoader](https://modernjs.dev/builder/zh/api/config-tools.html#tools-styleloader)。
9
+ :::
10
+
11
+ import Main from '@modern-js/builder-doc/en/config/tools/styleLoader.md'
12
+
13
+ <Main />
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: tools.styledComponents
3
+ sidebar_label: styledComponents
4
+ sidebar_position: 1
5
+ ---
6
+
7
+ :::info BUILDER
8
+ This configuration is Modern.js Builder configuration, there may be links that cannot be redirected. for details, please refer to [tools.styledComponents](https://modernjs.dev/builder/zh/api/config-tools.html#tools-styledcomponents)。
9
+ :::
10
+
11
+ import Main from '@modern-js/builder-doc/en/config/tools/styledComponents.md'
12
+
13
+ <Main />
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: tools.terser
3
+ sidebar_label: terser
4
+ sidebar_position: 1
5
+ ---
6
+
7
+ :::info BUILDER
8
+ This configuration is Modern.js Builder configuration, there may be links that cannot be redirected. for details, please refer to [tools.terser](https://modernjs.dev/builder/zh/api/config-tools.html#tools-terser)。
9
+ :::
10
+
11
+ import Main from '@modern-js/builder-doc/en/config/tools/terser.md'
12
+
13
+ <Main />
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: tools.tsChecker
3
+ sidebar_label: tsChecker
4
+ sidebar_position: 1
5
+ ---
6
+
7
+ :::info BUILDER
8
+ This configuration is Modern.js Builder configuration, there may be links that cannot be redirected. for details, please refer to [tools.tsChecker](https://modernjs.dev/builder/zh/api/config-tools.html#tools-tschecker)。
9
+ :::
10
+
11
+ import Main from '@modern-js/builder-doc/en/config/tools/tsChecker.md'
12
+
13
+ <Main />
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: tools.tsLoader
3
+ sidebar_label: tsLoader
4
+ sidebar_position: 1
5
+ ---
6
+
7
+ :::info BUILDER
8
+ This configuration is Modern.js Builder configuration, there may be links that cannot be redirected. for details, please refer to [tools.tsLoader](https://modernjs.dev/builder/zh/api/config-tools.html#tools-tsloader)。
9
+ :::
10
+
11
+ import Main from '@modern-js/builder-doc/en/config/tools/tsLoader.md'
12
+
13
+ <Main />
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: tools.webpackChain
3
+ sidebar_label: webpackChain
4
+ sidebar_position: 1
5
+ ---
6
+
7
+ :::info BUILDER
8
+ This configuration is Modern.js Builder configuration, there may be links that cannot be redirected. for details, please refer to [tools.webpackChain](https://modernjs.dev/builder/zh/api/config-tools.html#tools-webpackchain)。
9
+ :::
10
+
11
+ import Main from '@modern-js/builder-doc/en/config/tools/webpackChain.md'
12
+
13
+ <Main />
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: tools.webpack
3
+ sidebar_label: webpack
4
+ sidebar_position: 1
5
+ ---
6
+
7
+ :::info BUILDER
8
+ This configuration is Modern.js Builder configuration, there may be links that cannot be redirected. for details, please refer to [tools.webpack](https://modernjs.dev/builder/zh/api/config-tools.html#tools-webpack)。
9
+ :::
10
+
11
+ import Main from '@modern-js/builder-doc/en/config/tools/webpack.md'
12
+
13
+ <Main />
@@ -0,0 +1,5 @@
1
+ {
2
+ "label": "基础",
3
+ "position": 1,
4
+ "collapsed": false
5
+ }
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: JavaScript & React
3
+ sidebar_position: 2
4
+ ---
5
+
6
+ :::note Todo
7
+ Coming Soon...
8
+ :::
@@ -0,0 +1,43 @@
1
+ ---
2
+ title: Modern.js Introduce
3
+ sidebar_position: 1
4
+ ---
5
+
6
+ Welcome to Modern.js tutorials!
7
+
8
+ After reading this section, you will have an initial understanding of Modern.js and use Modern.js to create your first application.
9
+
10
+ :::note Follow
11
+ Join our Lark group to ask questions and learn about the latest news.
12
+ :::
13
+
14
+ ## What is Modern.js
15
+
16
+ **Modern.js** is a progressive modern web development framework based on React.
17
+
18
+ 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.
19
+
20
+ 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.
21
+
22
+ ## Why Modern.js
23
+
24
+ Modern.js can provide developers with the ultimate **Development Experience**,make the app better **User Experience**。
25
+
26
+ 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。
27
+
28
+ 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.
29
+
30
+ It mainly contains the following features:
31
+
32
+ - 🪜 **Progressive**:Create projects with the most streamlined templates, gradually turn on plugin capabilities through generators, and customize solutions.
33
+ - 🏠 **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.
34
+ - 📦 **Out Of The Box**:Default TS support, built-in build core, ESLint, debugging tools, full functionality can be tested.
35
+ - 🌏 **Ecology**:Self-developed state management, micro frontend, module packaging, Monorepo solution and other peripheral requirements.
36
+ - 🕸 **Routing Modes**:Contains controlled routing, routing based on file conventions (nested routing), configurable routing, etc。
37
+ - 🚀 **Independently Build Core**:Support a variety of packaging tools, deep optimization bundle.
38
+
39
+ ## Next
40
+
41
+ If you are a front-end beginner, you may find these concepts a bit complicated. We provide some [JavaScript and React](/docs/tutorials/foundations/basic) learning materials, you can do some understanding of them first。
42
+
43
+ If you are an experienced developer and want to know how to use Modern.js, you can try [Create your first app](/docs/tutorials/first-app/overview), or read [Guide](/docs/guides/overview).
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@modern-js/main-doc",
3
+ "description": "Shared documentation of modern.js framework",
4
+ "homepage": "https://modernjs.dev",
5
+ "bugs": "https://github.com/modern-js-dev/modern.js/issues",
6
+ "repository": "modern-js-dev/modern.js",
7
+ "license": "MIT",
8
+ "keywords": [
9
+ "react",
10
+ "framework",
11
+ "modern",
12
+ "modern.js"
13
+ ],
14
+ "version": "0.0.0-next-20221116121040",
15
+ "publishConfig": {
16
+ "registry": "https://registry.npmjs.org/",
17
+ "access": "public"
18
+ },
19
+ "peerDependencies": {
20
+ "@modern-js/builder-doc": "0.0.0-next-20221116121040"
21
+ },
22
+ "devDependencies": {
23
+ "@modern-js/builder-doc": "0.0.0-next-20221116121040",
24
+ "ts-node": "^10",
25
+ "fs-extra": "^10",
26
+ "@types/node": "^16",
27
+ "@types/fs-extra": "^9"
28
+ },
29
+ "scripts": {}
30
+ }
@@ -0,0 +1,60 @@
1
+ import path from 'path';
2
+ import fs from 'fs-extra';
3
+
4
+ const tip: Record<string, string> = {
5
+ zh: '该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考',
6
+ en: 'This configuration is Modern.js Builder configuration, there may be links that cannot be redirected. for details, please refer to',
7
+ };
8
+
9
+ const createMarkdown = (
10
+ summary: {
11
+ dirname: string;
12
+ name: string;
13
+ },
14
+ key: string,
15
+ ) => {
16
+ const { name, dirname } = summary;
17
+
18
+ return `---
19
+ title: ${dirname}.${name}
20
+ sidebar_label: ${name}
21
+ sidebar_position: 1
22
+ ---
23
+
24
+ :::info BUILDER
25
+ ${
26
+ tip[key]
27
+ } [${dirname}.${name}](https://modernjs.dev/builder/zh/api/config-${dirname}.html#${dirname}-${name.toLowerCase()})。
28
+ :::
29
+
30
+ import Main from '@modern-js/builder-doc/${key}/config/${dirname}/${name}.md'
31
+
32
+ <Main />
33
+ `;
34
+ };
35
+
36
+ const hyphenateRE = /\B([A-Z]+)/g;
37
+ const hyphenate = function (str: string) {
38
+ return str.replace(hyphenateRE, '-$1').toLowerCase();
39
+ };
40
+
41
+ const configPath = 'configure/app';
42
+
43
+ export const gen = (
44
+ jsonMap: Record<string, { name: string; dirname: string }[]>,
45
+ ) => {
46
+ Object.keys(jsonMap).forEach(key => {
47
+ const cwd = process.cwd();
48
+ const baseDir = path.join(cwd, key, configPath);
49
+
50
+ const json = jsonMap[key as 'zh' | 'en'];
51
+ json.forEach(summary => {
52
+ const mdDir = path.join(baseDir, summary.dirname);
53
+ const mdPath = path.join(mdDir, `${hyphenate(summary.name)}.md`);
54
+ if (!fs.existsSync(mdDir)) {
55
+ fs.mkdirpSync(mdDir);
56
+ }
57
+ fs.writeFileSync(mdPath, createMarkdown(summary, key));
58
+ });
59
+ });
60
+ };
@@ -0,0 +1,36 @@
1
+ import fs from 'fs';
2
+ import path, { basename, dirname, extname } from 'path';
3
+ import { gen } from './gen-config';
4
+
5
+ const walk = (dir: string) => {
6
+ const fl: string[] = [];
7
+ fs.readdirSync(dir).forEach(ff => {
8
+ const fpath = path.join(dir, ff);
9
+ if (fs.statSync(fpath).isDirectory()) {
10
+ fl.push(...walk(fpath));
11
+ } else if (extname(fpath) === '.md') {
12
+ fl.push(fpath);
13
+ }
14
+ });
15
+ return fl;
16
+ };
17
+
18
+ const summary = (lng: string) => {
19
+ const fl = walk(
20
+ path.join(
21
+ process.cwd(),
22
+ `./node_modules/@modern-js/builder-doc/${lng}/config`,
23
+ ),
24
+ );
25
+ return fl.map(fpath => {
26
+ return {
27
+ name: basename(fpath).replace(extname(fpath), ''),
28
+ dirname: basename(dirname(fpath)),
29
+ };
30
+ });
31
+ };
32
+
33
+ gen({
34
+ zh: summary('zh'),
35
+ en: summary('en'),
36
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "@modern-js/tsconfig/base",
3
+ "compilerOptions": {
4
+ "jsx": "preserve"
5
+ },
6
+ "include": ["./src", "./navbar.js", "./sidebar.js", "./scripts"]
7
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "label": "命令",
3
+ "position": 3,
4
+ "link": {
5
+ "type": "doc",
6
+ "id": "apis/app/commands/index"
7
+ }
8
+ }
@@ -0,0 +1,44 @@
1
+ ---
2
+ sidebar_position: 5
3
+ ---
4
+
5
+ ```bash
6
+ Usage: modern build [options]
7
+
8
+ build application
9
+
10
+ Options:
11
+ -c --config <config> 指定配置文件路径,可以为相对路径或绝对路径
12
+ -h, --help 显示命令帮助
13
+ --analyze 分析构建产物体积,查看各个模块打包后的大小
14
+ ```
15
+
16
+ `modern build` 命令默认会在 `/dist` 目录下构建出可用于生产环境的产物。
17
+
18
+ 可以通过修改配置 [`output.distPath`](/docs/configure/app/output/dist-path) 指定产物的输出目录。
19
+
20
+ ## 分析构建产物体积
21
+
22
+ 执行 `npx modern build --analyze` 命令,可以在打包生产环境代码的同时,产出一个分析构建产物体积的 HTML 文件:
23
+
24
+ ```
25
+ Bundle Analyzer saved report to /example/dist/report.html
26
+ File sizes after production build:
27
+
28
+ 122.35 KB dist/static/js/885.1d4fbe5a.js
29
+ 2.3 KB dist/static/js/main.4b8e8d64.js
30
+ 761 B dist/static/js/runtime-main.edb7cf35.js
31
+ 645 B dist/static/css/main.0dd3ecc1.css
32
+ ```
33
+
34
+ 手动在浏览器中打开上述 HTML 文件,可以看到打包产物的瓦片图,并进行包体积分析和优化:
35
+
36
+ <img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/aphqeh7uhohpquloj/modern-js/mwa-build-analyze-8784f762c1ab0cb20935829d5f912c4c.png" />
37
+
38
+ > 该功能基于 [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer) 实现。
39
+
40
+ ## 命令行参数
41
+
42
+ import CommandTip from '@site/docs/components/command-tip.md'
43
+
44
+ <CommandTip />
@@ -0,0 +1,31 @@
1
+ ---
2
+ sidebar_position: 1
3
+ ---
4
+
5
+ # dev
6
+
7
+ ```bash
8
+ Usage: modern dev [options]
9
+
10
+ 本地开发命令
11
+
12
+ Options:
13
+ -e --entry <entry> 指定入口,编译特定的页面
14
+ -c --config <config> 指定配置文件路径,可以为相对路径或绝对路径
15
+ -h, --help 显示命令帮助
16
+ --analyze 分析构建产物体积,查看各个模块打包后的大小
17
+ --api-only 仅启动 API 接口服务
18
+ ```
19
+
20
+ `modern dev` 命令启动一个开发服务器,同时监听源文件变化,默认支持 React Fast Refresh:
21
+
22
+ ```bash
23
+ App running at:
24
+
25
+ > Local: http://localhost:8080/
26
+ > Network: http://192.168.0.1:8080/
27
+ ```
28
+
29
+ import CommandTip from '@site/docs/components/command-tip.md'
30
+
31
+ <CommandTip />
@@ -0,0 +1,12 @@
1
+ ---
2
+ type: ref
3
+ ---
4
+
5
+ # 命令
6
+
7
+ 本节涵盖了使用应用工程的所有命令。
8
+
9
+
10
+
11
+
12
+
@@ -0,0 +1,39 @@
1
+ ---
2
+ sidebar_position: 7
3
+ ---
4
+
5
+ ```
6
+ Usage: modern inspect [options]
7
+
8
+ inspect internal webpack config
9
+
10
+ Options:
11
+ --env <env> 查看指定环境下的配置 (default: "development")
12
+ --output <output> 指定在 dist 目录下输出的路径 (default: "/")
13
+ --no-console 不在终端中输出完整结果
14
+ --verbose 在结果中展示函数的完整内容
15
+ -c --config <config> 指定配置文件路径,可以为相对路径或绝对路径
16
+ -h, --help 显示命令帮助
17
+ ```
18
+
19
+ `modern inspect` 命令,用于查看项目的 webpack 完整配置。
20
+
21
+ 在项目根目录下执行命令 `npx modern inspect`,会将 webpack 配置输出在终端界面,同时也会在项目的 `dist` 目录生成一份 `webpack.client.inspect.js` 文件,开发者可手动打开查看。
22
+
23
+ ## 指定环境
24
+
25
+ 默认情况下,会输出开发环境的 webpack 配置,可以使用 `env` 选项来输出生产环境的配置:
26
+
27
+ ```bash
28
+ modern inspect --env production
29
+ ```
30
+
31
+ ## 配置类型
32
+
33
+ ### SSR 配置
34
+
35
+ 如果项目开启了 SSR 能力,则在 `dist` 目录会另外生成一份 `webpack.ssr.inspect.js` 文件,对应 SSR 构建时的 webpack 配置。
36
+
37
+ ### Modern 配置
38
+
39
+ 如果项目开启了 [enableModernMode](/docs/configure/app/output/enable-modern-mode) 选项,则在 `dist` 目录会另外生成一份 `webpack.modern.inspect.js` 文件,对应现代浏览器的 webpack 配置。
@@ -0,0 +1,22 @@
1
+ ---
2
+ sidebar_position: 4
3
+ title: lint
4
+ ---
5
+
6
+ ```bash
7
+ Usage: modern lint [options] [...files]
8
+
9
+ lint and fix source files
10
+
11
+ Options:
12
+ --no-fix disable auto fix source file
13
+ -h, --help display help for command
14
+ ```
15
+
16
+ 运行 `ESLint` 检查代码语法情况, 通长情况下,我们只需要在 `git commit` 阶段通过 `lint-staged` 检查本次提交修改的部分代码。
17
+
18
+ * `--no-fix` 参数设置后可以关闭自动修复 lint 错误代码的能力。
19
+
20
+ import CommandTip from '@site/docs/components/command-tip.md'
21
+
22
+ <CommandTip />
@@ -0,0 +1,59 @@
1
+ ---
2
+ sidebar_position: 2
3
+ ---
4
+
5
+ ```bash
6
+ Usage: modern new [options]
7
+
8
+ 应用工程中执行生成器
9
+
10
+ Options:
11
+ -d, --debug 开启 Debug 模式,打印调试日志信息 (default: false)
12
+ -c, --config <config> 生成器运行默认配置(JSON 字符串)
13
+ --dist-tag <tag> 生成器使用特殊的 npm Tag 版本
14
+ --registry 生成器运行过程中定制 npm Registry
15
+ -h, --help 显示命令帮助
16
+ ```
17
+
18
+ `modern new` 命令用于在已有项目中添加项目元素。
19
+
20
+ 比如添加应用入口、启用启用一些可选功能如 Tailwind CSS、微前端开发模式等。
21
+
22
+ import CommandTip from '@site/docs/components/command-tip.md'
23
+
24
+ <CommandTip />
25
+
26
+ ### 添加入口
27
+
28
+ 在应用工程中,执行 `new` 命令添加入口如下:
29
+
30
+ ```bash
31
+ $ npx modern new
32
+ ? 请选择你想要的操作 创建工程元素
33
+ ? 创建工程元素 新建「应用入口」
34
+ ? 请填写入口名称 entry
35
+ ? 是否需要调整默认配置? 否
36
+ ```
37
+
38
+ ### 启用启用可选功能
39
+
40
+ 在应用工程中,执行 `new` 命令启用可选能力如下:
41
+
42
+ ```bash
43
+ $ npx modern new
44
+ ? 请选择你想要的操作 启用可选功能
45
+ ? 启用可选功能 (Use arrow keys)
46
+ ❯ 启用 Tailwind CSS 支持
47
+ 启用 Less 支持
48
+ 启用 Sass 支持
49
+ 启用「BFF」功能
50
+ 启用「微前端」模式
51
+ 启用「单元测试 / 集成测试」功能
52
+ 启用「Visual Testing (Storybook)」模式
53
+ ```
54
+
55
+ :::caution 注意
56
+ `--config` 参数对应参数值需要使用 JSON 字符串。
57
+
58
+ pnpm 暂不支持使用 JSON 字符串作为参数值,可使用 `npm new` 开启相关功能。【[相关 Issue](https://github.com/pnpm/pnpm/issues/3876)】
59
+ :::
@@ -0,0 +1,32 @@
1
+ ---
2
+ sidebar_position: 6
3
+ ---
4
+
5
+ ```bash
6
+ Usage: modern start [options]
7
+
8
+ start server
9
+
10
+ Options:
11
+ -c --config <config> 指定配置文件路径,可以为相对路径或绝对路径
12
+ -h, --help 显示命令帮助
13
+ --api-only 仅启动 API 接口服务
14
+ ```
15
+
16
+ 通常使用 `modern start` 命令在生产环境下启用应用工程, 需要提前执行 [`build`](/docs/apis/app/commands/build) 命令构建出对应产物。
17
+
18
+ 默认情况下,应用将会在 `localhost:8080` 启动,可以通过 `server.port` 修改 Server 端口号:
19
+
20
+ ```js
21
+ export default defineConfig({
22
+ server: {
23
+ port: 8081,
24
+ }
25
+ })
26
+ ```
27
+
28
+ import CommandTip from '@site/docs/components/command-tip.md'
29
+
30
+ <CommandTip />
31
+
32
+
@@ -0,0 +1,36 @@
1
+ ---
2
+ sidebar_position: 3
3
+ ---
4
+
5
+ ```bash
6
+ Usage: modern test [options]
7
+
8
+ Options:
9
+ -h, --help 显示命令帮助
10
+ ```
11
+
12
+ :::caution 注意
13
+ `modern test` 命令需要先通过 [`new`](/docs/apis/app/commands/new) 命令启用「单元测试 / 集成测试」功能
14
+ :::
15
+
16
+ `modern test` 命令会自动运行项目下的测试用例,效果如下:
17
+
18
+ ```bash
19
+ $ npx modern test
20
+ PASS src/tests/index.test.ts
21
+ The add method
22
+ ✓ should work fine. (2ms)
23
+
24
+ Test Suites: 1 passed, 1 total
25
+ Tests: 1 passed, 1 total
26
+ Snapshots: 0 total
27
+ Time: 0.994 s, estimated 1 s
28
+ ```
29
+
30
+ :::info 注
31
+ `src` 和 `api` 目录下面 `*.test.(js|ts)` 都会默认识别为测试用例。
32
+ :::
33
+
34
+ import CommandTip from '@site/docs/components/command-tip.md'
35
+
36
+ <CommandTip />
@@ -0,0 +1,23 @@
1
+ ---
2
+ sidebar_position: 8
3
+ ---
4
+
5
+ ```
6
+ Usage: modern upgrade [options]
7
+
8
+ 升级 Modern.js 到最新版本
9
+
10
+ Options:
11
+ --registry <registry> 定制 npm registry (default: "")
12
+ -d,--debug 开启 Debug 模式,打印调试日志信息 (default: false)
13
+ --cwd <cwd> 项目路径 (default: "")
14
+ -h, --help display help for command
15
+ ```
16
+
17
+ `modern upgrade` 命令,用于升级项目 Modern.js 相关依赖至最新版本。
18
+
19
+ 在项目根目录下执行命令 `npx modern upgrade`,会默认将当前执行命令项目的 `package.json` 中的 Modern.js 相关依赖更新至最新版本。
20
+
21
+ :::info
22
+ 命令在 `@modern-js/app-tools` 版本 >= 1.17.0 提供,之前版本可使用 `npx @modern-js/upgrade` 进行升级。
23
+ :::
@@ -0,0 +1,8 @@
1
+ {
2
+ "label": "文件约定",
3
+ "position": 1,
4
+ "link": {
5
+ "type": "doc",
6
+ "id": "apis/app/hooks/index"
7
+ }
8
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "label": "api/",
3
+ "position": 2
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "label": "框架写法",
3
+ "position": 2
4
+ }