@modern-js/main-doc 2.69.5 → 3.0.0-alpha.0

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 (540) hide show
  1. package/docs/en/{_meta.json → _nav.json} +5 -1
  2. package/docs/en/apis/app/commands.mdx +2 -3
  3. package/docs/en/apis/app/hooks/src/entry.mdx +1 -5
  4. package/docs/en/apis/app/hooks/src/entry.server.mdx +4 -5
  5. package/docs/en/apis/app/hooks/src/routes.mdx +2 -2
  6. package/docs/en/apis/app/runtime/_meta.json +0 -18
  7. package/docs/en/apis/app/runtime/bff/use-hono-context.mdx +2 -2
  8. package/docs/en/apis/app/runtime/router/router.mdx +1 -1
  9. package/docs/en/apis/app/runtime/utility/css-in-js.mdx +3 -2
  10. package/docs/en/community/blog/v2-release-note.mdx +0 -2
  11. package/docs/en/community/contributing-guide.mdx +10 -12
  12. package/docs/en/components/bff-upload.mdx +16 -12
  13. package/docs/en/components/build-output.mdx +45 -0
  14. package/docs/en/components/debug-app.mdx +1 -1
  15. package/docs/en/components/enable-bff-caution.mdx +2 -2
  16. package/docs/en/components/enable-bff.mdx +38 -8
  17. package/docs/en/components/enable-ssg.mdx +48 -0
  18. package/docs/en/components/entry-scan-logic.mdx +7 -0
  19. package/docs/en/components/init-app.mdx +40 -17
  20. package/docs/en/components/international/install-command.mdx +9 -0
  21. package/docs/en/components/international/introduce.mdx +2 -0
  22. package/docs/en/components/module-federation.mdx +4 -4
  23. package/docs/en/components/new-entry-tooltip.mdx +0 -0
  24. package/docs/en/components/nodeVersion.mdx +2 -6
  25. package/docs/en/components/prerequisites.mdx +1 -1
  26. package/docs/en/components/ua-polyfill.mdx +16 -12
  27. package/docs/en/components/upgrade-browserslist.mdx +0 -0
  28. package/docs/en/configure/_meta.json +7 -8
  29. package/docs/en/configure/app/bff/cross-project.mdx +24 -0
  30. package/docs/en/configure/app/dev/lazy-compilation.mdx +45 -0
  31. package/docs/en/configure/app/dev/server.mdx +103 -0
  32. package/docs/en/configure/app/dev/setup-middlewares.mdx +4 -22
  33. package/docs/en/configure/app/html/app-icon.mdx +1 -23
  34. package/docs/en/configure/app/output/inline-scripts.mdx +1 -1
  35. package/docs/en/configure/app/output/override-browserslist.mdx +6 -4
  36. package/docs/en/configure/app/output/source-map.mdx +6 -3
  37. package/docs/en/configure/app/output/ssg.mdx +12 -43
  38. package/docs/en/configure/app/output/ssgByEntries.mdx +93 -0
  39. package/docs/en/configure/app/performance/build-cache.mdx +0 -4
  40. package/docs/en/configure/app/resolve/alias-strategy.mdx +14 -0
  41. package/docs/en/configure/app/resolve/alias.mdx +13 -0
  42. package/docs/en/configure/app/resolve/condition-names.mdx +18 -0
  43. package/docs/en/configure/app/resolve/dedupe.mdx +13 -0
  44. package/docs/en/configure/app/resolve/extensions.mdx +18 -0
  45. package/docs/en/configure/app/runtime/0-intro.mdx +2 -51
  46. package/docs/en/configure/app/security/check-syntax.mdx +1 -1
  47. package/docs/en/configure/app/server/port.mdx +1 -21
  48. package/docs/en/configure/app/server/rsc.mdx +30 -0
  49. package/docs/en/configure/app/server/ssr.mdx +20 -9
  50. package/docs/en/configure/app/source/decorators.mdx +4 -2
  51. package/docs/en/configure/app/source/entries.mdx +0 -2
  52. package/docs/en/configure/app/source/main-entry-name.mdx +4 -4
  53. package/docs/en/configure/app/source/transform-import.mdx +1 -59
  54. package/docs/en/configure/app/tools/bundler-chain.mdx +5 -5
  55. package/docs/en/configure/app/tools/css-extract.mdx +1 -1
  56. package/docs/en/configure/app/tools/dev-server.mdx +14 -248
  57. package/docs/en/configure/app/tools/html-plugin.mdx +3 -3
  58. package/docs/en/configure/app/tools/lightningcss-loader.mdx +0 -1
  59. package/docs/en/configure/app/tools/swc.mdx +1 -43
  60. package/docs/en/configure/app/usage.mdx +7 -17
  61. package/docs/en/guides/_meta.json +1 -2
  62. package/docs/en/guides/advanced-features/_meta.json +6 -0
  63. package/docs/en/guides/advanced-features/bff/cross-project.mdx +1 -7
  64. package/docs/en/guides/advanced-features/bff/extend-server.mdx +18 -3
  65. package/docs/en/guides/advanced-features/bff/frameworks.mdx +1 -1
  66. package/docs/en/guides/advanced-features/bff/function.mdx +2 -6
  67. package/docs/en/guides/advanced-features/bff/sdk.mdx +3 -3
  68. package/docs/en/guides/advanced-features/build-performance.mdx +23 -26
  69. package/docs/en/guides/advanced-features/compatibility.mdx +53 -9
  70. package/docs/en/guides/advanced-features/international/_meta.json +11 -0
  71. package/docs/en/guides/advanced-features/international/advanced.mdx +193 -0
  72. package/docs/en/guides/advanced-features/international/api.mdx +400 -0
  73. package/docs/en/guides/advanced-features/international/basic.mdx +417 -0
  74. package/docs/en/guides/advanced-features/international/best-practices.mdx +135 -0
  75. package/docs/en/guides/advanced-features/international/configuration.mdx +437 -0
  76. package/docs/en/guides/advanced-features/international/locale-detection.mdx +276 -0
  77. package/docs/en/guides/advanced-features/international/quick-start.mdx +154 -0
  78. package/docs/en/guides/advanced-features/international/resource-loading.mdx +417 -0
  79. package/docs/en/guides/advanced-features/international/routing.mdx +212 -0
  80. package/docs/en/guides/advanced-features/international.mdx +37 -0
  81. package/docs/en/guides/advanced-features/low-level.mdx +21 -16
  82. package/docs/en/guides/advanced-features/page-performance/code-split.mdx +4 -4
  83. package/docs/en/guides/advanced-features/page-performance/inline-assets.mdx +4 -4
  84. package/docs/en/guides/advanced-features/page-performance/optimize-bundle.mdx +7 -21
  85. package/docs/en/guides/advanced-features/page-performance/react-compiler.mdx +1 -8
  86. package/docs/en/guides/advanced-features/rspack-start.mdx +2 -22
  87. package/docs/en/guides/advanced-features/server-monitor/logger.mdx +0 -4
  88. package/docs/en/guides/advanced-features/server-monitor/monitors.mdx +62 -34
  89. package/docs/en/guides/advanced-features/web-server.mdx +82 -299
  90. package/docs/en/guides/basic-features/_meta.json +6 -1
  91. package/docs/en/guides/basic-features/css/css-in-js.mdx +46 -11
  92. package/docs/en/guides/basic-features/css/css-modules.mdx +5 -17
  93. package/docs/en/guides/basic-features/css/css.mdx +3 -3
  94. package/docs/en/guides/basic-features/css/tailwindcss.mdx +5 -89
  95. package/docs/en/guides/basic-features/data/data-cache.mdx +5 -1
  96. package/docs/en/guides/basic-features/data/data-fetch.mdx +4 -4
  97. package/docs/en/guides/basic-features/data/data-write.mdx +2 -2
  98. package/docs/en/guides/basic-features/debug/mock.mdx +4 -1
  99. package/docs/en/guides/basic-features/debug/proxy.mdx +0 -8
  100. package/docs/en/guides/basic-features/debug/rsdoctor.mdx +5 -5
  101. package/docs/en/guides/basic-features/deploy.mdx +25 -18
  102. package/docs/en/guides/basic-features/env-vars.mdx +1 -1
  103. package/docs/en/guides/basic-features/html.mdx +1 -1
  104. package/docs/en/guides/basic-features/output-files.mdx +3 -3
  105. package/docs/en/guides/basic-features/render/_meta.json +1 -1
  106. package/docs/en/guides/basic-features/render/before-render.mdx +16 -23
  107. package/docs/en/guides/basic-features/render/overview.mdx +51 -0
  108. package/docs/en/guides/basic-features/render/rsc.mdx +394 -0
  109. package/docs/en/guides/basic-features/render/ssg.mdx +26 -62
  110. package/docs/en/guides/basic-features/render/ssr-cache.mdx +6 -6
  111. package/docs/en/guides/basic-features/render/ssr.mdx +31 -31
  112. package/docs/en/guides/basic-features/render/streaming-ssr.mdx +29 -9
  113. package/docs/en/guides/basic-features/routes/_meta.json +1 -0
  114. package/docs/en/guides/basic-features/routes/config-routes.mdx +427 -0
  115. package/docs/en/guides/basic-features/{routes.mdx → routes/routes.mdx} +7 -110
  116. package/docs/en/guides/basic-features/static-assets/json-files.mdx +21 -3
  117. package/docs/en/guides/basic-features/static-assets.mdx +2 -2
  118. package/docs/en/guides/concept/builder.mdx +24 -9
  119. package/docs/en/guides/concept/entries.mdx +139 -147
  120. package/docs/en/guides/get-started/glossary.mdx +0 -18
  121. package/docs/en/guides/get-started/introduction.mdx +1 -4
  122. package/docs/en/guides/get-started/quick-start.mdx +8 -73
  123. package/docs/en/guides/get-started/tech-stack.mdx +7 -25
  124. package/docs/en/guides/get-started/upgrade.mdx +30 -23
  125. package/docs/en/guides/topic-detail/_meta.json +0 -12
  126. package/docs/en/guides/topic-detail/module-federation/_meta.json +1 -1
  127. package/docs/en/guides/topic-detail/module-federation/application.mdx +16 -15
  128. package/docs/en/guides/topic-detail/module-federation/i18n.mdx +670 -0
  129. package/docs/en/guides/topic-detail/module-federation/introduce.mdx +5 -4
  130. package/docs/en/guides/topic-detail/module-federation/ssr.mdx +50 -2
  131. package/docs/en/guides/topic-detail/module-federation/usage.mdx +10 -30
  132. package/docs/en/guides/troubleshooting/builder.mdx +3 -82
  133. package/docs/en/guides/troubleshooting/cli.mdx +6 -30
  134. package/docs/en/guides/troubleshooting/dependencies.mdx +22 -22
  135. package/docs/en/plugin/cli-plugins/api.mdx +4 -5
  136. package/docs/en/plugin/cli-plugins/migration.mdx +33 -48
  137. package/docs/en/plugin/introduction.mdx +39 -27
  138. package/docs/en/plugin/official/_meta.json +0 -5
  139. package/docs/en/plugin/official/cli-plugins/_meta.json +1 -1
  140. package/docs/en/plugin/official/cli-plugins/plugin-styled-components.mdx +5 -0
  141. package/docs/en/plugin/official/cli-plugins.mdx +0 -2
  142. package/docs/en/plugin/plugin-system.mdx +68 -61
  143. package/docs/en/plugin/runtime-plugins/api.mdx +62 -59
  144. package/docs/en/plugin/runtime-plugins/migration.mdx +29 -20
  145. package/docs/en/tutorials/_meta.json +0 -10
  146. package/docs/en/tutorials/examples/csr-auth.mdx +1 -1
  147. package/docs/en/tutorials/foundations/introduction.mdx +9 -25
  148. package/docs/zh/{_meta.json → _nav.json} +10 -6
  149. package/docs/zh/apis/app/commands.mdx +2 -3
  150. package/docs/zh/apis/app/hooks/src/entry.mdx +1 -5
  151. package/docs/zh/apis/app/hooks/src/entry.server.mdx +4 -5
  152. package/docs/zh/apis/app/hooks/src/routes.mdx +2 -2
  153. package/docs/zh/apis/app/runtime/_meta.json +0 -18
  154. package/docs/zh/apis/app/runtime/bff/use-hono-context.mdx +2 -2
  155. package/docs/zh/apis/app/runtime/utility/css-in-js.mdx +3 -2
  156. package/docs/zh/community/blog/v2-release-note.mdx +0 -2
  157. package/docs/zh/community/contributing-guide.mdx +10 -12
  158. package/docs/zh/components/auto-upgrade.mdx +0 -0
  159. package/docs/zh/components/bff-upload.mdx +8 -5
  160. package/docs/zh/components/build-output.mdx +45 -0
  161. package/docs/zh/components/debug-app.mdx +1 -1
  162. package/docs/zh/components/enable-bff-caution.mdx +1 -1
  163. package/docs/zh/components/enable-bff.mdx +37 -8
  164. package/docs/zh/components/enable-ssg.mdx +47 -0
  165. package/docs/zh/components/entry-scan-logic.mdx +7 -0
  166. package/docs/zh/components/init-app.mdx +40 -18
  167. package/docs/zh/components/international/install-command.mdx +8 -0
  168. package/docs/zh/components/international/introduce.mdx +2 -0
  169. package/docs/zh/components/international/platform-support.mdx +0 -0
  170. package/docs/zh/components/module-federation.mdx +4 -4
  171. package/docs/zh/components/new-entry-tooltip.mdx +0 -0
  172. package/docs/zh/components/nodeVersion.mdx +3 -7
  173. package/docs/zh/components/prerequisites.mdx +1 -1
  174. package/docs/zh/components/self-route-example.mdx +3 -3
  175. package/docs/zh/components/ua-polyfill.mdx +11 -6
  176. package/docs/zh/components/upgrade-browserslist.mdx +0 -0
  177. package/docs/zh/configure/_meta.json +7 -8
  178. package/docs/zh/configure/app/bff/cross-project.mdx +24 -0
  179. package/docs/zh/configure/app/dev/lazy-compilation.mdx +44 -0
  180. package/docs/zh/configure/app/dev/server.mdx +104 -0
  181. package/docs/zh/configure/app/dev/setup-middlewares.mdx +4 -23
  182. package/docs/zh/configure/app/html/app-icon.mdx +1 -23
  183. package/docs/zh/configure/app/output/inline-scripts.mdx +1 -1
  184. package/docs/zh/configure/app/output/override-browserslist.mdx +3 -3
  185. package/docs/zh/configure/app/output/source-map.mdx +10 -3
  186. package/docs/zh/configure/app/output/ssg.mdx +13 -45
  187. package/docs/zh/configure/app/output/ssgByEntries.mdx +94 -0
  188. package/docs/zh/configure/app/performance/build-cache.mdx +0 -4
  189. package/docs/zh/configure/app/resolve/alias-strategy.mdx +14 -0
  190. package/docs/zh/configure/app/resolve/alias.mdx +13 -0
  191. package/docs/zh/configure/app/resolve/condition-names.mdx +18 -0
  192. package/docs/zh/configure/app/resolve/dedupe.mdx +14 -0
  193. package/docs/zh/configure/app/resolve/extensions.mdx +18 -0
  194. package/docs/zh/configure/app/runtime/0-intro.mdx +2 -53
  195. package/docs/zh/configure/app/security/check-syntax.mdx +1 -1
  196. package/docs/zh/configure/app/server/port.mdx +2 -21
  197. package/docs/zh/configure/app/server/rsc.mdx +30 -0
  198. package/docs/zh/configure/app/server/ssr.mdx +21 -11
  199. package/docs/zh/configure/app/source/decorators.mdx +4 -4
  200. package/docs/zh/configure/app/source/entries.mdx +0 -2
  201. package/docs/zh/configure/app/source/main-entry-name.mdx +4 -4
  202. package/docs/zh/configure/app/source/transform-import.mdx +1 -59
  203. package/docs/zh/configure/app/tools/bundler-chain.mdx +6 -6
  204. package/docs/zh/configure/app/tools/css-extract.mdx +1 -1
  205. package/docs/zh/configure/app/tools/dev-server.mdx +14 -248
  206. package/docs/zh/configure/app/tools/html-plugin.mdx +3 -2
  207. package/docs/zh/configure/app/tools/lightningcss-loader.mdx +0 -1
  208. package/docs/zh/configure/app/tools/swc.mdx +1 -43
  209. package/docs/zh/configure/app/usage.mdx +8 -18
  210. package/docs/zh/guides/_meta.json +5 -1
  211. package/docs/zh/guides/advanced-features/_meta.json +6 -1
  212. package/docs/zh/guides/advanced-features/bff/cross-project.mdx +8 -16
  213. package/docs/zh/guides/advanced-features/bff/extend-server.mdx +25 -8
  214. package/docs/zh/guides/advanced-features/bff/frameworks.mdx +1 -1
  215. package/docs/zh/guides/advanced-features/bff/function.mdx +7 -12
  216. package/docs/zh/guides/advanced-features/bff/sdk.mdx +4 -4
  217. package/docs/zh/guides/advanced-features/build-performance.mdx +23 -30
  218. package/docs/zh/guides/advanced-features/compatibility.mdx +44 -0
  219. package/docs/zh/guides/advanced-features/international/_meta.json +11 -0
  220. package/docs/zh/guides/advanced-features/international/advanced.mdx +193 -0
  221. package/docs/zh/guides/advanced-features/international/api.mdx +400 -0
  222. package/docs/zh/guides/advanced-features/international/basic.mdx +416 -0
  223. package/docs/zh/guides/advanced-features/international/best-practices.mdx +135 -0
  224. package/docs/zh/guides/advanced-features/international/configuration.mdx +441 -0
  225. package/docs/zh/guides/advanced-features/international/locale-detection.mdx +304 -0
  226. package/docs/zh/guides/advanced-features/international/quick-start.mdx +149 -0
  227. package/docs/zh/guides/advanced-features/international/resource-loading.mdx +417 -0
  228. package/docs/zh/guides/advanced-features/international/routing.mdx +212 -0
  229. package/docs/zh/guides/advanced-features/international.mdx +36 -0
  230. package/docs/zh/guides/advanced-features/low-level.mdx +21 -16
  231. package/docs/zh/guides/advanced-features/page-performance/code-split.mdx +3 -3
  232. package/docs/zh/guides/advanced-features/page-performance/inline-assets.mdx +4 -4
  233. package/docs/zh/guides/advanced-features/page-performance/optimize-bundle.mdx +7 -21
  234. package/docs/zh/guides/advanced-features/page-performance/react-compiler.mdx +1 -8
  235. package/docs/zh/guides/advanced-features/server-monitor/logger.mdx +0 -4
  236. package/docs/zh/guides/advanced-features/server-monitor/monitors.mdx +63 -35
  237. package/docs/zh/guides/advanced-features/web-server.mdx +79 -300
  238. package/docs/zh/guides/basic-features/_meta.json +6 -1
  239. package/docs/zh/guides/basic-features/css/css-in-js.mdx +40 -5
  240. package/docs/zh/guides/basic-features/css/css-modules.mdx +6 -17
  241. package/docs/zh/guides/basic-features/css/css.mdx +2 -2
  242. package/docs/zh/guides/basic-features/css/tailwindcss.mdx +6 -90
  243. package/docs/zh/guides/basic-features/data/data-cache.mdx +8 -5
  244. package/docs/zh/guides/basic-features/data/data-fetch.mdx +6 -5
  245. package/docs/zh/guides/basic-features/data/data-write.mdx +4 -4
  246. package/docs/zh/guides/basic-features/debug/mock.mdx +4 -1
  247. package/docs/zh/guides/basic-features/debug/proxy.mdx +0 -8
  248. package/docs/zh/guides/basic-features/debug/rsdoctor.mdx +6 -6
  249. package/docs/zh/guides/basic-features/deploy.mdx +24 -20
  250. package/docs/zh/guides/basic-features/env-vars.mdx +1 -1
  251. package/docs/zh/guides/basic-features/html.mdx +2 -2
  252. package/docs/zh/guides/basic-features/output-files.mdx +3 -3
  253. package/docs/zh/guides/basic-features/render/_meta.json +1 -1
  254. package/docs/zh/guides/basic-features/render/before-render.mdx +17 -24
  255. package/docs/zh/guides/basic-features/render/overview.mdx +52 -0
  256. package/docs/zh/guides/basic-features/render/rsc.mdx +413 -0
  257. package/docs/zh/guides/basic-features/render/ssg.mdx +27 -69
  258. package/docs/zh/guides/basic-features/render/ssr-cache.mdx +5 -5
  259. package/docs/zh/guides/basic-features/render/ssr.mdx +34 -31
  260. package/docs/zh/guides/basic-features/render/streaming-ssr.mdx +34 -14
  261. package/docs/zh/guides/basic-features/routes/_meta.json +1 -0
  262. package/docs/zh/guides/basic-features/routes/config-routes.mdx +426 -0
  263. package/docs/zh/guides/basic-features/{routes.mdx → routes/routes.mdx} +8 -114
  264. package/docs/zh/guides/basic-features/static-assets/json-files.mdx +21 -3
  265. package/docs/zh/guides/basic-features/static-assets.mdx +2 -2
  266. package/docs/zh/guides/basic-features/testing/cypress.mdx +5 -5
  267. package/docs/zh/guides/basic-features/testing/jest.mdx +12 -12
  268. package/docs/zh/guides/concept/builder.mdx +24 -9
  269. package/docs/zh/guides/concept/entries.mdx +95 -92
  270. package/docs/zh/guides/get-started/glossary.mdx +0 -18
  271. package/docs/zh/guides/get-started/introduction.mdx +1 -5
  272. package/docs/zh/guides/get-started/quick-start.mdx +5 -72
  273. package/docs/zh/guides/get-started/tech-stack.mdx +8 -26
  274. package/docs/zh/guides/get-started/upgrade.mdx +30 -23
  275. package/docs/zh/guides/topic-detail/_meta.json +0 -12
  276. package/docs/zh/guides/topic-detail/module-federation/_meta.json +1 -1
  277. package/docs/zh/guides/topic-detail/module-federation/application.mdx +18 -16
  278. package/docs/zh/guides/topic-detail/module-federation/i18n.mdx +623 -0
  279. package/docs/zh/guides/topic-detail/module-federation/introduce.mdx +4 -4
  280. package/docs/zh/guides/topic-detail/module-federation/ssr.mdx +51 -5
  281. package/docs/zh/guides/topic-detail/module-federation/usage.mdx +11 -32
  282. package/docs/zh/guides/troubleshooting/builder.mdx +3 -84
  283. package/docs/zh/guides/troubleshooting/cli.mdx +6 -30
  284. package/docs/zh/guides/troubleshooting/dependencies.mdx +23 -23
  285. package/docs/zh/guides/upgrade/_meta.json +1 -0
  286. package/docs/zh/guides/upgrade/config.mdx +809 -0
  287. package/docs/zh/guides/upgrade/entry.mdx +463 -0
  288. package/docs/zh/guides/upgrade/other.md +90 -0
  289. package/docs/zh/guides/upgrade/overview.mdx +36 -0
  290. package/docs/zh/guides/upgrade/tailwindcss.mdx +130 -0
  291. package/docs/zh/guides/upgrade/web-server.md +93 -0
  292. package/docs/zh/plugin/cli-plugins/api.mdx +4 -5
  293. package/docs/zh/plugin/cli-plugins/migration.mdx +30 -45
  294. package/docs/zh/plugin/introduction.mdx +36 -24
  295. package/docs/zh/plugin/official/_meta.json +0 -5
  296. package/docs/zh/plugin/official/cli-plugins/_meta.json +1 -1
  297. package/docs/zh/plugin/official/cli-plugins/plugin-styled-components.mdx +5 -0
  298. package/docs/zh/plugin/official/cli-plugins.mdx +0 -2
  299. package/docs/zh/plugin/plugin-system.mdx +45 -42
  300. package/docs/zh/plugin/runtime-plugins/api.mdx +58 -56
  301. package/docs/zh/plugin/runtime-plugins/migration.mdx +26 -17
  302. package/docs/zh/tutorials/_meta.json +0 -10
  303. package/docs/zh/tutorials/examples/csr-auth.mdx +1 -1
  304. package/docs/zh/tutorials/foundations/introduction.mdx +8 -25
  305. package/i18n.json +0 -16
  306. package/package.json +12 -12
  307. package/rspress.config.ts +5 -8
  308. package/src/components/ContentCard/index.module.scss +11 -7
  309. package/src/components/ContentCard/index.tsx +1 -1
  310. package/src/components/FeatureLayout/index.module.css +1 -1
  311. package/src/components/Footer/index.tsx +2 -14
  312. package/src/components/Footer/styles.module.scss +5 -5
  313. package/src/components/ListCard/index.tsx +1 -1
  314. package/src/components/RandomMemberList/index.tsx +1 -1
  315. package/src/components/RsbuildLink/index.tsx +1 -1
  316. package/src/components/Sandpack/index.tsx +1 -1
  317. package/src/custom.scss +15 -0
  318. package/src/i18n/enUS.ts +2 -4
  319. package/src/i18n/index.ts +1 -1
  320. package/src/i18n/zhCN.ts +2 -4
  321. package/src/index.ts +2 -1
  322. package/src/pages/index.module.scss +59 -41
  323. package/src/pages/index.tsx +9 -24
  324. package/docs/en/apis/app/hooks/server/index_.mdx +0 -10
  325. package/docs/en/apis/app/hooks/src/index_.mdx +0 -38
  326. package/docs/en/apis/app/hooks/src/stories.mdx +0 -16
  327. package/docs/en/apis/app/runtime/app/define-config.mdx +0 -67
  328. package/docs/en/apis/app/runtime/core/bootstrap.mdx +0 -74
  329. package/docs/en/apis/app/runtime/core/create-app.mdx +0 -49
  330. package/docs/en/apis/app/runtime/core/use-loader.mdx +0 -89
  331. package/docs/en/apis/app/runtime/core/use-module-apps.mdx +0 -140
  332. package/docs/en/apis/app/runtime/core/use-runtime-context.mdx +0 -116
  333. package/docs/en/apis/app/runtime/model/Provider.mdx +0 -36
  334. package/docs/en/apis/app/runtime/model/auto-actions.mdx +0 -122
  335. package/docs/en/apis/app/runtime/model/connect.mdx +0 -146
  336. package/docs/en/apis/app/runtime/model/create-app.mdx +0 -75
  337. package/docs/en/apis/app/runtime/model/create-store.mdx +0 -61
  338. package/docs/en/apis/app/runtime/model/handle-effect.mdx +0 -107
  339. package/docs/en/apis/app/runtime/model/model_.mdx +0 -198
  340. package/docs/en/apis/app/runtime/model/use-local-model.mdx +0 -29
  341. package/docs/en/apis/app/runtime/model/use-model.mdx +0 -89
  342. package/docs/en/apis/app/runtime/model/use-static-model.mdx +0 -51
  343. package/docs/en/apis/app/runtime/model/use-store.mdx +0 -26
  344. package/docs/en/apis/app/runtime/ssr/pre-render.mdx +0 -96
  345. package/docs/en/apis/app/runtime/web-server/hook.mdx +0 -134
  346. package/docs/en/apis/app/runtime/web-server/middleware.mdx +0 -113
  347. package/docs/en/apis/app/runtime/web-server/unstable_middleware.mdx +0 -167
  348. package/docs/en/components/bff-proxy-path-rewrite.mdx +0 -16
  349. package/docs/en/components/bff-proxy-principle.mdx +0 -1
  350. package/docs/en/components/builder.mdx +0 -3
  351. package/docs/en/components/create-bff-api-app.mdx +0 -25
  352. package/docs/en/components/custom-router-micro-frontend.mdx +0 -40
  353. package/docs/en/components/enable-micro-frontend.mdx +0 -30
  354. package/docs/en/components/enableSwc.mdx +0 -17
  355. package/docs/en/components/global-proxy-config.mdx +0 -85
  356. package/docs/en/components/global-proxy.mdx +0 -29
  357. package/docs/en/components/package-manager.mdx +0 -11
  358. package/docs/en/components/reduck-notify.mdx +0 -27
  359. package/docs/en/components/reduck-tip.mdx +0 -8
  360. package/docs/en/configure/app/auto-load-plugin.mdx +0 -66
  361. package/docs/en/configure/app/deploy/microFrontend.mdx +0 -53
  362. package/docs/en/configure/app/dev/port.mdx +0 -25
  363. package/docs/en/configure/app/dev/proxy.mdx +0 -9
  364. package/docs/en/configure/app/experiments/lazy-compilation.mdx +0 -106
  365. package/docs/en/configure/app/html/disable-html-folder.mdx +0 -46
  366. package/docs/en/configure/app/html/favicon-by-entries.mdx +0 -36
  367. package/docs/en/configure/app/html/inject-by-entries.mdx +0 -36
  368. package/docs/en/configure/app/html/meta-by-entries.mdx +0 -48
  369. package/docs/en/configure/app/html/tags-by-entries.mdx +0 -44
  370. package/docs/en/configure/app/html/template-by-entries.mdx +0 -33
  371. package/docs/en/configure/app/html/template-parameters-by-entries.mdx +0 -35
  372. package/docs/en/configure/app/html/title-by-entries.mdx +0 -37
  373. package/docs/en/configure/app/output/css-module-local-ident-name.mdx +0 -21
  374. package/docs/en/configure/app/output/disable-css-extract.mdx +0 -16
  375. package/docs/en/configure/app/output/disable-filename-hash.mdx +0 -16
  376. package/docs/en/configure/app/output/disable-minimize.mdx +0 -14
  377. package/docs/en/configure/app/output/disable-node-polyfill.mdx +0 -22
  378. package/docs/en/configure/app/output/disable-source-map.mdx +0 -31
  379. package/docs/en/configure/app/output/enable-asset-fallback.mdx +0 -36
  380. package/docs/en/configure/app/output/enable-inline-scripts.mdx +0 -22
  381. package/docs/en/configure/app/output/enable-inline-styles.mdx +0 -22
  382. package/docs/en/configure/app/output/enable-latest-decorators.mdx +0 -14
  383. package/docs/en/configure/app/performance/transform-lodash.mdx +0 -52
  384. package/docs/en/configure/app/runtime/master-app.mdx +0 -36
  385. package/docs/en/configure/app/runtime/state.mdx +0 -52
  386. package/docs/en/configure/app/source/disable-entry-dirs.mdx +0 -38
  387. package/docs/en/configure/app/source/enable-custom-entry.mdx +0 -68
  388. package/docs/en/configure/app/source/module-scopes.mdx +0 -72
  389. package/docs/en/configure/app/source/resolve-extension-prefix.mdx +0 -55
  390. package/docs/en/configure/app/source/resolve-main-fields.mdx +0 -46
  391. package/docs/en/configure/app/tools/esbuild.mdx +0 -44
  392. package/docs/en/configure/app/tools/pug.mdx +0 -54
  393. package/docs/en/configure/app/tools/styled-components.mdx +0 -55
  394. package/docs/en/configure/app/tools/tailwindcss.mdx +0 -98
  395. package/docs/en/configure/app/tools/terser.mdx +0 -58
  396. package/docs/en/configure/app/tools/ts-loader.mdx +0 -76
  397. package/docs/en/configure/app/tools/webpack-chain.mdx +0 -249
  398. package/docs/en/configure/app/tools/webpack.mdx +0 -305
  399. package/docs/en/guides/deprecated.md +0 -17
  400. package/docs/en/guides/topic-detail/micro-frontend/c01-introduction.mdx +0 -27
  401. package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +0 -290
  402. package/docs/en/guides/topic-detail/micro-frontend/c03-main-app.mdx +0 -298
  403. package/docs/en/guides/topic-detail/micro-frontend/c04-communicate.mdx +0 -58
  404. package/docs/en/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +0 -26
  405. package/docs/en/guides/topic-detail/model/_meta.json +0 -14
  406. package/docs/en/guides/topic-detail/model/auto-actions.mdx +0 -85
  407. package/docs/en/guides/topic-detail/model/computed-state.mdx +0 -148
  408. package/docs/en/guides/topic-detail/model/define-model.mdx +0 -62
  409. package/docs/en/guides/topic-detail/model/faq.mdx +0 -35
  410. package/docs/en/guides/topic-detail/model/manage-effects.mdx +0 -247
  411. package/docs/en/guides/topic-detail/model/model-communicate.mdx +0 -217
  412. package/docs/en/guides/topic-detail/model/performance.mdx +0 -167
  413. package/docs/en/guides/topic-detail/model/quick-start.mdx +0 -117
  414. package/docs/en/guides/topic-detail/model/redux-integration.mdx +0 -20
  415. package/docs/en/guides/topic-detail/model/typescript-best-practice.mdx +0 -68
  416. package/docs/en/guides/topic-detail/model/use-model.mdx +0 -243
  417. package/docs/en/guides/topic-detail/model/use-out-of-modernjs.mdx +0 -46
  418. package/docs/en/plugin/official/cli-plugins/plugin-swc.mdx +0 -363
  419. package/docs/en/plugin/official/cli-plugins/plugin-tailwind.mdx +0 -5
  420. package/docs/en/plugin/official/rsbuild-plugins/_meta.json +0 -1
  421. package/docs/en/plugin/official/rsbuild-plugins/plugin-esbuild.mdx +0 -205
  422. package/docs/en/plugin/official/rsbuild-plugins.mdx +0 -3
  423. package/docs/en/tutorials/first-app/c01-start.mdx +0 -99
  424. package/docs/en/tutorials/first-app/c02-component.mdx +0 -60
  425. package/docs/en/tutorials/first-app/c03-css.mdx +0 -324
  426. package/docs/en/tutorials/first-app/c04-routes.mdx +0 -172
  427. package/docs/en/tutorials/first-app/c05-loader.mdx +0 -87
  428. package/docs/en/tutorials/first-app/c06-model.mdx +0 -278
  429. package/docs/en/tutorials/first-app/c07-container.mdx +0 -281
  430. package/docs/en/tutorials/first-app/c08-entries.mdx +0 -135
  431. package/docs/zh/apis/app/hooks/server/index_.mdx +0 -10
  432. package/docs/zh/apis/app/hooks/src/index_.mdx +0 -39
  433. package/docs/zh/apis/app/hooks/src/stories.mdx +0 -16
  434. package/docs/zh/apis/app/runtime/app/define-config.mdx +0 -67
  435. package/docs/zh/apis/app/runtime/core/bootstrap.mdx +0 -74
  436. package/docs/zh/apis/app/runtime/core/create-app.mdx +0 -35
  437. package/docs/zh/apis/app/runtime/core/use-loader.mdx +0 -89
  438. package/docs/zh/apis/app/runtime/core/use-module-apps.mdx +0 -179
  439. package/docs/zh/apis/app/runtime/core/use-runtime-context.mdx +0 -116
  440. package/docs/zh/apis/app/runtime/model/Provider.mdx +0 -36
  441. package/docs/zh/apis/app/runtime/model/auto-actions.mdx +0 -122
  442. package/docs/zh/apis/app/runtime/model/connect.mdx +0 -143
  443. package/docs/zh/apis/app/runtime/model/create-app.mdx +0 -75
  444. package/docs/zh/apis/app/runtime/model/create-store.mdx +0 -61
  445. package/docs/zh/apis/app/runtime/model/handle-effect.mdx +0 -108
  446. package/docs/zh/apis/app/runtime/model/model_.mdx +0 -201
  447. package/docs/zh/apis/app/runtime/model/use-local-model.mdx +0 -29
  448. package/docs/zh/apis/app/runtime/model/use-model.mdx +0 -89
  449. package/docs/zh/apis/app/runtime/model/use-static-model.mdx +0 -49
  450. package/docs/zh/apis/app/runtime/model/use-store.mdx +0 -26
  451. package/docs/zh/apis/app/runtime/ssr/pre-render.mdx +0 -96
  452. package/docs/zh/apis/app/runtime/web-server/hook.mdx +0 -136
  453. package/docs/zh/apis/app/runtime/web-server/middleware.mdx +0 -114
  454. package/docs/zh/apis/app/runtime/web-server/unstable_middleware.mdx +0 -165
  455. package/docs/zh/components/bff-proxy-path-rewrite.mdx +0 -16
  456. package/docs/zh/components/bff-proxy-principle.mdx +0 -1
  457. package/docs/zh/components/builder.mdx +0 -3
  458. package/docs/zh/components/create-bff-api-app.mdx +0 -25
  459. package/docs/zh/components/custom-router-micro-frontend.mdx +0 -40
  460. package/docs/zh/components/enable-micro-frontend.mdx +0 -30
  461. package/docs/zh/components/enableSwc.mdx +0 -17
  462. package/docs/zh/components/global-proxy-config.mdx +0 -85
  463. package/docs/zh/components/global-proxy.mdx +0 -29
  464. package/docs/zh/components/package-manager.mdx +0 -11
  465. package/docs/zh/components/reduck-notify.mdx +0 -27
  466. package/docs/zh/components/reduck-tip.mdx +0 -8
  467. package/docs/zh/configure/app/auto-load-plugin.mdx +0 -66
  468. package/docs/zh/configure/app/deploy/microFrontend.mdx +0 -55
  469. package/docs/zh/configure/app/dev/port.mdx +0 -25
  470. package/docs/zh/configure/app/dev/proxy.mdx +0 -9
  471. package/docs/zh/configure/app/experiments/lazy-compilation.mdx +0 -105
  472. package/docs/zh/configure/app/html/disable-html-folder.mdx +0 -45
  473. package/docs/zh/configure/app/html/favicon-by-entries.mdx +0 -37
  474. package/docs/zh/configure/app/html/inject-by-entries.mdx +0 -37
  475. package/docs/zh/configure/app/html/meta-by-entries.mdx +0 -48
  476. package/docs/zh/configure/app/html/tags-by-entries.mdx +0 -44
  477. package/docs/zh/configure/app/html/template-by-entries.mdx +0 -33
  478. package/docs/zh/configure/app/html/template-parameters-by-entries.mdx +0 -36
  479. package/docs/zh/configure/app/html/title-by-entries.mdx +0 -37
  480. package/docs/zh/configure/app/output/css-module-local-ident-name.mdx +0 -21
  481. package/docs/zh/configure/app/output/disable-css-extract.mdx +0 -16
  482. package/docs/zh/configure/app/output/disable-filename-hash.mdx +0 -16
  483. package/docs/zh/configure/app/output/disable-minimize.mdx +0 -14
  484. package/docs/zh/configure/app/output/disable-node-polyfill.mdx +0 -22
  485. package/docs/zh/configure/app/output/disable-source-map.mdx +0 -31
  486. package/docs/zh/configure/app/output/enable-asset-fallback.mdx +0 -36
  487. package/docs/zh/configure/app/output/enable-inline-scripts.mdx +0 -22
  488. package/docs/zh/configure/app/output/enable-inline-styles.mdx +0 -22
  489. package/docs/zh/configure/app/output/enable-latest-decorators.mdx +0 -14
  490. package/docs/zh/configure/app/performance/transform-lodash.mdx +0 -52
  491. package/docs/zh/configure/app/runtime/master-app.mdx +0 -38
  492. package/docs/zh/configure/app/runtime/state.mdx +0 -52
  493. package/docs/zh/configure/app/source/disable-entry-dirs.mdx +0 -38
  494. package/docs/zh/configure/app/source/enable-custom-entry.mdx +0 -67
  495. package/docs/zh/configure/app/source/module-scopes.mdx +0 -72
  496. package/docs/zh/configure/app/source/resolve-extension-prefix.mdx +0 -57
  497. package/docs/zh/configure/app/source/resolve-main-fields.mdx +0 -46
  498. package/docs/zh/configure/app/tools/esbuild.mdx +0 -44
  499. package/docs/zh/configure/app/tools/pug.mdx +0 -54
  500. package/docs/zh/configure/app/tools/styled-components.mdx +0 -54
  501. package/docs/zh/configure/app/tools/tailwindcss.mdx +0 -98
  502. package/docs/zh/configure/app/tools/terser.mdx +0 -58
  503. package/docs/zh/configure/app/tools/ts-loader.mdx +0 -76
  504. package/docs/zh/configure/app/tools/webpack-chain.mdx +0 -253
  505. package/docs/zh/configure/app/tools/webpack.mdx +0 -305
  506. package/docs/zh/guides/advanced-features/rspack-start.mdx +0 -154
  507. package/docs/zh/guides/deprecated.md +0 -19
  508. package/docs/zh/guides/topic-detail/micro-frontend/c01-introduction.mdx +0 -26
  509. package/docs/zh/guides/topic-detail/micro-frontend/c02-development.mdx +0 -332
  510. package/docs/zh/guides/topic-detail/micro-frontend/c03-main-app.mdx +0 -296
  511. package/docs/zh/guides/topic-detail/micro-frontend/c04-communicate.mdx +0 -58
  512. package/docs/zh/guides/topic-detail/micro-frontend/c05-mixed-stack.mdx +0 -27
  513. package/docs/zh/guides/topic-detail/model/_meta.json +0 -14
  514. package/docs/zh/guides/topic-detail/model/auto-actions.mdx +0 -88
  515. package/docs/zh/guides/topic-detail/model/computed-state.mdx +0 -147
  516. package/docs/zh/guides/topic-detail/model/define-model.mdx +0 -63
  517. package/docs/zh/guides/topic-detail/model/faq.mdx +0 -36
  518. package/docs/zh/guides/topic-detail/model/manage-effects.mdx +0 -256
  519. package/docs/zh/guides/topic-detail/model/model-communicate.mdx +0 -217
  520. package/docs/zh/guides/topic-detail/model/performance.mdx +0 -167
  521. package/docs/zh/guides/topic-detail/model/quick-start.mdx +0 -117
  522. package/docs/zh/guides/topic-detail/model/redux-integration.mdx +0 -20
  523. package/docs/zh/guides/topic-detail/model/typescript-best-practice.mdx +0 -67
  524. package/docs/zh/guides/topic-detail/model/use-model.mdx +0 -248
  525. package/docs/zh/guides/topic-detail/model/use-out-of-modernjs.mdx +0 -46
  526. package/docs/zh/plugin/official/cli-plugins/plugin-swc.mdx +0 -351
  527. package/docs/zh/plugin/official/cli-plugins/plugin-tailwind.mdx +0 -5
  528. package/docs/zh/plugin/official/rsbuild-plugins/_meta.json +0 -1
  529. package/docs/zh/plugin/official/rsbuild-plugins/plugin-esbuild.mdx +0 -201
  530. package/docs/zh/plugin/official/rsbuild-plugins.mdx +0 -3
  531. package/docs/zh/tutorials/first-app/c01-start.mdx +0 -99
  532. package/docs/zh/tutorials/first-app/c02-component.mdx +0 -60
  533. package/docs/zh/tutorials/first-app/c03-css.mdx +0 -323
  534. package/docs/zh/tutorials/first-app/c04-routes.mdx +0 -172
  535. package/docs/zh/tutorials/first-app/c05-loader.mdx +0 -89
  536. package/docs/zh/tutorials/first-app/c06-model.mdx +0 -274
  537. package/docs/zh/tutorials/first-app/c07-container.mdx +0 -281
  538. package/docs/zh/tutorials/first-app/c08-entries.mdx +0 -135
  539. /package/docs/en/components/{reduck-migration.mdx → auto-upgrade.mdx} +0 -0
  540. /package/docs/{zh/components/reduck-migration.mdx → en/components/international/platform-support.mdx} +0 -0
