@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,239 @@
1
+ ---
2
+ sidebar_position: 6
3
+ ---
4
+
5
+ # 自定义 Changelog 生成
6
+
7
+ Changesets 默认会使用 `@changesets/cli/changelog` 生成 Changelog 信息,如果默认的 Changelog 信息不能满足需求,可以自定义 Changelog 的生成。
8
+
9
+ ## 自定义 Changlog 内容
10
+
11
+ Changelog 信息主要包含以下两种信息:
12
+
13
+ - changeset 中写入的 Changelog 信息。
14
+
15
+ - 本次版本升级关联包的版本变更信息。
16
+
17
+ 自定义逻辑主要实现两个函数,`getReleaseLine` 和 `getDependencyReleaseLine`,分别用来定义上述这两种信息。
18
+
19
+ ### getReleaseLine
20
+
21
+ #### Params
22
+
23
+ - changeset
24
+
25
+ ```typescript
26
+ export type VersionType = "major" | "minor" | "patch" | "none";
27
+
28
+ export type Release = { name: string; type: VersionType };
29
+
30
+ export type Changeset = {
31
+ id: string; // changeset 的文件名称
32
+ commit?: string; // changeset 提交时的 commit id 信息
33
+ summary: string; // changeset 内容信息
34
+ releases: Array<Release>; // 当前计算出的 changeset 升级包名称及类型信息
35
+ };
36
+ ```
37
+
38
+ - type
39
+
40
+ 当前包对应的升级版本类型,类型为上述 `VersionType`。
41
+
42
+ #### 返回值
43
+
44
+ Changelog 内容。
45
+
46
+ #### 默认实现
47
+
48
+ `@changesets/cli/changelog` 默认处理逻辑为将 `summary` 信息按照换行符 `\n` 分割,第一样前面增加 `-` 作为列表开头,其他内容作为第一行内容的补充整理在列表下方。
49
+
50
+ ```typescript
51
+ async function getReleaseLine(changeset, type) {
52
+ const [firstLine, ...futureLines] = changeset.summary
53
+ .split('\n')
54
+ .map(l => l.trimRight());
55
+
56
+ let returnVal = `- ${
57
+ changeset.commit ? `${changeset.commit}: ` : ''
58
+ }${firstLine}`;
59
+
60
+ if (futureLines.length > 0) {
61
+ returnVal += `\n${futureLines.map(l => ` ${l}`).join('\n')}`;
62
+ }
63
+
64
+ return returnVal;
65
+ }
66
+ ```
67
+
68
+ ### getDependencyReleaseLine
69
+
70
+ #### Params
71
+
72
+ - changesets
73
+
74
+ 当前关联的所有 changeset 信息,类型为 `getReleaseLine` changeset 类型数组。
75
+
76
+ - dependenciesUpdated
77
+
78
+ ```typescript
79
+ type ModCompWithPackage = {
80
+ name: string; // 依赖模块名称
81
+ type: VersionType; // 依赖模块的升级类型
82
+ oldVersion: string; // 依赖模块当前版本号
83
+ newVersion: string; // 依赖模块新版本号
84
+ changesets: string[]; // 关联的 changeset id 列表
85
+ packageJson: PackageJSON; // 依赖模块完整的 package.json 内容
86
+ dir: string; // 依赖模块的路径(绝对路径)
87
+ };
88
+
89
+ type DependenciesUpdated = ModCompWithPackage[]
90
+ ```
91
+
92
+ #### 返回值
93
+
94
+ Changelog 内容。
95
+
96
+ #### 默认实现
97
+
98
+ `@changesets/cli/changelog` 默认会使用 changesets 信息展示对应的 `Updated dependencies + commit id`,以列表形式展示。然后根据 `dependenciesUpdated` 信息展示对应的依赖包包名和新版本号,作为列表的子列表项。
99
+
100
+ ```typescript
101
+ async function getDependencyReleaseLine(changesets, dependenciesUpdated) {
102
+ console.log("getDependencyReleaseLine", changesets, dependenciesUpdated)
103
+ if (dependenciesUpdated.length === 0) return "";
104
+
105
+ const changesetLinks = changesets.map(
106
+ changeset =>
107
+ `- Updated dependencies${
108
+ changeset.commit ? ` [${changeset.commit}]` : ""
109
+ }`
110
+ );
111
+
112
+ const updatedDepenenciesList = dependenciesUpdated.map(
113
+ dependency => ` - ${dependency.name}@${dependency.newVersion}`
114
+ );
115
+
116
+ return [...changesetLinks, ...updatedDepenenciesList].join("\n");
117
+ }
118
+ ```
119
+
120
+ 展示效果为:
121
+
122
+ ```markdown
123
+ - Updated dependencies [f0438ab]
124
+ - Updated dependencies [f0438ab]
125
+ - module-3@2.0.0
126
+ - module-1@0.2.0
127
+ ```
128
+
129
+ ## 配置
130
+
131
+ Changesets 配置文件中 `changelog` 字段,该字段用于标记 Changelog 信息的获取途径。
132
+
133
+ 该配置可以为字符串,直接声明获取 Changelog 信息模块的模块名称或者路径。
134
+
135
+ 该配置还支持配置数组,数组中第一个元素为获取 Changelog 信息模块的模块名称或者路径,第二个元素为传入对应函数的参数值,会作为 `getReleaseLine` 和 `getDependencyReleaseLine` 函数的第三个参数传入。
136
+
137
+ ### 配置相对路径
138
+
139
+ changelog 配置如果为相对路径为 `.changesets` 目录下的相对路径。
140
+
141
+ 例如创建 `.changeset/my-changelog-config.js` 文件,定义如下内容:
142
+
143
+ ```typescript title=".changeset/my-changelog-config.js"
144
+ async function getReleaseLine(changeset, type) {}
145
+
146
+ async function getDependencyReleaseLine(changesets, dependenciesUpdated) {}
147
+
148
+ module.exports = {
149
+ getReleaseLine,
150
+ getDependencyReleaseLine,
151
+ };
152
+
153
+ ```
154
+
155
+ `changlog` 配置为 `./my-changelog-config.js` 即可:
156
+
157
+ ```json title=".changesets/config.json"
158
+ {
159
+ "changelog": "./my-changelog-config.js",
160
+ ...
161
+ }
162
+ ```
163
+
164
+ ### 使用模块工程方案
165
+
166
+ 自定义 Changelog 还可以使用模块工程方案进行管理,提供通用方案。
167
+
168
+ #### 使用 `npx @modern-js/create` 创建模块工程方案。
169
+
170
+ ``` md
171
+ ? 请选择你想创建的工程类型 模块
172
+ ? 请填写项目名称 custom-changelog
173
+ ? 请选择开发语言 TS
174
+ ? 请选择包管理工具 pnpm
175
+ ```
176
+
177
+ #### 实现自定义内容。
178
+
179
+ ```typescript title="src/index.ts"
180
+ export async function getReleaseLine() {}
181
+
182
+ export async function getDependencyReleaseLine() {}
183
+ ```
184
+
185
+ #### 将模块发布到 NPM。
186
+
187
+ #### 在目标仓库根目录安装对应模块,例如 `custom-changelog`。
188
+
189
+ #### 配置 changeset 的 changelog 配置为包名称。
190
+
191
+ ```json title=".changesets/config.json"
192
+ {
193
+ "changelog": "custom-changelog",
194
+ ...
195
+ }
196
+ ```
197
+
198
+ ### 使用 Monorepo 工程方案
199
+
200
+ 如果你当前仓库为 Monorepo 工程方案,可以直接使用模块子项目进行管理。
201
+
202
+ #### 执行 `pnpm run new` 创建模块子项目。
203
+
204
+ ``` md
205
+ ? 请选择你想创建的工程类型 模块
206
+ ? 请填写子项目名称 custom-changelog
207
+ ? 请填写子项目目录名称 custom-changelog
208
+ ? 请选择开发语言 TS
209
+ ```
210
+
211
+ #### 实现自定义内容。
212
+
213
+ ```typescript title="src/index.ts"
214
+ export async function getReleaseLine() {}
215
+
216
+ export async function getDependencyReleaseLine() {}
217
+ ```
218
+
219
+ #### 在 Monorepo 根目录添加子项目模块依赖,例如 `custom-changelog`。
220
+
221
+ ```json title="package.json"
222
+ {
223
+ "devDependencies": {
224
+ "custom-changelog": "workspace: *",
225
+ ...
226
+ }
227
+ }
228
+ ```
229
+
230
+ #### 配置 changeset 的 changelog 配置为包名称。
231
+
232
+ ```json title=".changesets/config.json"
233
+ {
234
+ "changelog": "custom-changelog",
235
+ ...
236
+ }
237
+ ```
238
+
239
+ 该模块发布到 NPM 后,依然可以和模块类型一样供其他仓库使用。
@@ -0,0 +1,272 @@
1
+ ---
2
+ sidebar_position: 7
3
+ ---
4
+
5
+ # 自定义提交 commit 信息
6
+
7
+ Changesets 支持配置 `commit` 为 true 时,在执行 `change` 和 `bump` 命令时自动提交当前变更。
8
+
9
+ 默认的 `commit` 信息由 `@changesets/cli/commit` 提供,默认信息格式为:
10
+
11
+ ![change commit](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-change-commit-info.png)
12
+ ![bump commit](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-bump-commit-info.png)
13
+
14
+ 当默认的 commit 信息不能满足需求时,支持自定义 commit 信息。
15
+
16
+ ## 自定义 commit 信息内容
17
+
18
+ commit 信息分为两种:
19
+ - 执行 `change` 命令时自动生成的 commit 信息。
20
+ - 执行 `bump` 命令时自动生成的 commit 信息。
21
+
22
+ 自定义逻辑主要实现两个函数,`getAddMessage` 和 `getVersionMessage`,分别用来定义上述这两种信息。
23
+
24
+ ### getAddMessage
25
+
26
+ #### Params
27
+
28
+ - changeset
29
+
30
+ 当前创建的 chagneset 信息
31
+
32
+ ```typescript
33
+ type Release = {
34
+ name: string;
35
+ type: VersionType;
36
+ };
37
+
38
+ type Changeset = {
39
+ summary: string;
40
+ releases: Array<Release>;
41
+ };
42
+ ```
43
+
44
+ - options
45
+
46
+ 配置 commit 时的配置信息。
47
+
48
+ > commit 配置为数组时,第二个参数支持传入默认的配置信息,会对应的使用该参数传递。
49
+
50
+ #### 返回值
51
+
52
+ commit 信息内容。
53
+
54
+ #### 默认实现
55
+
56
+ `@changesets/cli/commit` 默认处理逻辑为以 `docs(changeset):` 开头,commit 信息为 changeset 的 `summary`,并根据传入的 `skipCI` 参数配置添加 [skip ci] 信息。
57
+
58
+ ```typescript
59
+ type SkipCI = boolean | "add" | "version";
60
+
61
+ const getAddMessage = async (
62
+ changeset: Changeset,
63
+ options: { skipCI?: SkipCI } | null
64
+ ) => {
65
+ const skipCI = options?.skipCI === "add" || options?.skipCI === true;
66
+ return outdent`docs(changeset): ${changeset.summary}${
67
+ skipCI ? `\n\n[skip ci]\n` : ""
68
+ }`;
69
+ };
70
+ ```
71
+
72
+ > [outdent](https://www.npmjs.com/package/outdent) 目的是删除模板字符串开头的空格内容,使 commit 信息更符合规范。
73
+
74
+ ### getVersionMessage
75
+
76
+ #### Params
77
+
78
+ - releasePlan
79
+
80
+ ```typescript
81
+ type VersionType = "major" | "minor" | "patch" | "none";
82
+
83
+ type Release = {
84
+ name: string;
85
+ type: VersionType;
86
+ };
87
+
88
+ type Changeset = {
89
+ id: string;
90
+ summary: string;
91
+ releases: Array<Release>;
92
+ };
93
+
94
+ type ComprehensiveRelease = {
95
+ name: string;
96
+ type: VersionType;
97
+ oldVersion: string;
98
+ newVersion: string;
99
+ changesets: string[];
100
+ };
101
+
102
+ type PreState = {
103
+ mode: "pre" | "exit"; // pre 模式当前状态
104
+ tag: string; // pre 的类型
105
+ initialVersions: {
106
+ [pkgName: string]: string; // 版本升级前包名及版本号信息,Map 格式
107
+ };
108
+ changesets: string[]; // 本次升级的 changeset id 列表
109
+ };
110
+
111
+ type ReleasePlan = {
112
+ changesets: Changeset[]; // 本次升级的 changeset 列表
113
+ releases: ComprehensiveRelease[]; // 当前升级的包信息,包含包名称、当前版本、升级后版本、升级类型等
114
+ preState: PreState | undefined; // 当前如果为 pre 发布,提供相关状态信息
115
+ };
116
+ ```
117
+
118
+ - options
119
+
120
+ 配置 commit 时的配置信息。
121
+
122
+ > commit 配置为数组时,第二个参数支持传入默认的配置信息,会对应的使用该参数传递。
123
+
124
+ #### 返回值
125
+
126
+ commit 信息内容。
127
+
128
+ #### 默认实现
129
+
130
+ `@changesets/cli/commit` 默认处理逻辑为:先展示当前需要 release 的包数量,再展示 release 包的名称及新版本号,并根据传入的 `skipCI` 参数配置添加 [skip ci] 信息。
131
+
132
+ ```typescript
133
+ const getVersionMessage = async (
134
+ releasePlan: ReleasePlan,
135
+ options: { skipCI?: SkipCI } | null
136
+ ) => {
137
+ const skipCI = options?.skipCI === "version" || options?.skipCI === true;
138
+ const publishableReleases = releasePlan.releases.filter(
139
+ release => release.type !== "none"
140
+ );
141
+ const numPackagesReleased = publishableReleases.length;
142
+
143
+ const releasesLines = publishableReleases
144
+ .map(release => ` ${release.name}@${release.newVersion}`)
145
+ .join("\n");
146
+
147
+ return outdent`
148
+ RELEASING: Releasing ${numPackagesReleased} package(s)
149
+
150
+ Releases:
151
+ ${releasesLines}
152
+ ${skipCI ? `\n[skip ci]\n` : ""}
153
+ `;
154
+ };
155
+ ```
156
+
157
+ ## 配置
158
+
159
+ Changesets 配置文件中 `commit` 字段,该字段用于标记是否需要在 `change` 和 `bump` 命令是提交 commit 信息及 commit 信息的获取途径。
160
+
161
+ 该配置可以为 `boolean`,为 true 时使用默认 `@changesets/cli/commit` 格式化 commit 信息。
162
+
163
+ 该配置可以为字符串,直接声明获取 commit 信息模块的模块名称或者路径。
164
+
165
+ 该配置还支持配置数组,数组中第一个元素为获取 commit 信息模块的模块名称或者路径,第二个元素为传入对应函数的参数值,会作为 `getAddMessage` 和 `getVersionMessage` 函数的第二个参数传入。
166
+
167
+
168
+ ### 配置相对路径
169
+
170
+ commit 配置如果为相对路径为 `.changesets` 目录下的相对路径。
171
+
172
+ 例如创建 .changeset/my-commit-config.js 文件,定义如下内容:
173
+
174
+ ```javascript title=".changeset/my-commit-config.js"
175
+ async function getAddMessage(changeset, options) {}
176
+
177
+ async function getVersionMessage(releasePlan, options) {}
178
+
179
+ module.exports = {
180
+ getAddMessage,
181
+ getVersionMessage,
182
+ };
183
+ ```
184
+
185
+ commit 配置为 ./my-commit-config.js 即可:
186
+
187
+ ```json title=".changesets/config.json"
188
+ {
189
+ "changelog": "./my-commit-config.js",
190
+ ...
191
+ }
192
+ ```
193
+
194
+ ### 使用模块工程方案
195
+
196
+ 自定义 commit 还可以使用模块工程方案进行管理,提供通用方案。
197
+
198
+ 自定义 Changelog 还可以使用模块工程方案进行管理,提供通用方案。
199
+
200
+ #### 使用 `npx @modern-js/create` 创建模块工程方案。
201
+
202
+ ``` md
203
+ ? 请选择你想创建的工程类型 模块
204
+ ? 请填写项目名称 custom-commit
205
+ ? 请选择开发语言 TS
206
+ ? 请选择包管理工具 pnpm
207
+ ```
208
+
209
+ #### 实现自定义内容。
210
+
211
+ ```typescript title="src/index.ts"
212
+ export async function getAddMessage() {}
213
+
214
+ export async function getVersionMessage() {}
215
+
216
+ ```
217
+
218
+ #### 将模块发布到 NPM。
219
+
220
+ #### 在目标仓库根目录安装对应模块,例如 custom-commit。
221
+ #### 配置 changeset 的 commit 配置为包名称。
222
+
223
+ ```json title="package.json"
224
+ {
225
+ "changelog": "custom-commit",
226
+ ...
227
+ }
228
+ ```
229
+
230
+ ### 使用 Monorepo 工程方案
231
+
232
+ 如果你当前仓库为 Monorepo 工程方案,可以直接使用模块子项目进行管理。
233
+
234
+ #### 执行 `pnpm run new` 创建模块子项目。
235
+
236
+ ``` md
237
+ ? 请选择你想创建的工程类型 模块
238
+ ? 请填写子项目名称 custom-commit
239
+ ? 请填写子项目目录名称 custom-commit
240
+ ? 请选择开发语言 TS
241
+ ```
242
+
243
+ #### 实现自定义内容。
244
+
245
+ ```typescript title="src/index.ts"
246
+ export async function getAddMessage() {}
247
+
248
+ export async function getVersionMessage() {}
249
+
250
+ ```
251
+
252
+ #### 在 Monorepo 根目录添加子项目模块依赖,例如 custom-commit。
253
+
254
+ ```json title="package.json"
255
+ {
256
+ "devDependencies": {
257
+ "custom-commit": "workspace: *",
258
+ ...
259
+ }
260
+ }
261
+ ```
262
+
263
+ #### 配置 changeset 的 commit 配置为包名称。
264
+
265
+ ```json title=".changesets/config.json"
266
+ {
267
+ "commit": "custom-commit",
268
+ ...
269
+ }
270
+ ```
271
+
272
+ 该模块发布到 NPM 后,依然可以和模块类型一样供其他仓库使用。
@@ -0,0 +1,146 @@
1
+ ---
2
+ sidebar_position: 5
3
+ ---
4
+
5
+ # Changesets 配置文件
6
+
7
+ 我们前面了解到,初始化 Modern.js 仓库时,会默认初始化 Changesets 的配置文件,即 `.changeset/config.json` 文件,下面我们将详细了解一下该文件中支持哪些配置。
8
+
9
+ ## 配置介绍
10
+
11
+ ### commit
12
+
13
+ 类型: `boolean`
14
+
15
+ 默认值: `false`
16
+
17
+ 当配置该字段为 `true` 时,在执行 `change` 和 `bump` 命令时,将自动执行提交代码操作。
18
+
19
+ 默认的 commit 信息格式如下:
20
+
21
+ ![change commit](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-change-commit-info.png)
22
+ ![bump commit](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-bump-commit-info.png)
23
+
24
+ 该 commit 信息支持自定义,我们将在[自定义提交 commit 信息](/docs/guides/topic-detail/changesets/commit)章节进行详细介绍。
25
+
26
+ ### access
27
+
28
+ 类型:`restricted` | `public`
29
+
30
+ 默认值:`restricted`
31
+
32
+ 用于配置当前包的发布形式,如果配置为 `restricted`,将作为私有包发布,如果为 `public`,则发布公共范围包。
33
+
34
+ 对于仓库中存在部分包需要配置 access,可以在 `package.json` 中配置 `publishConfig`,例如:
35
+
36
+ ```json title=package.json
37
+ {
38
+ "publishConfig": {
39
+ "registry": "https://registry.npmjs.org/",
40
+ "access": "public"
41
+ }
42
+ }
43
+ ```
44
+
45
+ 对于不需要发布的包,可以在 `package.json` 中设置 `private` 为 `true`,阻止其进行发布。
46
+
47
+ ### baseBranch
48
+
49
+ 类型: `string`
50
+
51
+ 默认值: `main`
52
+
53
+ 仓库主分支。该配置用于计算当前分支的变更包并进行分类。
54
+
55
+ ### ignore
56
+
57
+ 类型:`string[]`
58
+
59
+ 默认值:`[]`
60
+
61
+ 用于声明执行 `bump` 命令时忽略的包,和 `bump` 命令的 `--ignore` 参数用法一致,注意两者不能同时使用。
62
+
63
+ ### fixed
64
+
65
+ 类型: `string[][]`
66
+
67
+ 默认值:`[]`
68
+
69
+ 用于 monorepo 中对包进行分组,相同分组中的包版本号将进行绑定,每次执行 `bump` 命令时,同一分组中的包只要有一个升级版本号,其他会一起升级。
70
+ 支持使用正则匹配包名称。
71
+
72
+ ### linked
73
+
74
+ 类型: `string[][]`
75
+
76
+ 默认值:`[]`
77
+
78
+ 和 `fixed` 类似,也是对 monorepo 中对包进行分组,但是每次执行 `bump` 命令时,只有和 changeset 声明的变更相关的包才会升级版本号,同一分组的变更包的版本号将保持一致。
79
+ 支持使用正则匹配包名称。
80
+
81
+ ### updateInternalDependencies
82
+
83
+ 类型:`patch` | `minor`
84
+
85
+ 默认值:`patch`
86
+
87
+ 用于声明更新内部依赖的版本号规则。
88
+
89
+ 当执行 `bump` 命令升级版本号时,默认会自动更新仓库中使用该包的依赖声明。配置该字段为 `minor` 后,如果升级版本号为 `patch` 类型,将不会自动更新引用依赖声明。
90
+
91
+ 例如:
92
+ ```
93
+ pkg-a @ version 1.0.0
94
+ pkg-b @ version 1.0.0
95
+ depends on pkg-a at range `^1.0.0
96
+ ```
97
+
98
+ 默认情况下,升级 `pkg-a` 至 `1.0.1` 时,会更新 `pkg-b` 中的 `pkg-a` 的依赖版本为 `^1.0.1`。
99
+
100
+ 当配置 `updateInternalDependencies` 为 `minor` 时,升级 `pkg-a` 至 `1.0.1` 时,`pkg-b` 中的 `pkg-a` 的依赖版本将不会更新,只有 `pkg-a` 升级版本号为 `1.1.0` 或者 `2.0.0` 时,才会更新 `pkg-b` 中的 `pkg-a` 的依赖。
101
+
102
+ ### changelog
103
+
104
+ 类型:`boolean` | `string` | `[string, unknow]`
105
+
106
+ 默认值:`@changesets/cli/changelog`
107
+
108
+ 生成 Changelog 规则。
109
+
110
+ 配置为 `false` 时,执行 bump 命令时,在 `CHANGELOG.md` 文件中只声明版本号,不声明其他 Changelog 信息。
111
+
112
+ ![关闭 changelog 配置](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/changeset-empty-changelog.png)
113
+
114
+ 配置为 `@changesets/cli/changelog` 将使用官方提供的 Changlog 生成规则,将 changeset 信息转换为 Changlog 内容。
115
+
116
+ 配置为数组时,第一个参数为自定义 NPM 包或者路径,第二个参数为需要传入的默认参数配置,自定义格式我们将在后续[自定义 Changelog](/docs/guides/topic-detail/changesets/changelog) 章节讲解。
117
+
118
+ ### ___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH
119
+
120
+ 一些实验性配置。
121
+
122
+ #### onlyUpdatePeerDependentsWhenOutOfRange
123
+
124
+ 类型:`boolean`
125
+
126
+ 默认值:`false`
127
+
128
+ 针对于 `peerDependence` 依赖的升级策略配置,默认针对 `peerDependence` 在 `minor` 和 `major` 版本升级时,当前包会升级大版本。
129
+
130
+ 该配置设置为 true 时,仅当 `peerDependence` 声明包依赖超出声明范围时才更新版本。
131
+
132
+ #### updateInternalDependents
133
+
134
+ 类型: `always` | `out-of-range`
135
+
136
+ 默认值:`always`
137
+
138
+ 当执行 `bump` 命令升级版本号时,默认会自动更新仓库中使用该包的依赖声明。当设置该参数为 `out-of-range` 时,只有当依赖声明超出范围时才会更新仓库中使用该包的依赖声明。
139
+
140
+ #### useCalculatedVersionForSnapshots
141
+
142
+ 类型:`boolean`
143
+
144
+ 默认值:`false`
145
+
146
+ 使用快照发布时,默认会使用 `0.0.0-timestamp` 的版本格式,保证用户可以正常使用预发布版本。当你需要忽略上述问题,使用正常的版本号格式时,即当前版本为 `1.0.1` 快照版本期望使用`1.0.1-timestamp`,可配置该参数为 `true`。