@modern-js/main-doc 2.0.0-beta.2 → 2.0.0-beta.4

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 (345) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/en/docusaurus-plugin-content-docs/current/apis/app/commands/inspect.md +0 -4
  3. package/en/docusaurus-plugin-content-docs/current/apis/app/commands/new.md +0 -2
  4. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/bootstrap.md +17 -3
  5. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/create-app.md +1 -1
  6. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-store.md +0 -22
  7. package/en/docusaurus-plugin-content-docs/current/components/init-app.md +42 -0
  8. package/en/docusaurus-plugin-content-docs/current/components/reduck-migration.md +1 -0
  9. package/en/docusaurus-plugin-content-docs/current/configure/app/dev/asset-prefix.md +1 -1
  10. package/en/docusaurus-plugin-content-docs/current/configure/app/dev/hmr.md +1 -1
  11. package/en/docusaurus-plugin-content-docs/current/configure/app/dev/https.md +1 -1
  12. package/en/docusaurus-plugin-content-docs/current/configure/app/dev/port.md +1 -1
  13. package/en/docusaurus-plugin-content-docs/current/configure/app/dev/progress-bar.md +1 -1
  14. package/en/docusaurus-plugin-content-docs/current/configure/app/dev/start-url.md +1 -1
  15. package/en/docusaurus-plugin-content-docs/current/configure/app/experiments/lazy-compilation.md +1 -1
  16. package/en/docusaurus-plugin-content-docs/current/configure/app/html/app-icon.md +1 -1
  17. package/en/docusaurus-plugin-content-docs/current/configure/app/html/crossorigin.md +1 -1
  18. package/en/docusaurus-plugin-content-docs/current/configure/app/html/disable-html-folder.md +1 -1
  19. package/en/docusaurus-plugin-content-docs/current/configure/app/html/favicon-by-entries.md +1 -1
  20. package/en/docusaurus-plugin-content-docs/current/configure/app/html/favicon.md +1 -1
  21. package/en/docusaurus-plugin-content-docs/current/configure/app/html/inject-by-entries.md +1 -1
  22. package/en/docusaurus-plugin-content-docs/current/configure/app/html/inject.md +1 -1
  23. package/en/docusaurus-plugin-content-docs/current/configure/app/html/meta-by-entries.md +1 -1
  24. package/en/docusaurus-plugin-content-docs/current/configure/app/html/meta.md +1 -1
  25. package/en/docusaurus-plugin-content-docs/current/configure/app/html/mount-id.md +1 -1
  26. package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-by-entries.md +1 -1
  27. package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-parameters-by-entries.md +1 -1
  28. package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-parameters.md +1 -1
  29. package/en/docusaurus-plugin-content-docs/current/configure/app/html/template.md +1 -1
  30. package/en/docusaurus-plugin-content-docs/current/configure/app/html/title-by-entries.md +1 -1
  31. package/en/docusaurus-plugin-content-docs/current/configure/app/html/title.md +1 -1
  32. package/en/docusaurus-plugin-content-docs/current/configure/app/output/asset-prefix.md +1 -1
  33. package/en/docusaurus-plugin-content-docs/current/configure/app/output/assets-retry.md +1 -1
  34. package/en/docusaurus-plugin-content-docs/current/configure/app/output/charset.md +1 -1
  35. package/en/docusaurus-plugin-content-docs/current/configure/app/output/clean-dist-path.md +1 -1
  36. package/en/docusaurus-plugin-content-docs/current/configure/app/output/convert-to-rem.md +1 -1
  37. package/en/docusaurus-plugin-content-docs/current/configure/app/output/copy.md +1 -1
  38. package/en/docusaurus-plugin-content-docs/current/configure/app/output/css-module-local-ident-name.md +1 -1
  39. package/en/docusaurus-plugin-content-docs/current/configure/app/output/data-uri-limit.md +1 -1
  40. package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-css-extract.md +1 -1
  41. package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-css-module-extension.md +1 -1
  42. package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-filename-hash.md +1 -1
  43. package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-inline-runtime-chunk.md +1 -1
  44. package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-minimize.md +1 -1
  45. package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-source-map.md +1 -1
  46. package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-ts-checker.md +1 -1
  47. package/en/docusaurus-plugin-content-docs/current/configure/app/output/dist-path.md +1 -1
  48. package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-asset-fallback.md +1 -1
  49. package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-asset-manifest.md +1 -1
  50. package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-css-module-tsdeclaration.md +1 -1
  51. package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-inline-scripts.md +1 -1
  52. package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-inline-styles.md +1 -1
  53. package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-latest-decorators.md +1 -1
  54. package/en/docusaurus-plugin-content-docs/current/configure/app/output/externals.md +1 -1
  55. package/en/docusaurus-plugin-content-docs/current/configure/app/output/filename.md +1 -1
  56. package/en/docusaurus-plugin-content-docs/current/configure/app/output/legal-comments.md +1 -1
  57. package/en/docusaurus-plugin-content-docs/current/configure/app/output/override-browserslist.md +1 -1
  58. package/en/docusaurus-plugin-content-docs/current/configure/app/output/polyfill.md +1 -1
  59. package/en/docusaurus-plugin-content-docs/current/configure/app/output/svg-default-export.md +1 -1
  60. package/en/docusaurus-plugin-content-docs/current/configure/app/performance/build-cache.md +1 -1
  61. package/en/docusaurus-plugin-content-docs/current/configure/app/performance/bundle-analyze.md +1 -1
  62. package/en/docusaurus-plugin-content-docs/current/configure/app/performance/chunk-split.md +1 -1
  63. package/en/docusaurus-plugin-content-docs/current/configure/app/performance/print-file-size.md +1 -1
  64. package/en/docusaurus-plugin-content-docs/current/configure/app/performance/profile.md +1 -1
  65. package/en/docusaurus-plugin-content-docs/current/configure/app/performance/remove-console.md +1 -1
  66. package/en/docusaurus-plugin-content-docs/current/configure/app/performance/remove-moment-locale.md +1 -1
  67. package/en/docusaurus-plugin-content-docs/current/configure/app/plugins.md +1 -1
  68. package/en/docusaurus-plugin-content-docs/current/configure/app/security/sri.md +1 -1
  69. package/en/docusaurus-plugin-content-docs/current/configure/app/server/routes.md +2 -4
  70. package/en/docusaurus-plugin-content-docs/current/configure/app/source/alias.md +1 -1
  71. package/en/docusaurus-plugin-content-docs/current/configure/app/source/compile-js-data-uri.md +1 -1
  72. package/en/docusaurus-plugin-content-docs/current/configure/app/source/define.md +1 -1
  73. package/en/docusaurus-plugin-content-docs/current/configure/app/source/exclude.md +1 -1
  74. package/en/docusaurus-plugin-content-docs/current/configure/app/source/global-vars.md +1 -1
  75. package/en/docusaurus-plugin-content-docs/current/configure/app/source/include.md +1 -1
  76. package/en/docusaurus-plugin-content-docs/current/configure/app/source/module-scopes.md +1 -1
  77. package/en/docusaurus-plugin-content-docs/current/configure/app/source/pre-entry.md +1 -1
  78. package/en/docusaurus-plugin-content-docs/current/configure/app/source/resolve-extension-prefix.md +1 -1
  79. package/en/docusaurus-plugin-content-docs/current/configure/app/source/resolve-main-fields.md +1 -1
  80. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/autoprefixer.md +1 -1
  81. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/babel.md +1 -1
  82. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/css-extract.md +1 -1
  83. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/css-loader.md +1 -1
  84. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/dev-server.md +1 -1
  85. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/esbuild.md +16 -39
  86. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/html-plugin.md +1 -1
  87. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/inspector.md +1 -1
  88. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/less.md +1 -1
  89. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/minify-css.md +1 -1
  90. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/postcss.md +1 -1
  91. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/pug.md +1 -1
  92. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/sass.md +1 -1
  93. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/style-loader.md +1 -1
  94. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/styled-components.md +1 -1
  95. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/swc.md +42 -0
  96. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/terser.md +1 -1
  97. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/ts-checker.md +1 -1
  98. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/ts-loader.md +1 -1
  99. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/webpack-chain.md +1 -1
  100. package/en/docusaurus-plugin-content-docs/current/configure/app/tools/webpack.md +1 -1
  101. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/builder.md +46 -0
  102. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/css-in-js.md +38 -0
  103. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/css-modules.md +86 -0
  104. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/less-sass.md +17 -0
  105. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/postcss.md +81 -0
  106. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/tailwindcss.md +95 -0
  107. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/data-fetch.md +66 -0
  108. package/en/docusaurus-plugin-content-docs/current/guides/basic-features/routes.md +270 -0
  109. package/en/docusaurus-plugin-content-docs/current/guides/concept/entries.md +116 -0
  110. package/en/docusaurus-plugin-content-docs/current/guides/concept/lifecycle.md +15 -0
  111. package/en/docusaurus-plugin-content-docs/current/guides/get-started/quick-start.md +162 -0
  112. package/en/docusaurus-plugin-content-docs/current/guides/get-started/upgrade.md +78 -0
  113. package/{zh/tutorials/first-app → en/docusaurus-plugin-content-docs/current/guides}/overview.md +4 -4
  114. package/en/docusaurus-plugin-content-docs/current/tutorials/foundations/introduction.md +1 -1
  115. package/en/docusaurus-plugin-content-docs/current.json +29 -29
  116. package/package.json +3 -3
  117. package/scripts/config.ts +2 -2
  118. package/zh/apis/app/commands/inspect.md +0 -4
  119. package/zh/apis/app/commands/new.md +1 -3
  120. package/zh/apis/app/hooks/src/index_.md +6 -5
  121. package/zh/apis/app/runtime/app/_category_.json +1 -1
  122. package/zh/apis/app/runtime/bff/_category_.json +1 -1
  123. package/zh/apis/app/runtime/core/_category_.json +1 -1
  124. package/zh/apis/app/runtime/core/bootstrap.md +17 -3
  125. package/zh/apis/app/runtime/model/_category_.json +1 -1
  126. package/zh/apis/app/runtime/model/create-app.md +1 -1
  127. package/zh/apis/app/runtime/model/use-store.md +1 -23
  128. package/zh/apis/app/runtime/router/_category_.json +1 -1
  129. package/zh/apis/app/runtime/ssr/_category_.json +1 -1
  130. package/zh/apis/app/runtime/testing/_category_.json +1 -1
  131. package/zh/apis/app/runtime/utility/_category_.json +1 -1
  132. package/zh/apis/app/runtime/web-server/_category_.json +1 -1
  133. package/zh/components/debug-app.md +18 -0
  134. package/zh/components/global-proxy.md +28 -0
  135. package/zh/components/init-app.md +44 -0
  136. package/zh/components/prerequisites.md +19 -0
  137. package/zh/components/reduck-migration.md +1 -0
  138. package/zh/configure/app/dev/asset-prefix.md +1 -1
  139. package/zh/configure/app/dev/hmr.md +1 -1
  140. package/zh/configure/app/dev/https.md +1 -1
  141. package/zh/configure/app/dev/port.md +1 -1
  142. package/zh/configure/app/dev/progress-bar.md +1 -1
  143. package/zh/configure/app/dev/start-url.md +1 -1
  144. package/zh/configure/app/experiments/_category_.json +4 -0
  145. package/zh/configure/app/experiments/lazy-compilation.md +1 -1
  146. package/zh/configure/app/html/_category_.json +4 -0
  147. package/zh/configure/app/html/app-icon.md +1 -1
  148. package/zh/configure/app/html/crossorigin.md +1 -1
  149. package/zh/configure/app/html/disable-html-folder.md +1 -1
  150. package/zh/configure/app/html/favicon-by-entries.md +1 -1
  151. package/zh/configure/app/html/favicon.md +1 -1
  152. package/zh/configure/app/html/inject-by-entries.md +1 -1
  153. package/zh/configure/app/html/inject.md +1 -1
  154. package/zh/configure/app/html/meta-by-entries.md +1 -1
  155. package/zh/configure/app/html/meta.md +1 -1
  156. package/zh/configure/app/html/mount-id.md +1 -1
  157. package/zh/configure/app/html/template-by-entries.md +1 -1
  158. package/zh/configure/app/html/template-parameters-by-entries.md +1 -1
  159. package/zh/configure/app/html/template-parameters.md +1 -1
  160. package/zh/configure/app/html/template.md +1 -1
  161. package/zh/configure/app/html/title-by-entries.md +1 -1
  162. package/zh/configure/app/html/title.md +1 -1
  163. package/zh/configure/app/output/asset-prefix.md +1 -1
  164. package/zh/configure/app/output/assets-retry.md +1 -1
  165. package/zh/configure/app/output/charset.md +1 -1
  166. package/zh/configure/app/output/clean-dist-path.md +1 -1
  167. package/zh/configure/app/output/convert-to-rem.md +1 -1
  168. package/zh/configure/app/output/copy.md +1 -1
  169. package/zh/configure/app/output/css-module-local-ident-name.md +1 -1
  170. package/zh/configure/app/output/data-uri-limit.md +1 -1
  171. package/zh/configure/app/output/disable-css-extract.md +1 -1
  172. package/zh/configure/app/output/disable-css-module-extension.md +1 -1
  173. package/zh/configure/app/output/disable-filename-hash.md +1 -1
  174. package/zh/configure/app/output/disable-inline-runtime-chunk.md +1 -1
  175. package/zh/configure/app/output/disable-minimize.md +1 -1
  176. package/zh/configure/app/output/disable-source-map.md +1 -1
  177. package/zh/configure/app/output/disable-ts-checker.md +1 -1
  178. package/zh/configure/app/output/dist-path.md +1 -1
  179. package/zh/configure/app/output/enable-asset-fallback.md +1 -1
  180. package/zh/configure/app/output/enable-asset-manifest.md +1 -1
  181. package/zh/configure/app/output/enable-css-module-tsdeclaration.md +1 -1
  182. package/zh/configure/app/output/enable-inline-scripts.md +1 -1
  183. package/zh/configure/app/output/enable-inline-styles.md +1 -1
  184. package/zh/configure/app/output/enable-latest-decorators.md +1 -1
  185. package/zh/configure/app/output/externals.md +1 -1
  186. package/zh/configure/app/output/filename.md +1 -1
  187. package/zh/configure/app/output/legal-comments.md +1 -1
  188. package/zh/configure/app/output/override-browserslist.md +1 -1
  189. package/zh/configure/app/output/polyfill.md +1 -1
  190. package/zh/configure/app/output/ssg.md +118 -114
  191. package/zh/configure/app/output/svg-default-export.md +1 -1
  192. package/zh/configure/app/performance/_category_.json +4 -0
  193. package/zh/configure/app/performance/build-cache.md +1 -1
  194. package/zh/configure/app/performance/bundle-analyze.md +1 -1
  195. package/zh/configure/app/performance/chunk-split.md +1 -1
  196. package/zh/configure/app/performance/print-file-size.md +1 -1
  197. package/zh/configure/app/performance/profile.md +1 -1
  198. package/zh/configure/app/performance/remove-console.md +1 -1
  199. package/zh/configure/app/performance/remove-moment-locale.md +1 -1
  200. package/zh/configure/app/plugins.md +1 -1
  201. package/zh/configure/app/runtime/state.md +13 -0
  202. package/zh/configure/app/security/_category_.json +4 -0
  203. package/zh/configure/app/security/sri.md +1 -1
  204. package/zh/configure/app/server/routes.md +2 -4
  205. package/zh/configure/app/server/ssr.md +0 -2
  206. package/zh/configure/app/source/alias.md +1 -1
  207. package/zh/configure/app/source/compile-js-data-uri.md +1 -1
  208. package/zh/configure/app/source/define.md +1 -1
  209. package/zh/configure/app/source/exclude.md +1 -1
  210. package/zh/configure/app/source/global-vars.md +1 -1
  211. package/zh/configure/app/source/include.md +1 -1
  212. package/zh/configure/app/source/module-scopes.md +1 -1
  213. package/zh/configure/app/source/pre-entry.md +1 -1
  214. package/zh/configure/app/source/resolve-extension-prefix.md +1 -1
  215. package/zh/configure/app/source/resolve-main-fields.md +1 -1
  216. package/zh/configure/app/tools/autoprefixer.md +1 -1
  217. package/zh/configure/app/tools/babel.md +1 -1
  218. package/zh/configure/app/tools/css-extract.md +1 -1
  219. package/zh/configure/app/tools/css-loader.md +1 -1
  220. package/zh/configure/app/tools/dev-server.md +1 -1
  221. package/zh/configure/app/tools/esbuild.md +16 -39
  222. package/zh/configure/app/tools/html-plugin.md +1 -1
  223. package/zh/configure/app/tools/inspector.md +1 -1
  224. package/zh/configure/app/tools/less.md +1 -1
  225. package/zh/configure/app/tools/minify-css.md +1 -1
  226. package/zh/configure/app/tools/postcss.md +1 -1
  227. package/zh/configure/app/tools/pug.md +1 -1
  228. package/zh/configure/app/tools/sass.md +1 -1
  229. package/zh/configure/app/tools/style-loader.md +1 -1
  230. package/zh/configure/app/tools/styled-components.md +1 -1
  231. package/zh/configure/app/tools/swc.md +42 -0
  232. package/zh/configure/app/tools/terser.md +1 -1
  233. package/zh/configure/app/tools/ts-checker.md +1 -1
  234. package/zh/configure/app/tools/ts-loader.md +1 -1
  235. package/zh/configure/app/tools/webpack-chain.md +1 -1
  236. package/zh/configure/app/tools/webpack.md +1 -1
  237. package/zh/guides/advanced-features/bff/bff-proxy.md +1 -1
  238. package/zh/guides/advanced-features/compatibility.md +2 -38
  239. package/zh/guides/advanced-features/custom-app.md +23 -19
  240. package/zh/guides/advanced-features/ssg.md +73 -62
  241. package/zh/guides/advanced-features/ssr.md +142 -36
  242. package/zh/guides/advanced-features/testing.md +33 -1
  243. package/zh/guides/advanced-features/web-server.md +2 -2
  244. package/zh/guides/basic-features/builder.md +46 -0
  245. package/zh/guides/basic-features/css/_category_.json +1 -1
  246. package/zh/guides/basic-features/css/less-sass.md +1 -14
  247. package/zh/guides/basic-features/css/tailwindcss.md +2 -6
  248. package/zh/guides/basic-features/data-fetch.md +1 -1
  249. package/zh/guides/basic-features/env-vars.md +34 -0
  250. package/zh/guides/basic-features/html.md +182 -0
  251. package/zh/guides/basic-features/mock.md +3 -9
  252. package/zh/guides/basic-features/proxy.md +2 -27
  253. package/zh/guides/basic-features/routes.md +32 -35
  254. package/zh/guides/concept/entries.md +8 -9
  255. package/zh/guides/get-started/quick-start.md +6 -78
  256. package/zh/guides/get-started/upgrade.md +8 -8
  257. package/zh/guides/topic-detail/framework-plugin/extend.md +3 -4
  258. package/zh/{apis/app/runtime/plugin/hook-api.md → guides/topic-detail/framework-plugin/hook-list.md} +42 -135
  259. package/zh/{apis/app/runtime/plugin → guides/topic-detail/framework-plugin}/hook.md +2 -3
  260. package/zh/guides/topic-detail/framework-plugin/implement.md +21 -10
  261. package/zh/guides/topic-detail/framework-plugin/introduction.md +49 -0
  262. package/{en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin → zh/guides/topic-detail/framework-plugin}/plugin-api.md +3 -4
  263. package/zh/guides/topic-detail/framework-plugin/relationship.md +2 -3
  264. package/zh/guides/topic-detail/model/quick-start.md +5 -1
  265. package/zh/guides/topic-detail/model/test-model.md +2 -2
  266. package/zh/guides/topic-detail/monorepo/intro.md +1 -1
  267. package/zh/guides/troubleshooting/dependencies.md +0 -69
  268. package/zh/tutorials/first-app/_category_.json +1 -1
  269. package/zh/tutorials/first-app/c01-start.md +94 -0
  270. package/zh/tutorials/first-app/c02-component.md +56 -0
  271. package/zh/tutorials/first-app/c03-css.md +305 -0
  272. package/zh/tutorials/first-app/c04-routes.md +169 -0
  273. package/zh/tutorials/first-app/c05-loader.md +82 -0
  274. package/zh/tutorials/first-app/c06-model.md +256 -0
  275. package/zh/tutorials/first-app/c07-container.md +268 -0
  276. package/zh/tutorials/first-app/c08-entries.md +134 -0
  277. package/zh/tutorials/foundations/introduction.md +2 -2
  278. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/default-alias.md +0 -25
  279. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/_category_.json +0 -4
  280. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/abstract.md +0 -26
  281. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/hook-api.md +0 -896
  282. package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/hook.md +0 -170
  283. package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-modern-mode.md +0 -34
  284. package/zh/apis/app/runtime/default-alias.md +0 -23
  285. package/zh/apis/app/runtime/plugin/_category_.json +0 -4
  286. package/zh/apis/app/runtime/plugin/abstract.md +0 -26
  287. package/zh/apis/app/runtime/plugin/plugin-api.md +0 -117
  288. package/zh/apis/generator/overview.md +0 -32
  289. package/zh/configure/app/output/enable-modern-mode.md +0 -34
  290. package/zh/guides/basic-features/image.md +0 -43
  291. package/zh/guides/topic-detail/compile-speed.md +0 -182
  292. package/zh/guides/topic-detail/framework-plugin/abstract.md +0 -27
  293. package/zh/guides/topic-detail/monorepo/deploy.md +0 -43
  294. package/zh/guides/troubleshooting/compile.md +0 -379
  295. package/zh/tutorials/first-app/c01-getting-started/1.1-prerequisites.md +0 -25
  296. package/zh/tutorials/first-app/c01-getting-started/1.2-minimal-mwa.md +0 -118
  297. package/zh/tutorials/first-app/c01-getting-started/1.3-dev-command.md +0 -29
  298. package/zh/tutorials/first-app/c01-getting-started/1.4-enable-ssr.md +0 -44
  299. package/zh/tutorials/first-app/c01-getting-started/1.5-start-command.md +0 -18
  300. package/zh/tutorials/first-app/c01-getting-started/1.6-create-repo.md +0 -31
  301. package/zh/tutorials/first-app/c01-getting-started/_category_.json +0 -3
  302. package/zh/tutorials/first-app/c02-generator-and-studio/2.1-generator.md +0 -79
  303. package/zh/tutorials/first-app/c02-generator-and-studio/2.2-boilerplates.md +0 -36
  304. package/zh/tutorials/first-app/c02-generator-and-studio/2.3-configuration.md +0 -21
  305. package/zh/tutorials/first-app/c02-generator-and-studio/_category_.json +0 -3
  306. package/zh/tutorials/first-app/c03-ide/3.1-setting-up.md +0 -55
  307. package/zh/tutorials/first-app/c03-ide/3.2-hints-in-ide.md +0 -66
  308. package/zh/tutorials/first-app/c03-ide/3.3-autofix-in-ide.md +0 -11
  309. package/zh/tutorials/first-app/c03-ide/3.4-autofix-in-cli.md +0 -63
  310. package/zh/tutorials/first-app/c03-ide/_category_.json +0 -3
  311. package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.1-use-es6-plus.md +0 -67
  312. package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.2-use-typescript.md +0 -111
  313. package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.3-compatibility.md +0 -67
  314. package/zh/tutorials/first-app/c04-es6-plus-and-ts/_category_.json +0 -3
  315. package/zh/tutorials/first-app/c05-component/5.1-use-ui-library.md +0 -68
  316. package/zh/tutorials/first-app/c05-component/5.2-use-standalone-component.md +0 -92
  317. package/zh/tutorials/first-app/c05-component/_category_.json +0 -3
  318. package/zh/tutorials/first-app/c06-css-and-component/6.1-css-in-js.md +0 -110
  319. package/zh/tutorials/first-app/c06-css-and-component/6.2-utility-class.md +0 -148
  320. package/zh/tutorials/first-app/c06-css-and-component/6.3-postcss.md +0 -84
  321. package/zh/tutorials/first-app/c06-css-and-component/6.4-design-system.md +0 -83
  322. package/zh/tutorials/first-app/c06-css-and-component/6.5-storybook.md +0 -77
  323. package/zh/tutorials/first-app/c06-css-and-component/6.6-testing.md +0 -113
  324. package/zh/tutorials/first-app/c06-css-and-component/_category_.json +0 -3
  325. package/zh/tutorials/first-app/c07-app-entry/7.1-intro.md +0 -64
  326. package/zh/tutorials/first-app/c07-app-entry/7.2-add-entry-in-cli.md +0 -100
  327. package/zh/tutorials/first-app/c07-app-entry/7.3-manage-entries-by-hand.md +0 -74
  328. package/zh/tutorials/first-app/c07-app-entry/_category_.json +0 -3
  329. package/zh/tutorials/first-app/c08-client-side-routing/8.1-code-based-routing.md +0 -153
  330. package/zh/tutorials/first-app/c08-client-side-routing/8.2-file-based-routing.md +0 -310
  331. package/zh/tutorials/first-app/c08-client-side-routing/_category_.json +0 -3
  332. package/zh/tutorials/first-app/c09-bff/9.1-serverless.md +0 -30
  333. package/zh/tutorials/first-app/c09-bff/9.2-enable-bff.md +0 -93
  334. package/zh/tutorials/first-app/c09-bff/9.3-fetch-bff.md +0 -205
  335. package/zh/tutorials/first-app/c09-bff/_category_.json +0 -3
  336. package/zh/tutorials/first-app/c10-model/10.1-application-architecture.md +0 -23
  337. package/zh/tutorials/first-app/c10-model/10.2-add-model.md +0 -185
  338. package/zh/tutorials/first-app/c10-model/10.3-use-model.md +0 -54
  339. package/zh/tutorials/first-app/c10-model/10.4-testing.md +0 -69
  340. package/zh/tutorials/first-app/c10-model/_category_.json +0 -3
  341. package/zh/tutorials/first-app/c11-container/11.1-use-model-with-app-state.md +0 -274
  342. package/zh/tutorials/first-app/c11-container/11.2-add-container.md +0 -106
  343. package/zh/tutorials/first-app/c11-container/11.3-use-loader.md +0 -61
  344. package/zh/tutorials/first-app/c11-container/11.4-testing.md +0 -56
  345. package/zh/tutorials/first-app/c11-container/_category_.json +0 -3