@@ -0,0 +1,670 @@
1
+ # Integrating Internationalization
2
+
3
+ Modern.js provides the **@modern-js/plugin-i18n** plugin to support internationalization. When using Module Federation, you need to provide corresponding i18n integration solutions for different scenarios (components or applications).
4
+
5
+ ## Prerequisites
6
+
7
+ Before you begin, make sure you have:
8
+
9
+ - Understood [Module Federation Basic Usage](/guides/topic-detail/module-federation/usage)
10
+ - Understood [Basic Usage of the Internationalization Plugin](/guides/advanced-features/international/quick-start)
11
+ - Created producer and consumer applications
12
+
13
+ ## Solution Overview
14
+
15
+ In Module Federation scenarios, producers and consumers need to share or independently manage i18n instances. Based on different use cases, we provide two solutions:
16
+
17
+ 1. **Shared I18n Instance**: Producers and consumers use the same i18n instance, and language switching will be synchronized
18
+ 2. **Independent I18n Instance**: Producers and consumers maintain their own independent i18n instances and can switch languages independently
19
+
20
+ :::tip
21
+
22
+ For component scenarios, we recommend using a shared I18n instance, because components are ultimately rendered on the same React tree, and sharing an instance ensures consistency in language switching.
23
+
24
+ :::
25
+
26
+ :::info
27
+
28
+ For detailed usage of the i18n plugin, please refer to the [Internationalization Documentation](/guides/advanced-features/international/quick-start).
29
+
30
+ :::
31
+
32
+ ## Enabling I18n Capability
33
+
34
+ Both producers and consumers need to enable i18n capability first.
35
+
36
+ ### Install Dependencies
37
+
38
+ In Module Federation scenarios, you need to install both the i18n plugin and the Module Federation plugin:
39
+
40
+ ```bash
41
+ pnpm add i18next react-i18next @modern-js/plugin-i18n @module-federation/modern-js
42
+ ```
43
+
44
+ :::info
45
+
46
+ `i18next` and `react-i18next` are peer dependencies and need to be installed manually.
47
+
48
+ :::
49
+
50
+ ### Configure Plugins
51
+
52
+ Configure both the i18n plugin and the Module Federation plugin in `modern.config.ts`:
53
+
54
+ ```ts title="modern.config.ts"
55
+ import { appTools, defineConfig } from '@modern-js/app-tools';
56
+ import { i18nPlugin } from '@modern-js/plugin-i18n';
57
+ import { moduleFederationPlugin } from '@module-federation/modern-js';
58
+
59
+ export default defineConfig({
60
+ plugins: [appTools(), i18nPlugin(), moduleFederationPlugin()],
61
+ });
62
+ ```
63
+
64
+ :::info
65
+
66
+ For detailed configuration options of the i18n plugin, please refer to the [Configuration Documentation](/guides/advanced-features/international/configuration).
67
+
68
+ :::
69
+
70
+ ## Scenario 1: Producer - Component
71
+
72
+ When the producer exports component-level modules, you can use the following two solutions to integrate i18n.
73
+
74
+ ### Shared I18n Instance (Recommended)
75
+
76
+ For component scenarios, producers and consumers are ultimately on the same React tree, so you only need to share the `i18next` and `react-i18next` dependencies.
77
+
78
+ :::note
79
+
80
+ Both producers and consumers need to configure `shared` in `module-federation.config.ts` to ensure that `i18next` and `react-i18next` use singleton mode.
81
+
82
+ :::
83
+
84
+ #### Configure Module Federation
85
+
86
+ ```ts title="module-federation.config.ts"
87
+ import { createModuleFederationConfig } from '@module-federation/modern-js';
88
+
89
+ export default createModuleFederationConfig({
90
+ // The name parameter must be unique and cannot be the same as other applications (including different remotes)
91
+ name: 'i18nComponentProvider',
92
+ filename: 'remoteEntry.js',
93
+ exposes: {
94
+ './Text': './src/components/Text.tsx',
95
+ },
96
+ shared: {
97
+ react: { singleton: true },
98
+ 'react-dom': { singleton: true },
99
+ 'react-i18next': {
100
+ singleton: true,
101
+ },
102
+ i18next: {
103
+ singleton: true,
104
+ },
105
+ },
106
+ });
107
+ ```
108
+
109
+ #### Using Translation
110
+
111
+ Use the `useTranslation` hook from `react-i18next` in components to perform translation:
112
+
113
+ ```tsx title="src/components/Text.tsx"
114
+ import { useTranslation } from 'react-i18next';
115
+
116
+ export default () => {
117
+ const { t } = useTranslation();
118
+ return (
119
+ <div>
120
+ <p>{t('about')}</p>
121
+ </div>
122
+ );
123
+ };
124
+ ```
125
+
126
+ When using a shared instance, remote components will use the consumer's i18n instance, and when the main application switches languages, the corresponding remote components will automatically update.
127
+
128
+ ### Independent I18n Instance
129
+
130
+ If the producer needs to maintain its own I18n instance (for example, it needs independent language resources or language switching logic), you can avoid configuring `shared` for `i18next` and `react-i18next`, but you need to:
131
+
132
+ 1. Create an independent i18n instance
133
+ 2. Wrap the exported component with `I18nextProvider`
134
+ 3. Export a language switching Hook for consumers to use
135
+
136
+ #### Create an Independent I18n Instance
137
+
138
+ ```ts title="src/i18n.ts"
139
+ import originalI18next from 'i18next';
140
+
141
+ const i18next = originalI18next.createInstance();
142
+
143
+ i18next.init({
144
+ lng: 'en',
145
+ fallbackLng: 'en',
146
+ resources: {
147
+ en: {
148
+ translation: {
149
+ key: 'Hello World(provider)',
150
+ about: 'About(provider)',
151
+ },
152
+ },
153
+ zh: {
154
+ translation: {
155
+ key: '你好,世界(provider)',
156
+ about: '关于(provider)',
157
+ },
158
+ },
159
+ },
160
+ });
161
+
162
+ export default i18next;
163
+ ```
164
+
165
+ #### Wrap Component with I18nextProvider
166
+
167
+ ```tsx title="src/components/Text.tsx"
168
+ import { I18nextProvider, useTranslation } from 'react-i18next';
169
+ import i18next from '../i18n';
170
+
171
+ const Text = () => {
172
+ const { t } = useTranslation();
173
+ return <p>{t('about')}</p>;
174
+ };
175
+
176
+ export default () => {
177
+ return (
178
+ <I18nextProvider i18n={i18next}>
179
+ <Text />
180
+ </I18nextProvider>
181
+ );
182
+ };
183
+ ```
184
+
185
+ #### Export Language Switching Hook
186
+
187
+ Export a `changeLanguage` hook that allows consumers to switch the language of the corresponding producer:
188
+
189
+ ```ts title="src/hooks/useSwitchLanguage.ts"
190
+ import i18next from '../i18n';
191
+
192
+ const useSwitchLanguage = () => {
193
+ return (languageId: string) => i18next.changeLanguage(languageId);
194
+ };
195
+
196
+ export default useSwitchLanguage;
197
+ ```
198
+
199
+ :::note
200
+ When using an independent I18n instance, the producer maintains its own language state. Consumers need to manually call the language switching hook to synchronize language changes between the main application and the remote component. This approach is useful when the producer needs to maintain its own language resources or has independent language switching logic.
201
+ :::
202
+
203
+ #### Configure Module Federation
204
+
205
+ ```ts title="module-federation.config.ts"
206
+ import { createModuleFederationConfig } from '@module-federation/modern-js';
207
+
208
+ export default createModuleFederationConfig({
209
+ // The name parameter must be unique and cannot be the same as other applications (including different remotes)
210
+ name: 'i18nComponentProvider',
211
+ filename: 'remoteEntry.js',
212
+ exposes: {
213
+ './Text': './src/components/Text.tsx',
214
+ './hooks/useSwitchLanguage': './src/hooks/useSwitchLanguage',
215
+ },
216
+ shared: {
217
+ react: { singleton: true },
218
+ 'react-dom': { singleton: true },
219
+ },
220
+ });
221
+ ```
222
+
223
+ ## Scenario 2: Consumer - Component
224
+
225
+ When consumers need to load remote components, they need to configure accordingly based on the solution used by the producer.
226
+
227
+ ### Configure Module Federation
228
+
229
+ First, configure the remote module in the consumer's `module-federation.config.ts`:
230
+
231
+ ```ts title="module-federation.config.ts"
232
+ import { createModuleFederationConfig } from '@module-federation/modern-js';
233
+
234
+ export default createModuleFederationConfig({
235
+ // The name parameter must be unique and cannot be the same as other applications (including different remotes)
236
+ name: 'consumer',
237
+ remotes: {
238
+ componentRemote:
239
+ 'i18nComponentProvider@http://localhost:3006/mf-manifest.json',
240
+ },
241
+ shared: {
242
+ react: { singleton: true },
243
+ 'react-dom': { singleton: true },
244
+ 'react-i18next': { singleton: true },
245
+ i18next: { singleton: true },
246
+ },
247
+ });
248
+ ```
249
+
250
+ :::note
251
+
252
+ If the producer uses a shared I18n instance, the consumer must configure `shared` for `i18next` and `react-i18next`. If the producer uses an independent instance, there is no need to configure `shared` for these two dependencies.
253
+
254
+ :::
255
+
256
+ ### Shared I18n Instance
257
+
258
+ When the producer uses a shared I18n instance, the consumer can directly load the remote component without additional configuration:
259
+
260
+ ```tsx title="src/routes/page.tsx"
261
+ import { createLazyComponent } from '@module-federation/modern-js/react';
262
+ import { getInstance } from '@module-federation/modern-js/runtime';
263
+
264
+ const RemoteComponent = createLazyComponent({
265
+ instance: getInstance(),
266
+ loader: () => import('componentRemote/Text'),
267
+ loading: 'loading...',
268
+ export: 'default',
269
+ });
270
+
271
+ export default () => {
272
+ return (
273
+ <div>
274
+ <RemoteComponent />
275
+ </div>
276
+ );
277
+ };
278
+ ```
279
+
280
+ The i18n resources and i18n instance used here are from the main application. When the main application switches languages, the corresponding remote components will automatically update.
281
+
282
+ ### Independent I18n Instance
283
+
284
+ When the producer uses an independent I18n instance, the consumer needs to handle the language switching logic for both the main application and the remote component:
285
+
286
+ ```tsx title="src/routes/layout.tsx"
287
+ import { useModernI18n } from '@modern-js/plugin-i18n/runtime';
288
+ import { Outlet } from '@modern-js/runtime/router';
289
+ import useSwitchComponentLanguage from 'componentRemote/hooks/useSwitchLanguage';
290
+
291
+ export default function Layout() {
292
+ const { changeLanguage } = useModernI18n();
293
+ const switchComponentLanguage = useSwitchComponentLanguage();
294
+
295
+ const handleSwitchLanguage = (language: string) => {
296
+ // Switch language for the main application
297
+ changeLanguage(language);
298
+ // Switch language for the remote component with independent instance
299
+ switchComponentLanguage(language);
300
+ };
301
+
302
+ return (
303
+ <div>
304
+ <div>
305
+ <button onClick={() => handleSwitchLanguage('zh')}>zh</button>
306
+ <button onClick={() => handleSwitchLanguage('en')}>en</button>
307
+ </div>
308
+ <Outlet />
309
+ </div>
310
+ );
311
+ }
312
+ ```
313
+
314
+ :::info
315
+
316
+ For detailed API documentation of the `useModernI18n` Hook, please refer to the [API Reference Documentation](/guides/advanced-features/international/api).
317
+
318
+ :::
319
+
320
+ :::note
321
+
322
+ When using an independent I18n instance:
323
+
324
+ - The producer and consumer maintain separate language states
325
+ - Language switching must be synchronized manually by calling both the main application's `changeLanguage` and the remote component's language switching hook
326
+ - This approach is recommended when the producer needs independent language resources or custom language switching logic
327
+ - For component scenarios, we generally recommend using a shared I18n instance for better consistency
328
+
329
+ :::
330
+
331
+ ## Scenario 3: Producer - Application
332
+
333
+ When the producer exports application-level modules, you need to use the Bridge API to export the application. For detailed information about application-level modules, please refer to [Application-Level Modules](/guides/topic-detail/module-federation/application).
334
+
335
+ :::warning
336
+
337
+ Producers do not support enabling path redirection (`localePathRedirect`). Route and language switching need to be managed uniformly in the consumer.
338
+
339
+ :::
340
+
341
+ :::info
342
+
343
+ For detailed information about routing integration, please refer to the [Routing Integration Documentation](/guides/advanced-features/international/routing).
344
+
345
+ :::
346
+
347
+ ### Export Application
348
+
349
+ First, you need to create an entry file to export the application:
350
+
351
+ ```tsx title="src/export-app.tsx"
352
+ import '@modern-js/runtime/registry/index';
353
+ import { render } from '@modern-js/runtime/browser';
354
+ import { createRoot } from '@modern-js/runtime/react';
355
+ import { createBridgeComponent } from '@module-federation/modern-js/react-v19';
356
+ import type { ReactElement } from 'react';
357
+
358
+ const ModernRoot = createRoot();
359
+
360
+ export const provider = createBridgeComponent({
361
+ rootComponent: ModernRoot,
362
+ render: (Component, dom) =>
363
+ render(Component as ReactElement<{ basename: string }>, dom),
364
+ });
365
+
366
+ export default provider;
367
+ ```
368
+
369
+ ### Shared I18n Instance
370
+
371
+ #### Configure Module Federation
372
+
373
+ ```ts title="module-federation.config.ts"
374
+ import { createModuleFederationConfig } from '@module-federation/modern-js';
375
+
376
+ export default createModuleFederationConfig({
377
+ // The name parameter must be unique and cannot be the same as other applications (including different remotes)
378
+ name: 'i18nAppProvider',
379
+ filename: 'remoteEntry.js',
380
+ exposes: {
381
+ './export-app': './src/export-app.tsx',
382
+ },
383
+ shared: {
384
+ react: { singleton: true },
385
+ 'react-dom': { singleton: true },
386
+ 'react-i18next': { singleton: true },
387
+ i18next: { singleton: true },
388
+ },
389
+ });
390
+ ```
391
+
392
+ #### Configure Runtime to Use Shared Instance
393
+
394
+ Configure the use of a shared i18n instance in `modern.runtime.tsx`:
395
+
396
+ ```ts title="modern.runtime.tsx"
397
+ import { defineRuntimeConfig } from '@modern-js/runtime';
398
+ import i18next from 'i18next';
399
+
400
+ if (!i18next.isInitialized) {
401
+ i18next.init({
402
+ fallbackLng: 'en',
403
+ resources: {
404
+ en: {
405
+ translation: {
406
+ key: 'Hello World(provider)',
407
+ about: 'About(provider)',
408
+ },
409
+ },
410
+ zh: {
411
+ translation: {
412
+ key: '你好,世界(provider)',
413
+ about: '关于(provider)',
414
+ },
415
+ },
416
+ },
417
+ });
418
+ }
419
+
420
+ export default defineRuntimeConfig({
421
+ i18n: {
422
+ i18nInstance: i18next,
423
+ },
424
+ });
425
+ ```
426
+
427
+ :::note
428
+
429
+ When using a shared instance, `i18next` here does not need to call `init`. You can directly use the default exported i18next instance initialized by the consumer.
430
+
431
+ :::
432
+
433
+ :::tip
434
+
435
+ For applications with multiple entries, `defineRuntimeConfig` can accept a function that receives the `entryName` parameter, allowing you to return different configurations for different entries:
436
+
437
+ ```ts title="modern.runtime.tsx"
438
+ import { defineRuntimeConfig } from '@modern-js/runtime';
439
+ import i18nextCustom from './custom/i18n';
440
+ import i18nextMfAppProvider from './i18n-mf-app-provider/i18n';
441
+
442
+ export default defineRuntimeConfig((entryName: string) => {
443
+ return {
444
+ i18n: {
445
+ i18nInstance:
446
+ entryName === 'custom' ? i18nextCustom : i18nextMfAppProvider,
447
+ },
448
+ };
449
+ });
450
+ ```
451
+
452
+ This is useful when you need different i18n instances for different entry points.
453
+
454
+ :::
455
+
456
+ :::info
457
+
458
+ For detailed information about the `i18nInstance` configuration, please refer to the [Configuration Documentation](/guides/advanced-features/international/configuration#i18ninstance-配置).
459
+
460
+ :::
461
+
462
+ ### Independent I18n Instance (Recommended)
463
+
464
+ For an independent I18n instance, no additional operations are needed. The producer will use its own i18n instance. The i18n plugin will automatically initialize the i18n instance.
465
+
466
+ ## Scenario 4: Consumer - Application
467
+
468
+ When consumers need to load remote applications, they need to use the Bridge API to load application-level modules.
469
+
470
+ ### Configure Module Federation
471
+
472
+ First, configure the remote application in the consumer's `module-federation.config.ts`:
473
+
474
+ ```ts title="module-federation.config.ts"
475
+ import { createModuleFederationConfig } from '@module-federation/modern-js';
476
+
477
+ export default createModuleFederationConfig({
478
+ // The name parameter must be unique and cannot be the same as other applications (including different remotes)
479
+ name: 'consumer',
480
+ remotes: {
481
+ AppRemote: 'i18nAppProvider@http://localhost:3005/mf-manifest.json',
482
+ },
483
+ shared: {
484
+ react: { singleton: true },
485
+ 'react-dom': { singleton: true },
486
+ 'react-i18next': { singleton: true },
487
+ i18next: { singleton: true },
488
+ },
489
+ });
490
+ ```
491
+
492
+ :::note
493
+
494
+ If the producer uses a shared I18n instance, the consumer must configure `shared` for `i18next` and `react-i18next`. If the producer uses an independent instance, there is no need to configure `shared` for these two dependencies.
495
+
496
+ :::
497
+
498
+ ### Define Component to Load Remote Application
499
+
500
+ Create a component for loading the remote application:
501
+
502
+ ```tsx title="src/components/RemoteApp.tsx"
503
+ import { createRemoteAppComponent } from '@module-federation/modern-js/react';
504
+ import { loadRemote } from '@module-federation/modern-js/runtime';
505
+ import React from 'react';
506
+
507
+ const FallbackErrorComp = (info: any) => {
508
+ return (
509
+ <div
510
+ style={{ padding: '20px', border: '1px solid red', borderRadius: '4px' }}
511
+ >
512
+ <h3>Loading Failed</h3>
513
+ <p>{info?.error?.message}</p>
514
+ <button onClick={() => info.resetErrorBoundary()}>Retry</button>
515
+ </div>
516
+ );
517
+ };
518
+
519
+ const FallbackComp = (
520
+ <div style={{ padding: '20px', textAlign: 'center' }}>
521
+ <div>Loading remote application...</div>
522
+ </div>
523
+ );
524
+
525
+ const RemoteApp = createRemoteAppComponent({
526
+ loader: () => loadRemote('AppRemote/export-app'),
527
+ export: 'provider' as any,
528
+ fallback: FallbackErrorComp,
529
+ loading: FallbackComp,
530
+ });
531
+
532
+ export default RemoteApp;
533
+ ```
534
+
535
+ :::tip
536
+ The `export` parameter in `createRemoteAppComponent` specifies which export to use from the remote module:
537
+
538
+ - When the producer uses `export default`, you can omit this parameter
539
+ - When the producer uses named exports (e.g., `export const provider`), you must specify the export name
540
+ :::
541
+
542
+ ### Using Remote Application in Routes
543
+
544
+ Use the remote application component in route files. The `basename` parameter is used to specify the base path of the remote application and needs to be determined based on whether path redirection (`localePathRedirect`) is enabled:
545
+
546
+ #### When Path Redirection is Enabled
547
+
548
+ If the consumer has enabled path redirection (`localePathRedirect: true`), the route will include a `[lang]` dynamic parameter. You need to get the language information from the route parameters and pass it to `basename`:
549
+
550
+ ```tsx title="src/routes/[lang]/remote/$.tsx"
551
+ import { useParams } from '@modern-js/runtime/router';
552
+ import React from 'react';
553
+ import RemoteApp from '../../../components/RemoteApp';
554
+
555
+ export default (props: Record<string, any>) => {
556
+ const { lang } = useParams();
557
+ return (
558
+ <div>
559
+ <h2>Remote Application Page</h2>
560
+ {/* basename needs to include the language prefix, e.g., zh/remote or en/remote */}
561
+ <RemoteApp {...props} basename={`${lang}/remote`} />
562
+ </div>
563
+ );
564
+ };
565
+ ```
566
+
567
+ #### When Path Redirection is Not Enabled
568
+
569
+ If the consumer has not enabled path redirection (`localePathRedirect: false` or not configured), the route does not include a language parameter, and `basename` only needs to include the route path:
570
+
571
+ ```tsx title="src/routes/remote/$.tsx"
572
+ import React from 'react';
573
+ import RemoteApp from '../../components/RemoteApp';
574
+
575
+ export default (props: Record<string, any>) => {
576
+ return (
577
+ <div>
578
+ <h2>Remote Application Page</h2>
579
+ {/* When path redirection is not enabled, basename does not need to include the language prefix */}
580
+ <RemoteApp {...props} basename="remote" />
581
+ </div>
582
+ );
583
+ };
584
+ ```
585
+
586
+ :::note
587
+
588
+ Rules for calculating `basename`:
589
+
590
+ - **When `localePathRedirect` is enabled**: `basename` needs to include the language prefix in the format `${lang}/${routePath}` (e.g., `zh/remote`, `en/remote`)
591
+ - **When `localePathRedirect` is not enabled**: `basename` only needs to include the route path in the format `${routePath}` (e.g., `remote`), without adding a language prefix
592
+
593
+ :::
594
+
595
+ ### Shared I18n Instance
596
+
597
+ When the producer uses a shared I18n instance, the consumer needs to create a custom i18n instance and use it in the runtime configuration.
598
+
599
+ #### Create Custom I18n Instance
600
+
601
+ Create a custom i18n instance using the default exported instance from i18next:
602
+
603
+ ```ts title="src/i18n.ts"
604
+ import i18next from 'i18next';
605
+
606
+ i18next.init({
607
+ lng: 'en',
608
+ fallbackLng: 'en',
609
+ resources: {
610
+ en: {
611
+ translation: {
612
+ key: 'Hello World(consumer)',
613
+ about: 'About(consumer)',
614
+ },
615
+ },
616
+ zh: {
617
+ translation: {
618
+ key: '你好,世界(consumer)',
619
+ about: '关于(consumer)',
620
+ },
621
+ },
622
+ },
623
+ });
624
+
625
+ export default i18next;
626
+ ```
627
+
628
+ #### Configure Runtime to Use Custom Instance
629
+
630
+ Pass the custom i18n instance into the application:
631
+
632
+ ```ts title="modern.runtime.tsx"
633
+ import { defineRuntimeConfig } from '@modern-js/runtime';
634
+ import i18next from './i18n';
635
+
636
+ export default defineRuntimeConfig({
637
+ i18n: {
638
+ i18nInstance: i18next,
639
+ },
640
+ });
641
+ ```
642
+
643
+ :::info
644
+
645
+ For detailed information about the `i18nInstance` configuration, please refer to the [Configuration Documentation](/guides/advanced-features/international/configuration#i18ninstance-配置).
646
+
647
+ :::
648
+
649
+ ### Independent I18n Instance
650
+
651
+ For an independent I18n instance, no additional operations are needed. The remote application will use its own i18n instance.
652
+
653
+ ## Summary
654
+
655
+ Key points for integrating i18n with Module Federation:
656
+
657
+ 1. **Component Scenarios**: It is recommended to use a shared I18n instance. Producers and consumers share `i18next` and `react-i18next`, and language switching will be automatically synchronized
658
+ 2. **Application Scenarios**: You can choose to share or use an independent I18n instance based on business requirements
659
+ 3. **Configuration Points**: Ensure that the `shared` configuration of producers and consumers is consistent, especially the singleton configuration of `i18next` and `react-i18next`
660
+ 4. **Route Management**: Producers do not support path redirection (`localePathRedirect`). Route and language switching need to be managed uniformly in the consumer
661
+ 5. **Dependency Sharing**: When using a shared instance, you must configure `i18next` and `react-i18next` as singletons in both the producer's and consumer's `module-federation.config.ts`
662
+ 6. **Name Uniqueness**: The `name` parameter of `createModuleFederationConfig` must be unique for each application and cannot be the same for different remotes
663
+
664
+ ## Related Documentation
665
+
666
+ - [Module Federation Basic Usage](/guides/topic-detail/module-federation/usage)
667
+ - [Application-Level Modules](/guides/topic-detail/module-federation/application)
668
+ - [Internationalization Quick Start](/guides/advanced-features/international/quick-start)
669
+ - [Internationalization Configuration](/guides/advanced-features/international/configuration)
670
+ - [Internationalization Routing Integration](/guides/advanced-features/international/routing)
@@ -6,7 +6,7 @@ In this divided model, it can help improve application performance, enhance code
6
6
 
7
7
  ## Module Federation 2.0
8
8
 
9
- Module Federation, a highlight feature introduced with Webpack 5, has been around for more than three years. This year, ByteDance, along with the author of Module Federation, [@Zack Jackson](https://github.com/ScriptedAlchemy), and community members jointly launched **Module Federation 2.0**.
9
+ Module Federation, a highlight feature introduced with Webpack 5, has been around for more than five years. This year, ByteDance, along with the author of Module Federation, [@Zack Jackson](https://github.com/ScriptedAlchemy), and community members jointly launched **Module Federation 2.0**.
10
10
 
11
11
  Module Federation 2.0 is based on internal practices at ByteDance and the existing community ecosystem of Module Federation, addressing many issues in the previous version.
12
12
 
@@ -20,7 +20,7 @@ Refer to [Module Federation 2.0 Announcement](https://module-federation.io/zh/bl
20
20
 
21
21
  Based on internal practices at ByteDance, the Module Federation team officially provides the [Modern.js Plugin](https://www.npmjs.com/package/@module-federation/modern-js) to help developers use Module Federation more easily.
22
22
 
23
- The plugin recognizes the current build engine (Webpack or Rspack), injects the corresponding Module Federation plugin into Modern.js applications, and automatically handles build configurations and adds runtime code.
23
+ The plugin injects the Module Federation plugin into Modern.js applications and automatically handles build configurations and adds runtime code.
24
24
 
25
25
  Moreover, the plugin also supports the use of Module Federation in Modern.js SSR applications, providing a better performance experience.
26
26
 
@@ -30,6 +30,7 @@ For more details, refer to [Using Module Federation](/guides/topic-detail/module
30
30
 
31
31
  **Application-level modules** possess the application's framework rendering capabilities and routing capabilities, allowing them to operate like applications. Application-level modules are a crucial capability in **micro-frontend frameworks**, providing the ability to load and render across application frameworks (React, Vue) and supporting the loading of modules with routing.
32
32
 
33
- Module Federation 2.0 offers the [Bridge](https://module-federation.io/zh/practice/bridge/index.html) capability to load application-level modules.
33
+ Module Federation 2.0 offers the [Bridge](https://module-federation.io/practice/bridge/overview.html) capability to load application-level modules.
34
+
35
+ Modern.js, based on Bridge and its internal implementation, provides APIs to easily export application-level modules. For more details, refer to [Application-Level Modules](/guides/topic-detail/module-federation/application).
34
36
 
35
- Modern.js, based on Bridge and its internal implementation, provides APIs to easily export application-level modules. For more details, refer to [Application-Level Modules](/guides/topic-detail/module-federation/application).