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

Sign up to get free protection for your applications and to get access to all the features.
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: tsLoader
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- This configuration is Modern.js Builder configuration, there may be links that cannot be redirected. for details, please refer to [tools.tsLoader](https://modernjs.dev/builder/zh/api/config-tools.html#tools-tsloader)。
7
+ This configuration is Modern.js Builder configuration, more detail can see [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/en/config/tools/tsLoader.md'
@@ -4,7 +4,7 @@ sidebar_label: webpackChain
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- This configuration is Modern.js Builder configuration, there may be links that cannot be redirected. for details, please refer to [tools.webpackChain](https://modernjs.dev/builder/zh/api/config-tools.html#tools-webpackchain)。
7
+ This configuration is Modern.js Builder configuration, more detail can see [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/en/config/tools/webpackChain.md'
@@ -4,7 +4,7 @@ sidebar_label: webpack
4
4
  ---
5
5
 
6
6
  :::info BUILDER
7
- This configuration is Modern.js Builder configuration, there may be links that cannot be redirected. for details, please refer to [tools.webpack](https://modernjs.dev/builder/zh/api/config-tools.html#tools-webpack)。
7
+ This configuration is Modern.js Builder configuration, more detail can see [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/en/config/tools/webpack.md'
@@ -0,0 +1,46 @@
1
+ ---
2
+ title: Builder
3
+ sidebar_position: 2
4
+ ---
5
+
6
+ **Modern.js uses [Modern.js Builder](https://modernjs.dev/builder) to build your Web APP. **
7
+
8
+ Modern.js Builder is one of the core components of Modern.js. It is a build engine for modern Web development and can be used independently of Modern.js. Modern.js Builder supports multiple bundlers such as webpack and rspack, and it uses webpack by default.
9
+
10
+ ## Build Architecture
11
+
12
+ From the perspective of building, Modern.js is divided into three layers, from top to bottom:
13
+
14
+ - Upper-layer framework: Modern.js.
15
+ - Universal build engine: Modern.js Builder.
16
+ - Low-level bundlers: webpack and rspack.
17
+
18
+ <img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvT/ljhwZthlaukjlkulzlp/builder-layers-1117.png" style={{ maxWidth: '540px' }} />
19
+
20
+ ## Builder Documentation
21
+
22
+ Since Modern.js Builder is a module that can be used independently, we provide a separate document for it, the site address is: [modernjs.dev/builder](https://modernjs.dev/builder).
23
+
24
+ In this document, you can learn about the detailed introduction of Modern.js Builder, and you can also find a complete usage guide for each building features. When you encounter building issues, it is recommended that you first read the Modern.js Builder documentation to solve them.
25
+
26
+ ## Builder Config
27
+
28
+ The config of Modern.js is inherited from Modern.js Builder, so you can use all build configs provided by Modern.js Builder in Modern.js.
29
+
30
+ Take the `html.title` config of Modern.js Builder as an example, you can directly use this config in the `modern.config.ts` file, and it will be automatically passed to Modern.js Builder.
31
+
32
+ ```ts title="modern.config.js"
33
+ export default defineConfig({
34
+ html: {
35
+ title: 'example',
36
+ },
37
+ });
38
+ ```
39
+
40
+ For details of building configs, please refer to [「Modern.js Builder - Builder Config」](https://modernjs.dev/builder/en/guide/basic/builder-config.html).
41
+
42
+ ## Building Features
43
+
44
+ Modern.js Builder provides a wealth of building features, including dozens of features such as JavaScript compilation, CSS compilation, static resource processing, hot module replacement, code compression, and TS type checking.
45
+
46
+ We recommend you to read [「Modern.js Builder - All Features」](https://modernjs.dev/builder/en/guide/features.html) to learn all the building features provided by Modern.js Builder.
@@ -0,0 +1,38 @@
1
+ ---
2
+ sidebar_position: 1
3
+ ---
4
+
5
+ # CSS-in-JS
6
+
7
+ CSS-in-JS is a technology that can write CSS styles in JS files. Modern.js integrates the CSS-in-JS library [styled-components](https://styled-components.com/) commonly used in the community, which uses the new feature of JavaScript [Tagged template](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) to write CSS styles for components. You can use the [styled-components](https://styled-components.com/) API directly from `@modern-js/runtime/styled`.
8
+
9
+ When you need to write a `div` component with an internal font in red, you can do the following implementation:
10
+
11
+ ```js
12
+ import styled from '@modern-js/runtime/styled'
13
+
14
+ const RedDiv = styled.div`
15
+ color: red;
16
+ `
17
+ ```
18
+
19
+ When you need to dynamically set the component style according to the `props` of the component, for example, when the attribute `primary` of `props` is `true`, the color of the button is white, and otherwise it is red. The implementation code is as follows:
20
+
21
+ ```js
22
+ import styled from '@modern-js/runtime/styled'
23
+
24
+ const Button = styled.button`
25
+ color: ${props => props.primary ? "white" : "red"};
26
+ font-size: 1em;
27
+ `
28
+ ```
29
+
30
+ For more usage of styled-components, please refer to [[styled-components official website](https://styled-components.com/) ].
31
+
32
+ :::info Additional
33
+ Modern.js uses the Babel plugin [babel-plugin-styled-components](https://github.com/styled-components/babel-plugin-styled-components) internally, and the plugin can be configured through [`tools.styled Components`](/docs/configure/app/tools/styled-components).
34
+ :::
35
+
36
+ :::tip
37
+ If you need to use [styled-jsx](https://www.npmjs.com/package/styled-jsx), [Emotion](https://emotion.sh/) and other CSS-in-JS libraries, you need to install the dependency of the corresponding library first. For specific usage, please refer to the official website of the corresponding library.
38
+ :::
@@ -0,0 +1,86 @@
1
+ ---
2
+ sidebar_position: 5
3
+ ---
4
+
5
+ # CSS Modules
6
+
7
+ Modern.js out of the box support for [CSS Modules](https://github.com/css-modules/css-modules).
8
+
9
+ ## File Suffix Form CSS Modules
10
+
11
+ By default, files ending in `.module.(css|scss|sass|less)` are treated as CSS Modules files, for example:
12
+
13
+ ```css title="button.module.css"
14
+ .redColor {
15
+ color: red;
16
+ }
17
+ ```
18
+
19
+ ```js title="Button.jsx"
20
+ import styles from './button.module.css';
21
+
22
+ export default function Button() {
23
+ return (
24
+ <button type="button" className={styles.redColor}>
25
+ red button
26
+ </button>
27
+ );
28
+ }
29
+ ```
30
+
31
+ Will eventually be compiled as:
32
+
33
+ ```js
34
+ <button type="button" className="button_redColor__1-RBg">
35
+ red button
36
+ </button>;
37
+ ```
38
+
39
+ ## Global CSS Modules
40
+
41
+ If you want to remove the `.module` suffix from the filename, you can set [`output.disable CssModuleExtension`](/docs/configure/app/output/disable-css-module-extension).
42
+
43
+ After setting, all style files except the style files in the `node_modules/` directory and the file name format of `[name].global.(css|scss|sass|less)` will be processed as CSS Modules.
44
+
45
+ If you need global styles at this point, you can solve it by creating a style file with the filename format `[name].global.(css|scss|sass|less)`, for example:
46
+
47
+ ```css title="app.global.css"
48
+ .bg-blue {
49
+ background-color: blue;
50
+ }
51
+ ```
52
+
53
+ ```css title="button.css"
54
+ .redColor {
55
+ color: red;
56
+ }
57
+ ```
58
+
59
+ ```js title="App.jsx"
60
+ import './app.global.css';
61
+ import styles from './button.css';
62
+
63
+ export default function Button() {
64
+ return (
65
+ <button type="button" className={`${styles.redColor} bg-blue`}>
66
+ button
67
+ </button>
68
+ );
69
+ }
70
+ ```
71
+
72
+ Will eventually be compiled as:
73
+
74
+ ```js
75
+ <button type="button" className="button__redColor--JsFYl bg-blue">
76
+ button
77
+ </button>;
78
+ ```
79
+
80
+ The final effect is as follows:
81
+
82
+ ![](https://lf3-static.bytednsdoc.com/obj/eden-cn/aphqeh7uhohpquloj/modern-js/more-css-modules.png)
83
+
84
+ :::tip
85
+ When using [babel-plugin-react-css-modules](https://github.com/gajus/babel-plugin-react-css-modules), it is important to note that the configuration option `generateScopedName` of this plugin needs to be the same as [`output.css ModuleLocalIdentName`](/docs/configure/app/output/css-module-local-ident-name).
86
+ :::
@@ -0,0 +1,17 @@
1
+ ---
2
+ sidebar_position: 4
3
+ ---
4
+
5
+ # Less and Sass
6
+
7
+ [Less](https://lesscss.org/) and [Sass](https://sass-lang.com/) are two commonly used CSS preprocessors that Modern.js built-in support for the Less and Sass compile capabilities.
8
+
9
+ ## Customized Configuration
10
+
11
+ - If you need to customize the configuration of [less-loader](https://github.com/webpack-contrib/less-loader), please refer to the [tools.less](/docs/configure/app/tools/less).
12
+ - If you need to customize the configuration of [sass-loader](https://github.com/webpack-contrib/sass-loader), please refer to the [tools.less](/docs/configure/app/tools/sass).
13
+
14
+
15
+ ::: Tips
16
+ CSS files pre-compiled by Less and Sass will still undergo Modern.js build-in [PostCSS](https://postcss.org/) conversion, which has good browser compatibility. For related content, please refer to [[PostCSS](/docs/guides/basic-features/css/postcss)].
17
+ :::
@@ -0,0 +1,81 @@
1
+ ---
2
+ sidebar_position: 3
3
+ ---
4
+
5
+ # PostCSS
6
+
7
+ [PostCSS](https://postcss.org/) is a tool for converting CSS code with JavaScript tools and plugins. Modern.js built-in PostCSS and integrates common PostCSS plugins such as [Autoprefixer](https://github.com/postcss/autoprefixer) to meet the style development needs of most projects.
8
+
9
+ By default, Modern.js compile and transform CSS as follows:
10
+
11
+ 1. [Autoprefixer](https://github.com/postcss/autoprefixer) Automatically add the required browser vendor prefix to CSS rules according to the required browser range. Modern.js default supported browser ranges are: `['> 0.01%', 'not dead', 'not op_mini all']`.
12
+
13
+ :::info Note
14
+ - [Supported browser range: `> 0.01%`] means that the browser market share is greater than 0.01%.
15
+ - `Not dead` means excluding browsers that are no longer officially supported and browsers that have not been updated in the past 24 months.
16
+ - `not op_mini all` means exclude Opera Mini.
17
+ :::
18
+
19
+
20
+ :::info Additional
21
+ If you need to modify the default browser support range, you can configure `browserslist` in the project's `package.json` file, and set the rule to refer to the use of [Browserslist](https://github.com/browserslist/browserslist). The following is an example:
22
+ ```json title ="package.json"
23
+ {
24
+ "Browserslist": [
25
+ "The last 1 versions",
26
+ "> 1%",
27
+ "IE 10"
28
+ ]
29
+ }
30
+ ```
31
+ :::
32
+
33
+ 2. Provide [CSS custom properties](https://www.w3.org/TR/css-variables-1/) support, you can define and use custom variables in CSS, such as:
34
+
35
+ ```css
36
+ :root {
37
+ --main-bg-color: pink;
38
+ }
39
+
40
+ body {
41
+ background-color: var(--main-bg-color);
42
+ }
43
+ ```
44
+ 3. Provide [CSS Nesting](https://drafts.csswg.org/css-nesting-1/) support, you can use nested writing in CSS, such as:
45
+
46
+ ```css
47
+ table.colortable td {
48
+ text-align: center;
49
+ }
50
+ table.colortable td.c {
51
+ text-transform: uppercase;
52
+ }
53
+ ```
54
+ It can also be rewritten as CSS nested:
55
+ ```css
56
+ table.colortable {
57
+ & td {
58
+ text-align: center;
59
+ &.c { text-transform: uppercase }
60
+ }
61
+ }
62
+ ```
63
+
64
+ 4. Fix known [Flexbugs](https://github.com/philipwalton/flexbugs).
65
+ 5. Provide compatibility with the following CSS features:
66
+ - [`initial` attribute value](https://developer.mozilla.org/en-US/docs/Web/CSS/initial_value)
67
+ - [`break-` attribute](https://developer.mozilla.org/en-US/docs/Web/CSS/break-after)
68
+ - [`font-variant`](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant)
69
+ - [Media Query Ranges](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#syntax_improvements_in_level_4)
70
+
71
+ When you need to modify the PostCSS configuration, you can implement it through the underlying configuration [`tools.postcss`](/docs/configure/app/tools/postcss), here is an example:
72
+
73
+ ```typescript title="modern.config.ts"
74
+ export default defineConfig({
75
+ tools: {
76
+ postcss: {
77
+ plugins: ['autoprefixer', ('postcss-flexbugs-fixes': {})],
78
+ },
79
+ },
80
+ });
81
+ ```
@@ -0,0 +1,95 @@
1
+ ---
2
+ sidebar_position: 2
3
+ ---
4
+
5
+ # Tailwind CSS
6
+
7
+
8
+
9
+ [Tailwind CSS](https://tailwindcss.com/) is a CSS framework and design system based on Utility Class, which can quickly add common styles to components, and support flexible extension of theme styles. To use [Tailwind CSS](https://tailwindcss.com/) in the Modern.js, just execute `pnpm run new` in the project root directory and turn it on.
10
+
11
+ Choose as follows:
12
+
13
+ ```bash
14
+ ? Action: Enable features
15
+ ? Enable features: Enable Tailwind CSS
16
+ ```
17
+
18
+ When using, add the following code to the root component of the entry (such as `src/App.jsx`):
19
+
20
+ ```js
21
+ import 'tailwindcss/base.css';
22
+ import 'tailwindcss/components.css';
23
+ import 'tailwindcss/utilities.css';
24
+ ```
25
+
26
+ You can then use the Utility Class provided by Tailwind CSS in each component.
27
+
28
+ ::: info Additional
29
+ According to different needs, you can optionally import the CSS files provided by Tailwind CSS. Since the use of `@taiwind` is equivalent to directly importing CSS files, you can refer to the content in the annotate in the [`@tailwind` usage](https://tailwindcss.com/docs/functions-and-directives#tailwind) document for the purpose of the CSS files provided by Tailwind CSS.
30
+ :::
31
+
32
+ When you need to customize the [theme](https://tailwindcss.com/docs/theme) configuration of Tailwind CSS, you can modify it in the configuration [`source.designSystem`](/docs/configure/app/source/design-system), for example, add a color theme `primary`:
33
+
34
+ ```typescript title="modern.config.ts"
35
+ export default defineConfig({
36
+ source: {
37
+ designSystem: {
38
+ extend: {
39
+ colors: {
40
+ primary: '#5c6ac4',
41
+ },
42
+ },
43
+ },
44
+ },
45
+ });
46
+ ```
47
+
48
+ When you need special configuration for Tailwind CSS other than [theme](https://tailwindcss.com/docs/theme), you can configure it in [`tools.tailwindcss`](/docs/configure/app/tools/tailwindcss), for example setting `variants`:
49
+
50
+ ```typescript title="modern.config.ts"
51
+ export default defineConfig({
52
+ tools: {
53
+ tailwindcss: {
54
+ variants: {
55
+ extend: {
56
+ backgroundColor: ['active'],
57
+ },
58
+ },
59
+ },
60
+ },
61
+ });
62
+ ```
63
+
64
+ ## Use the [`Twin`](https://github.com/ben-rogerson/twin.macro)
65
+
66
+ In the previous chapter, we introduced what CSS-in-JS is and the CSS-in-JS library [styled-components](https://styled-components.com/) commonly used by the community. This section will explain how to use [Tailwind CSS](https://tailwindcss.com/) in CSS with [`Twin`](https://github.com/ben-rogerson/twin.macro). Using [`Twin`](https://github.com/ben-rogerson/twin.macro) makes it easier to use Tailwind CSS in CSS-in-JS code. [`Twin`](https://github.com/ben-rogerson/twin.macro) for its own description is:
67
+
68
+ > *Twin blends the magic of Tailwind with the flexibility of css-in-js*
69
+
70
+ After enabling the "Tailwind CSS" function, you first need to install the ['Twin'](https://github.com/ben-rogerson/twin.macro) dependency:
71
+
72
+ ``` bash
73
+ pnpm add twin.macro -D
74
+ ```
75
+
76
+ When the project installs the `twin.macro` dependency, Modern.js detects the dependency and adds twin.macro related configuration to the `baby-plugin-macro` of build-in. So after installing the dependency, there is no need for manual configuration. Here is an example of a simple use of twin.macro:
77
+
78
+ ``` js
79
+ import tw from 'twin.macro'
80
+
81
+ const Input = tw.input`border hover:border-black`
82
+ ```
83
+
84
+ :::tip
85
+ If a `MacroError: /project/App.tsx` error occurs during runtime, it may be caused by a lack of `twin.macro` dependency.
86
+ :::
87
+
88
+ For more usage, please refer to the [twin.macro](https://github.com/ben-rogerson/twin.macro/blob/master/docs/index.md).
89
+
90
+ `twin.macro` reads the `tailwindcss.config.js` files in the project directory by default, or reads the Tailwind CSS configuration via the file path specified by [twin.config](https://github.com/ben-rogerson/twin.macro/blob/master/docs/options.md#options) on the `babel-plugin-macro`. However, these additional configurations are not required in the Modern.js.
91
+
92
+ When the Tailwind CSS is configured in the `modern.config.ts` file by [`source.designSystem`](/docs/configure/app/source/design-system) and [`tools.tailwindcss`](/docs/configure/app/tools/tailwindcss), these configurations will also take effect on the `twin.macro`.
93
+
94
+ > When configuring Tailwind CSS for a project, the combination of the two configurations [`source.designSystem`](/docs/configure/app/source/design-system) and [`tools.tailwindcss`](/docs/configure/app/tools/tailwindcss) is equivalent to a separate configuration `tailwindcss.config.js` file.
95
+ > Where [`source.designSystem`](/docs/configure/app/source/design-system) is equivalent to the [`theme`](https://v2.tailwindcss.com/docs/configuration#theme) configuration of Tailwind CSS.
@@ -0,0 +1,66 @@
1
+ ---
2
+ title: Fetch Data
3
+ sidebar_position: 3
4
+ ---
5
+
6
+ Modern.js provides out of the box fetching data capabilities, developers can use these APIs to develop in CSR and SSR environments isomorphic.
7
+
8
+ It should be noted that these APIs do not help applications to initiate requests, but help developers better manage the relationship between data and routing.
9
+
10
+ ## useLoader(Old)
11
+
12
+ **`useLoader`** is an API in Modern.js old version. The API is a React Hook specially provided for SSR applications, allowing developers to fetch data in components.
13
+
14
+ :::tip
15
+ CSR don't need to use `useLoader` to fetch data.
16
+ :::
17
+
18
+ Here is the simplest example:
19
+
20
+ ```tsx
21
+ import { useLoader } from '@modern-js/runtime';
22
+
23
+ export default () => {
24
+ const { data } = useLoader(async () => {
25
+ console.log('fetch in useLoader');
26
+
27
+ // No real request is sent here, just a hard coding data is returned.
28
+ // In a real project, the data obtained from the remote end should be returned.
29
+ return {
30
+ name: 'modern.js',
31
+ };
32
+ });
33
+
34
+ return <div>Hello, {data?.name}</div>;
35
+ };
36
+ ```
37
+
38
+ After the above code starts, visit the page. You can see that the log is printed at terminal, but not at console in browser.
39
+
40
+ This is because Modern.js server-side rendering, the data returned by the `useLoader` is collected and injected into the HTML of the response. If SSR rendering succeeds, the following code snippet can be seen in the HTML:
41
+
42
+ ```html
43
+ <script>
44
+ window._SSR_DATA = {};
45
+ </script>
46
+ ```
47
+
48
+ In this global variable, every piece of data is recorded, and this data will be used first in the process of rendering on the browser side. If the data does not exist, the `useLoader` function will be re-executed.
49
+
50
+ :::note
51
+ During the build phase, Modern.js will automatically generate a Loader ID for each `useLoader` and inject it into the JS bundle of SSR and CSR, which is used to associate Loader and data.
52
+ :::
53
+
54
+ Compared with `getServerSideProps` in the Next.js, get data in advance before rendering. Using `useLoader`, you can get the data required by the local UI in the component without passing the data layer by layer. Similarly, it will not add redundant logic to the outermost data acquisition function because different routes require different data requests. Of course, `useLoader` also has some problems, such as the difficulty of Treeshaking server-level code, and the need for one more pre-render at the server level.
55
+
56
+ Modern.js in the new version, a new Loader solution is designed. The new solution solves these problems and can cooperate with **nested routing** to optimize page performance.
57
+
58
+ :::note
59
+ Detailed APIs can be found at [useLoader](/docs/apis/app/runtime/core/use-loader).
60
+ :::
61
+
62
+ ## Route Loader
63
+
64
+ :::note
65
+ Stay tuned.
66
+ :::