@@ -4,7 +4,7 @@ sidebar_label: cssLoader
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.cssLoader](https://modernjs.dev/builder/zh/api/config-tools.html#tools-cssloader)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.cssLoader](https://modernjs.dev/builder/zh/api/config-tools.html#tools-cssloader)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/cssLoader.md'
@@ -4,7 +4,7 @@ sidebar_label: devServer
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.devServer](https://modernjs.dev/builder/zh/api/config-tools.html#tools-devserver)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.devServer](https://modernjs.dev/builder/zh/api/config-tools.html#tools-devserver)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/devServer.md'
@@ -3,59 +3,36 @@ title: tools.esbuild
3
3
  sidebar_label: esbuild
4
4
  ---
5
5
 
6
- * 类型: `Object`
7
- * 默认值: `undefined`
6
+ - 类型: `Object`
7
+ - 默认值: `undefined`
8
8
 
9
9
  ## 介绍
10
10
 
11
- esbuild 是使用 Go 语言编写的 JavaScript Bundler/Minifier,它的特点是速度极快。在代码压缩方面,相比 webpack 内置的 terser 压缩器,esbuild 在性能上有数十倍的提升。
12
-
13
- Modern.js 基于 esbuild 提供了代码编译和压缩的能力,在大型工程中开启后,**可以大幅度减少代码压缩所需的时间,同时有效避免 OOM (heap out of memory) 问题**。
14
-
15
- 使用 esbuild 压缩虽然带来了构建效率上的提升,但 esbuild 的压缩比例是低于 terser 的,因此**构建产物的体积会增大**,请根据业务情况酌情使用(比较适合中后台场景)。
16
-
17
- 对于压缩工具之间的详细对比,可以参考 [minification-benchmarks](https://github.com/privatenumber/minification-benchmarks)。
18
-
19
- :::info
20
- 除了代码压缩外,esbuild 也可以代替 babel 进行代码编译,优点是可以提升编译速度,缺点是无法使用丰富的 babel 插件能力。
11
+ :::tip esbuild 介绍
12
+ [esbuild](https://esbuild.github.io/) 是一款基于 Golang 开发的前端构建工具,具有打包、编译和压缩 JavaScript 代码的功能,相比传统的打包编译工具,esbuild 在性能上有显著提升。在代码压缩方面,相比 webpack 内置的 terser 压缩器,esbuild 在性能上有数十倍的提升。
21
13
  :::
22
14
 
23
- ## 配置项
24
-
25
- ### target
15
+ Modern.js 提供了 esbuild 插件,让你能使用 esbuild 代替 babel-loader、ts-loader 和 terser 等库进行代码编译和压缩。在大型工程中开启后,**可以大幅度减少代码编译和压缩所需的时间,同时有效避免 OOM (heap out of memory) 问题**。
26
16
 
27
- * 类型: `string | string[]`
28
- * 默认值: `'esnext'`
29
-
30
- 为生成的 JavaScript 和 CSS 代码设置目标环境。
31
-
32
- 可以直接设置为 JavaScript 语言版本,比如 `es5`,`es6`,`es2020`。也可以设置为若干个目标环境,每个目标环境都是一个环境名称后跟一个版本号。比如 `['chrome58', 'edge16' ,'firefox57']`。
33
-
34
- 支持设置以下环境:
17
+ ## 配置项
35
18
 
36
- - chrome
37
- - edge
38
- - firefox
39
- - ie
40
- - ios
41
- - node
42
- - opera
43
- - safari
19
+ 你可以通过 `tools.esbuild` 配置项来设置 esbuild 编译行为。
44
20
 
45
- 默认情况下,esbuild 压缩过程中会引入 ES6 代码,比如模板字符串。如果需要兼容 ES5,可以将 `target` 设置为 `es5`。
21
+ ```js title="modern.config.ts"
22
+ import { defineConfig } from '@modern-js/app-tools';
46
23
 
47
- ```typescript title="modern.config.ts"
48
24
  export default defineConfig({
49
25
  tools: {
50
26
  esbuild: {
51
- target: 'es5',
27
+ loader: {
28
+ target: 'chrome61',
29
+ },
30
+ minimize: {
31
+ target: 'chrome61',
32
+ },
52
33
  },
53
34
  },
54
35
  });
55
36
  ```
56
37
 
57
- :::info
58
- 设置 `target` 为 `es5` 时,需要保证所有代码被 babel 转义为 es5 代码,否则会导致 esbuild 编译报错:`Transforming 'xxx' to the configured target environment ("es5") is not supported yet`。
59
-
60
- `target` 字段的详细介绍可以参考 [esbuild - target](https://esbuild.github.io/api/#target)。
61
- :::
38
+ 完整配置项请参考 [Modern.js Builder - esbuild 插件配置](https://modernjs.dev/builder/zh/plugins/plugin-esbuild.html#%E9%85%8D%E7%BD%AE)。
@@ -4,7 +4,7 @@ sidebar_label: htmlPlugin
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.htmlPlugin](https://modernjs.dev/builder/zh/api/config-tools.html#tools-htmlplugin)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.htmlPlugin](https://modernjs.dev/builder/zh/api/config-tools.html#tools-htmlplugin)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/htmlPlugin.md'
@@ -4,7 +4,7 @@ sidebar_label: inspector
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.inspector](https://modernjs.dev/builder/zh/api/config-tools.html#tools-inspector)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.inspector](https://modernjs.dev/builder/zh/api/config-tools.html#tools-inspector)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/inspector.md'
@@ -4,7 +4,7 @@ sidebar_label: less
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.less](https://modernjs.dev/builder/zh/api/config-tools.html#tools-less)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.less](https://modernjs.dev/builder/zh/api/config-tools.html#tools-less)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/less.md'
@@ -4,7 +4,7 @@ sidebar_label: minifyCss
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.minifyCss](https://modernjs.dev/builder/zh/api/config-tools.html#tools-minifycss)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.minifyCss](https://modernjs.dev/builder/zh/api/config-tools.html#tools-minifycss)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/minifyCss.md'
@@ -4,7 +4,7 @@ sidebar_label: postcss
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.postcss](https://modernjs.dev/builder/zh/api/config-tools.html#tools-postcss)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.postcss](https://modernjs.dev/builder/zh/api/config-tools.html#tools-postcss)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/postcss.md'
@@ -4,7 +4,7 @@ sidebar_label: pug
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.pug](https://modernjs.dev/builder/zh/api/config-tools.html#tools-pug)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.pug](https://modernjs.dev/builder/zh/api/config-tools.html#tools-pug)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/pug.md'
@@ -4,7 +4,7 @@ sidebar_label: sass
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.sass](https://modernjs.dev/builder/zh/api/config-tools.html#tools-sass)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.sass](https://modernjs.dev/builder/zh/api/config-tools.html#tools-sass)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/sass.md'
@@ -4,7 +4,7 @@ sidebar_label: styleLoader
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.styleLoader](https://modernjs.dev/builder/zh/api/config-tools.html#tools-styleloader)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.styleLoader](https://modernjs.dev/builder/zh/api/config-tools.html#tools-styleloader)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/styleLoader.md'
@@ -4,7 +4,7 @@ sidebar_label: styledComponents
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.styledComponents](https://modernjs.dev/builder/zh/api/config-tools.html#tools-styledcomponents)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.styledComponents](https://modernjs.dev/builder/zh/api/config-tools.html#tools-styledcomponents)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/styledComponents.md'
@@ -0,0 +1,42 @@
1
+ ---
2
+ title: tools.swc
3
+ sidebar_label: swc
4
+ ---
5
+
6
+ - 类型: `Object`
7
+ - 默认值: `undefined`
8
+
9
+ ## 介绍
10
+
11
+ [SWC](https://swc.rs/) (Speedy Web Compiler) 是基于 `Rust` 语言编写的高性能 JavaScript 和 TypeScript 转译和压缩工具。在 Polyfill 和语法降级方面可以和 Babel 提供一致的能力,并且比 Babel 性能高出 10 倍不止。
12
+
13
+ Modern.js 提供了开箱即用的 SWC 插件,可以为你的 Web 应用提供语法降级、Polyfill 以及压缩,并且移植了一些额外常见的 Babel 插件。
14
+
15
+ ## 安装
16
+
17
+ 使用前需要安装 `@modern-js/plugin-swc` 插件,安装完成后,会自动启用 SWC 编译和压缩能力。
18
+
19
+ ```bash
20
+ pnpm add @modern-js/plugin-swc -D
21
+ ```
22
+
23
+ ## 配置项
24
+
25
+ 你可以通过 `tools.swc` 配置项来设置 SWC 编译行为。
26
+
27
+ ```js title="modern.config.ts"
28
+ import { defineConfig } from '@modern-js/app-tools';
29
+
30
+ export default defineConfig({
31
+ tools: {
32
+ swc: {
33
+ jsMinify: {
34
+ compress: {},
35
+ mangle: true,
36
+ },
37
+ },
38
+ },
39
+ });
40
+ ```
41
+
42
+ 完整配置项请参考 [Modern.js Builder - SWC 插件配置](https://modernjs.dev/builder/zh/plugins/plugin-swc.html#%E9%85%8D%E7%BD%AE)。
@@ -4,7 +4,7 @@ sidebar_label: terser
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.terser](https://modernjs.dev/builder/zh/api/config-tools.html#tools-terser)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.terser](https://modernjs.dev/builder/zh/api/config-tools.html#tools-terser)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/terser.md'
@@ -4,7 +4,7 @@ sidebar_label: tsChecker
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.tsChecker](https://modernjs.dev/builder/zh/api/config-tools.html#tools-tschecker)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.tsChecker](https://modernjs.dev/builder/zh/api/config-tools.html#tools-tschecker)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/tsChecker.md'
@@ -4,7 +4,7 @@ sidebar_label: tsLoader
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.tsLoader](https://modernjs.dev/builder/zh/api/config-tools.html#tools-tsloader)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.tsLoader](https://modernjs.dev/builder/zh/api/config-tools.html#tools-tsloader)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/tsLoader.md'
@@ -4,7 +4,7 @@ sidebar_label: webpackChain
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.webpackChain](https://modernjs.dev/builder/zh/api/config-tools.html#tools-webpackchain)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.webpackChain](https://modernjs.dev/builder/zh/api/config-tools.html#tools-webpackchain)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/webpackChain.md'
@@ -4,7 +4,7 @@ sidebar_label: webpack
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- 该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.webpack](https://modernjs.dev/builder/zh/api/config-tools.html#tools-webpack)。
7
+ 该配置为 Modern.js Builder 配置,详细信息可参考 [tools.webpack](https://modernjs.dev/builder/zh/api/config-tools.html#tools-webpack)。
8
8
  :::
9
9
 
10
10
  import Main from '@modern-js/builder-doc/zh/config/tools/webpack.md'
@@ -5,7 +5,7 @@ title: 使用 BFF 代理
5
5
 
6
6
  通过配置 BFF 代理,无需手动写码,即可对 API 请求进行转发。
7
7
 
8
- ::: caution
8
+ :::caution
9
9
  使用 BFF 代理需确保请求能进入 BFF handler。(例如请求路径必须包含 bff prefix)
10
10
  :::
11
11
 
@@ -25,8 +25,8 @@ Modern.js 中还提供了基于浏览器 [UA](https://developer.mozilla.org/zh-C
25
25
  可以通过微生成器开启该功能:
26
26
 
27
27
  ```bash
28
- ? 请选择你想要的操作:启用可选功能
29
- ? 启用可选功能:启用「基于 UA 的 Polyfill」功能
28
+ ? 请选择你想要的操作 启用可选功能
29
+ ? 启用可选功能 启用「基于 UA 的 Polyfill」功能
30
30
  ```
31
31
 
32
32
  安装依赖后,配置 `output.polyfill` 为 `ua` 并且执行 `pnpm run build && pnpm run start` 启动服务器后,访问页面可以看到 HTML 产物中包含如下脚本:
@@ -40,42 +40,6 @@ Modern.js 中还提供了基于浏览器 [UA](https://developer.mozilla.org/zh-C
40
40
 
41
41
  ![ua-polyfill](https://lf3-static.bytednsdoc.com/obj/eden-cn/aphqeh7uhohpquloj/modern-js/docs/ua-polyfill.png)
42
42
 
43
-
44
- ## 差异化分发
45
-
46
- Modern.js 提供了运行时基于浏览器 User Agent 的差异化分发方案, 设置 [`output.enableModernMode`](/docs/configure/app/output/enable-modern-mode) 后, 生产环境会自动构建出针对现代浏览器语法未降级的 JS 产物和针对旧版本浏览器带有 Polyfill 的 JS 产物:
47
-
48
- ```bash title="dist/static/js"
49
- ├── 370.95db0e84-es6.js
50
- ├── 370.95db0e84-es6.js.map
51
- ├── 370.ace5d8a0.js
52
- ├── 370.ace5d8a0.js.map
53
- ├── main.64eb3bc7-es6.js
54
- ├── main.64eb3bc7-es6.js.map
55
- ├── main.c8aab430.js
56
- ├── main.c8aab430.js.map
57
- ├── runtime-main.9ad9a46b-es6.js
58
- ├── runtime-main.9ad9a46b-es6.js.map
59
- ├── runtime-main.dccca6e0.js
60
- └── runtime-main.dccca6e0.js.map
61
- ```
62
-
63
- 同时 HTML 也会构建出对应的 ES6 版本:
64
-
65
- ```js title="dist/html/main/index-es6.html"
66
- <script defer="defer" src="/static/js/370.95db0e84-es6.js"></script>
67
- ```
68
-
69
- ```js title="dist/html/main/index.html"
70
- <script defer="defer" src="/static/js/370.ace5d8a0.js"></script>
71
- ```
72
-
73
- 通过 `pnpm run build && pnpm run start` 启动服务器, 访问页面时,会根据浏览器信息决定返回 `index-es6.html` 还是 `index.html`。
74
-
75
- :::info 注
76
- 内部目前使用 [@babel/compat-data](https://github.com/babel/babel/blob/main/packages/babel-compat-data/data/native-modules.json) 来判断具体浏览器是否支持 es6 语法。
77
- :::
78
-
79
43
  ## Browserslist 配置
80
44
 
81
45
  Modern.js 支持在项目根目录 `package.json` 文件中的 `browserslist` 字段(或单独的 `.browserslistrc` 文件)指定项目覆盖的目标浏览器范围。该值会被 [`@babel/preset-env`](https://babeljs.io/docs/en/babel-preset-env) 和 [`autoprefixer`](https://github.com/postcss/autoprefixer) 用来确定需要转换的 JavaScript 语法特性和需要添加的 CSS 浏览器前缀。
@@ -9,46 +9,50 @@ sidebar_position: 7
9
9
 
10
10
  ## 添加自定义行为
11
11
 
12
- 当 `index` 文件默认导出**函数**是,Modern.js 还是会根据 `runtime.features` 的设置情况生成 `createApp` 包裹后的代码。在渲染过程中,将 `createApp` 包裹后的组件作为参数传递给 `index` 文件导出的函数,这样开发者可以自定义将组件挂载到 DOM 节点上,或在挂载前添加自定义行为。例如:
12
+ 当 `index` 文件默认导出**函数**是,Modern.js 还是会根据 `runtime` 的设置情况生成 `createApp` 包裹后的代码。在渲染过程中,将 `createApp` 包裹后的组件作为参数传递给 `index` 文件导出的函数,这样开发者可以自定义将组件挂载到 DOM 节点上,或在挂载前添加自定义行为。例如:
13
13
 
14
14
  ```js title=src/index.jsx
15
+ import ReactDOM from 'react-dom/client'
15
16
  import { bootstrap } from '@modern-js/runtime';
16
17
 
17
- export default App => {
18
+
19
+ export default (App: React.ComponentType) => {
18
20
  // do something before bootstrap...
19
- bootstrap(App, 'root');
21
+ bootstrap(App, 'root', undefined, ReactDOM);
20
22
  };
21
23
  ```
22
24
 
25
+ :::warning
26
+ 由于 bootstrap 函数需要兼容 React17 和 React18 的用法,调用 bootstrap 函数时需要手动传入 ReactDOM 参数。
27
+ :::
28
+
23
29
  Modern.js 生成的文件内容如下:
24
30
 
25
31
  ```js
26
- import customRender from '@/src/index.js';
27
- import { createApp, bootstrap } from '@modern-js/runtime';
28
32
  import React from 'react';
29
- import App from '@/src/App';
33
+ import ReactDOM from 'react-dom/client';
34
+ import customBootstrap from '@_edenx_src/index.tsx';
35
+ import App from '@_edenx_src/App';
36
+ import { router, state } from '@edenx/runtime/plugins';
30
37
 
31
- const IS_BROWSER = typeof window !== 'undefined';
38
+ const IS_BROWSER = typeof window !== 'undefined' && window.name !== 'nodejs';
32
39
  const MOUNT_ID = 'root';
33
40
 
34
41
  let AppWrapper = null;
35
42
 
36
- const renderApp = () => {
43
+ function render() {
37
44
  AppWrapper = createApp({
38
45
  // runtime 的插件参数...
39
- })(App);
40
- customRender(AppWrapper);
41
- };
42
-
43
- renderApp();
46
+ })(App)
47
+ if (IS_BROWSER) {
48
+ customBootstrap(AppWrapper);
49
+ }
50
+ return AppWrapper
51
+ }
44
52
 
45
- export default AppWrapper;
53
+ AppWrapper = render();
46
54
 
47
- if (IS_BROWSER && module.hot) {
48
- module.hot.accept('<path>/src/App', () => {
49
- renderApp();
50
- });
51
- }
55
+ export default AppWrapper;;
52
56
  ```
53
57
 
54
58
  ## 完全接管 Webpack 入口
@@ -1,5 +1,5 @@
1
1
  ---
2
- title: 静态站点生成
2
+ title: 静态站点生成(SSG)
3
3
  sidebar_position: 4
4
4
  ---
5
5
 
@@ -9,7 +9,7 @@ SSG(Static Site Generation)是一种基于数据与模板,在构建时渲
9
9
  SSG 是构建阶段的解决方案,因此仅对生产环境有效。通过 `dev` 命令运行时,表现效果与 SSR 相同。
10
10
  :::
11
11
 
12
- 我们首先需要执行`pnpm run new`启用 SSG 功能:
12
+ 我们首先需要执行 `pnpm run new` 启用 SSG 功能:
13
13
 
14
14
  ```bash
15
15
  ? 请选择你想要的操作 启用可选功能
@@ -25,22 +25,37 @@ SSG 在**约定式路由**和**自控式路由**下的使用方式不同。
25
25
  例如,以下是一个使用约定式路由的项目目录结构:
26
26
 
27
27
  ```
28
- ├── src/
29
- ├── pages/
30
- │ ├── home.tsx
31
- ├── info.tsx
32
- │ └── index.tsx
28
+ .
29
+ ├── src
30
+    └── routes
31
+    ├── layout.tsx
32
+    ├── page.tsx
33
+ │   └── user
34
+ │   ├── layout.tsx
35
+ │   ├── page.tsx
36
+ │   └── profile
37
+ │   └── page.tsx
33
38
  ```
34
39
 
35
- 在 `src/pages/index.tsx` 中添加组件代码:
40
+ 上述文件目录将会生成以下三条路由:
36
41
 
37
- ```jsx title="src/pages/index.tsx"
42
+ - `/`
43
+ - `/user`
44
+ - `/user/profile`
45
+
46
+ :::note
47
+ 如果还不了解约定式路由的规则,可以先查看[路由](/docs/guides/basic-features/routes)。
48
+ :::
49
+
50
+ 在 `src/routes/page.tsx` 中添加组件代码:
51
+
52
+ ```jsx title="src/routes/page.tsx"
38
53
  export default () => {
39
- return <div>index page</div>
54
+ return <div>Index Page</div>
40
55
  }
41
56
  ```
42
57
 
43
- SSG SSR 一样,也是在 Node.js 环境中完成页面渲染,因此我们可以在开发阶段开启 SSR,提前在开发阶段验证 SSG 渲染效果:
58
+ SSG 也是在 Node.js 环境渲染页面,因此我们可以在**开发阶段开启 SSR**,提前在暴露代码问题,验证 SSG 渲染效果:
44
59
 
45
60
  ```typescript title="modern.config.ts"
46
61
  export default defineConfig({
@@ -50,13 +65,11 @@ export default defineConfig({
50
65
  }
51
66
  ```
52
67
 
53
- 在项目根路径下执行 `pnpm run dev` 命令,查看 `dist/` 目录,此时只生成一个 HTML 文件:
54
-
55
- ![vsc-alert](https://lf3-static.bytednsdoc.com/obj/eden-cn/aphqeh7uhohpquloj/modern-js/docs/ssg-dev.png)
68
+ 在项目根路径下执行 `pnpm run dev` 命令,查看 `dist/` 目录,此时只生成一个 HTML 文件 `main/index.html`。
56
69
 
57
- 在项目根路径下执行 `pnpm run build` 命令,构建完成后,查看 `dist/` 目录,此时生成 `main/index.html`、`main/home/index.html` 和 `main/info/index.html` 3 HTML 文件,分别对应 `/`、`/home`、`/info` 3 个约定式路由,可见**约定式路由**中的每一条路由,都会生成一个单独的 HTML 文件。查看 `main/index.html`,可以发现包含 `index page` 的文本内容,这正是 SSG 的效果。
70
+ 在项目根路径下执行 `pnpm run build` 命令,构建完成后,查看 `dist/` 目录,此时生成 `main/index.html`、`main/user/index.html` 和 `main/user/profile/index.html` 三个 HTML 文件,内容分别对应上述三条路由。
58
71
 
59
- ![vsc-alert](https://lf3-static.bytednsdoc.com/obj/eden-cn/aphqeh7uhohpquloj/modern-js/docs/ssg-build.png)
72
+ **约定式路由**中的每一条路由,都会生成一个单独的 HTML 文件。查看 `main/index.html`,可以发现包含 `Index Page` 的文本内容,这正是 SSG 的效果。
60
73
 
61
74
  执行 `pnpm run start` 启动项目后,访问页面,在浏览器我们工具的 Network 窗口,查看请求返回的文档,文档包含组件渲染后的完整页面内容。
62
75
 
@@ -64,45 +77,46 @@ export default defineConfig({
64
77
 
65
78
  **自控式路由**是通过组件代码自定义路由,需要应用运行起来才能获取准确的路由信息。因此,无法开箱即用的使用 SSG 功能。此时需要用户提前告知 Modern.js 框架,哪些路由需要开启 SSG 功能。
66
79
 
67
- 例如有以下代码:
68
-
69
- ```ts
70
- import { Switch, Route } from '@modern-js/runtime/router';
71
-
72
- export default () => (
73
- <Switch>
74
- <Route path="/" exact={true}>
75
- <div>Home</div>
76
- </Route>
77
- <Route path="/foo" exact={true}>
78
- <div>Foo</div>
79
- </Route>
80
- </Switch>
81
- );
82
- ```
80
+ 例如有以下代码,包含多条路由,设置 `output.ssg` 为 `true` 时,默认只会渲染入口路由即 `/`:
81
+
82
+ ```tsx title="src/App.tsx"
83
+ import { useRuntimeContext } from '@modern-js/runtime';
84
+ import { Routes, Route, BrowserRouter } from '@modern-js/runtime/router';
85
+ import { StaticRouter } from '@modern-js/runtime/router/server';
83
86
 
84
- 希望为 `/foo` 路由开启 SSG 功能,同样利用 `output.ssg` 配置。该参数允许配置页面信息,告知 Modern.js 开启指定路由的 SSG 功能。
87
+ const Router = typeof window === 'undefined' ? StaticRouter : BrowserRouter;
88
+
89
+ export default () => {
90
+ const { context } = useRuntimeContext();
91
+ return (
92
+ <Router location={context.request.pathname}>
93
+ <Routes>
94
+ <Route index element={<div>index</div>} />
95
+ <Route path="about" element={<div>about</div>} />
96
+ </Routes>
97
+ </Router>
98
+ );
99
+ };
100
+ ```
85
101
 
86
- 例如上述入口中,包含两条客户端路由,分别是 `/` `/foo`,设置 `output.ssg` `true` 时,默认只会渲染入口路由即 `/`。如果我们希望同时开启 `/foo` 的 SSG 功能,可以这样配置:
102
+ 如果我们希望同时开启 `/about` SSG 功能,可以配置 `output.ssg`,告知 Modern.js 开启指定路由的 SSG 功能。
87
103
 
88
104
  ```typescript title="modern.config.ts"
89
105
  export default defineConfig({
90
106
  output: {
91
107
  ssg: {
92
- routes: ['/', '/foo'],
108
+ routes: ['/', '/about'],
93
109
  },
94
110
  },
95
111
  })
96
112
  ```
97
113
 
98
- 执行 `pnpm run build` 与 `pnpm run start` 后,访问 `http://localhost:8080/foo`,在 Preview 视图中可以看到页面已经完成渲染。
99
-
100
- 查看构建产物文件,可以看到 `dist/` 目录中,在默认的 `main` 入口产物目录下,新增一个 `foo.html` 文件:
114
+ 执行 `pnpm run build` 与 `pnpm run start` 后,访问 `http://localhost:8080/about`,在 Preview 视图中可以看到页面已经完成渲染。
101
115
 
102
- ![vsc-alert](https://lf3-static.bytednsdoc.com/obj/eden-cn/aphqeh7uhohpquloj/modern-js/docs/ssg-foo.png)
116
+ 查看构建产物文件,可以看到 `dist/` 目录中,新增了一个 `main/about/index.html` 文件。
103
117
 
104
118
  :::info
105
- 以上仅介绍了单入口的情况,与部分配置。更多相关内容可以查看 [API 文档](/docs/configure/app/output/ssg)。
119
+ 以上仅介绍了单入口的情况,更多相关内容可以查看 [API 文档](/docs/configure/app/output/ssg)。
106
120
  :::
107
121
 
108
122
  ### 获取数据
@@ -116,36 +130,33 @@ export default defineConfig({
116
130
  - 在开发阶段,不管 `useLoader` 是否配置 `{ static: true }`,函数都会在 SSR 时获取数据。
117
131
  :::
118
132
 
119
- 修改上述 `App.ts` 的代码为:
133
+ 修改上述 `src/App.ts` 的代码为:
120
134
 
121
- ```ts title="App.ts"
122
- import { Switch, Route } from '@modern-js/runtime/router';
123
- import { useLoader } from '@modern-js/runtime';
135
+ ```tsx title="App.ts"
136
+ import { useRuntimeContext, useLoader } from '@modern-js/runtime';
137
+ import { Routes, Route, BrowserRouter } from '@modern-js/runtime/router';
138
+ import { StaticRouter } from '@modern-js/runtime/router/server';
139
+
140
+ const Router = typeof window === 'undefined' ? StaticRouter : BrowserRouter;
124
141
 
125
142
  export default () => {
126
- const { data } = useLoader(
127
- async () => ({
128
- message: Math.random(),
129
- }),
130
- {
131
- static: true,
132
- params: 'foo',
133
- },
134
- );
143
+ const { context } = useRuntimeContext();
144
+
145
+ const { data } = useLoader(async () => ({
146
+ message: Math.random(),
147
+ }), { static: true });
135
148
 
136
149
  return (
137
- <Switch>
138
- <Route path="/" exact={true}>
139
- <div>Home</div>
140
- </Route>
141
- <Route path="/foo" exact={true}>
142
- <div>Foo, {data?.message}</div>
143
- </Route>
144
- </Switch>
150
+ <Router location={context.request.pathname}>
151
+ <Routes>
152
+ <Route index element={<div>index</div>} />
153
+ <Route path="about" element={<div>about, {data?.message}</div>} />
154
+ </Routes>
155
+ </Router>
145
156
  );
146
157
  };
147
158
  ```
148
159
 
149
160
  执行 `pnpm run dev`,重复刷新页面,可以看到 `/foo` 页面的渲染结果不断发生变化,说明数据是在请求时获取的。
150
161
 
151
- 重新执行 `pnpm run build` 后,执行 `pnpm run start`,重复刷新页面,发现页面渲染结果始终保持同样的内容,说明数据在请求时不会再次获取。
162
+ 重新执行 `pnpm run build` 后,执行 `pnpm run start`,重复刷新页面,发现页面渲染结果始终保持同样的内容,数据在请求时不会再次获取,说明页面在编译时已经完成渲染。