@modern-js/main-doc 2.58.0 → 2.58.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (467) hide show
  1. package/docs/en/_meta.json +27 -0
  2. package/docs/en/apis/_meta.json +13 -0
  3. package/docs/en/apis/app/hooks/_meta.json +28 -0
  4. package/docs/en/apis/app/hooks/config/icon.mdx +1 -1
  5. package/docs/en/apis/app/runtime/_meta.json +50 -0
  6. package/docs/en/apis/app/runtime/web-server/unstable_middleware.mdx +2 -2
  7. package/docs/en/community/_meta.json +11 -0
  8. package/docs/en/community/blog/2022-0708-updates.md +95 -0
  9. package/docs/en/community/blog/2022-0910-updates.md +80 -0
  10. package/docs/en/community/blog/_meta.json +6 -0
  11. package/docs/en/community/blog/v2-release-note.mdx +246 -0
  12. package/docs/en/components/debug-app.mdx +1 -1
  13. package/docs/en/configure/_meta.json +78 -0
  14. package/docs/en/configure/app/bff/prefix.mdx +1 -1
  15. package/docs/en/configure/app/deploy/microFrontend.mdx +1 -1
  16. package/docs/en/configure/app/dev/asset-prefix.mdx +1 -1
  17. package/docs/en/configure/app/dev/before-start-url.mdx +1 -1
  18. package/docs/en/configure/app/dev/client.mdx +1 -1
  19. package/docs/en/configure/app/dev/hmr.mdx +1 -1
  20. package/docs/en/configure/app/dev/host.mdx +1 -1
  21. package/docs/en/configure/app/dev/https.mdx +1 -1
  22. package/docs/en/configure/app/dev/live-reload.mdx +1 -1
  23. package/docs/en/configure/app/dev/port.mdx +1 -1
  24. package/docs/en/configure/app/dev/progress-bar.mdx +1 -1
  25. package/docs/en/configure/app/dev/proxy.mdx +1 -1
  26. package/docs/en/configure/app/dev/setup-middlewares.mdx +1 -1
  27. package/docs/en/configure/app/dev/start-url.mdx +1 -1
  28. package/docs/en/configure/app/dev/watch-files.mdx +1 -1
  29. package/docs/en/configure/app/dev/write-to-disk.mdx +1 -1
  30. package/docs/en/configure/app/experiments/lazy-compilation.mdx +1 -1
  31. package/docs/en/configure/app/experiments/source-build.mdx +1 -1
  32. package/docs/en/configure/app/html/app-icon.mdx +1 -1
  33. package/docs/en/configure/app/html/crossorigin.mdx +1 -1
  34. package/docs/en/configure/app/html/disable-html-folder.mdx +1 -1
  35. package/docs/en/configure/app/html/favicon-by-entries.mdx +1 -1
  36. package/docs/en/configure/app/html/favicon.mdx +1 -1
  37. package/docs/en/configure/app/html/inject-by-entries.mdx +1 -1
  38. package/docs/en/configure/app/html/inject.mdx +1 -1
  39. package/docs/en/configure/app/html/meta-by-entries.mdx +1 -1
  40. package/docs/en/configure/app/html/meta.mdx +1 -1
  41. package/docs/en/configure/app/html/mount-id.mdx +1 -1
  42. package/docs/en/configure/app/html/script-loading.mdx +1 -1
  43. package/docs/en/configure/app/html/tags-by-entries.mdx +1 -1
  44. package/docs/en/configure/app/html/tags.mdx +1 -1
  45. package/docs/en/configure/app/html/template-by-entries.mdx +1 -1
  46. package/docs/en/configure/app/html/template-parameters-by-entries.mdx +1 -1
  47. package/docs/en/configure/app/html/template-parameters.mdx +1 -1
  48. package/docs/en/configure/app/html/template.mdx +1 -1
  49. package/docs/en/configure/app/html/title-by-entries.mdx +1 -1
  50. package/docs/en/configure/app/html/title.mdx +1 -1
  51. package/docs/en/configure/app/output/asset-prefix.mdx +1 -1
  52. package/docs/en/configure/app/output/assets-retry.mdx +1 -1
  53. package/docs/en/configure/app/output/charset.mdx +1 -1
  54. package/docs/en/configure/app/output/clean-dist-path.mdx +1 -1
  55. package/docs/en/configure/app/output/convert-to-rem.mdx +1 -1
  56. package/docs/en/configure/app/output/copy.mdx +1 -1
  57. package/docs/en/configure/app/output/css-module-local-ident-name.mdx +1 -1
  58. package/docs/en/configure/app/output/css-modules.mdx +1 -1
  59. package/docs/en/configure/app/output/data-uri-limit.mdx +1 -1
  60. package/docs/en/configure/app/output/disable-css-extract.mdx +1 -1
  61. package/docs/en/configure/app/output/disable-css-module-extension.mdx +1 -1
  62. package/docs/en/configure/app/output/disable-filename-hash.mdx +1 -1
  63. package/docs/en/configure/app/output/disable-inline-runtime-chunk.mdx +1 -1
  64. package/docs/en/configure/app/output/disable-minimize.mdx +1 -1
  65. package/docs/en/configure/app/output/disable-node-polyfill.mdx +1 -1
  66. package/docs/en/configure/app/output/disable-source-map.mdx +1 -1
  67. package/docs/en/configure/app/output/disable-svgr.mdx +1 -1
  68. package/docs/en/configure/app/output/disable-ts-checker.mdx +1 -1
  69. package/docs/en/configure/app/output/dist-path.mdx +1 -1
  70. package/docs/en/configure/app/output/enable-asset-fallback.mdx +1 -1
  71. package/docs/en/configure/app/output/enable-asset-manifest.mdx +1 -1
  72. package/docs/en/configure/app/output/enable-css-module-tsdeclaration.mdx +1 -1
  73. package/docs/en/configure/app/output/enable-inline-route-manifests.mdx +1 -1
  74. package/docs/en/configure/app/output/enable-inline-scripts.mdx +1 -1
  75. package/docs/en/configure/app/output/enable-inline-styles.mdx +1 -1
  76. package/docs/en/configure/app/output/enable-latest-decorators.mdx +1 -1
  77. package/docs/en/configure/app/output/externals.mdx +1 -1
  78. package/docs/en/configure/app/output/filename-hash.mdx +1 -1
  79. package/docs/en/configure/app/output/filename.mdx +1 -1
  80. package/docs/en/configure/app/output/legal-comments.mdx +1 -1
  81. package/docs/en/configure/app/output/override-browserslist.mdx +1 -1
  82. package/docs/en/configure/app/output/polyfill.mdx +1 -1
  83. package/docs/en/configure/app/output/splitRouteChunks.mdx +1 -1
  84. package/docs/en/configure/app/output/ssg.mdx +1 -1
  85. package/docs/en/configure/app/output/svg-default-export.mdx +1 -1
  86. package/docs/en/configure/app/output/temp-dir.mdx +1 -1
  87. package/docs/en/configure/app/performance/build-cache.mdx +1 -1
  88. package/docs/en/configure/app/performance/bundle-analyze.mdx +1 -1
  89. package/docs/en/configure/app/performance/chunk-split.mdx +1 -1
  90. package/docs/en/configure/app/performance/dns-prefetch.mdx +1 -1
  91. package/docs/en/configure/app/performance/preconnect.mdx +1 -1
  92. package/docs/en/configure/app/performance/prefetch.mdx +1 -1
  93. package/docs/en/configure/app/performance/preload.mdx +1 -1
  94. package/docs/en/configure/app/performance/print-file-size.mdx +1 -1
  95. package/docs/en/configure/app/performance/profile.mdx +1 -1
  96. package/docs/en/configure/app/performance/remove-console.mdx +1 -1
  97. package/docs/en/configure/app/performance/remove-moment-locale.mdx +1 -1
  98. package/docs/en/configure/app/performance/transform-lodash.mdx +1 -1
  99. package/docs/en/configure/app/runtime/{intro.mdx → 0-intro.mdx} +1 -1
  100. package/docs/en/configure/app/runtime/master-app.mdx +1 -1
  101. package/docs/en/configure/app/runtime/router.mdx +3 -1
  102. package/docs/en/configure/app/runtime/state.mdx +1 -1
  103. package/docs/en/configure/app/security/check-syntax.mdx +1 -1
  104. package/docs/en/configure/app/security/nonce.mdx +1 -1
  105. package/docs/en/configure/app/security/sri.mdx +1 -1
  106. package/docs/en/configure/app/server/base-url.mdx +1 -1
  107. package/docs/en/configure/app/server/enable-framework-ext.mdx +1 -1
  108. package/docs/en/configure/app/server/port.mdx +1 -1
  109. package/docs/en/configure/app/server/public-routes.mdx +1 -1
  110. package/docs/en/configure/app/server/routes.mdx +1 -1
  111. package/docs/en/configure/app/server/ssr-by-entries.mdx +1 -1
  112. package/docs/en/configure/app/server/ssr.mdx +1 -1
  113. package/docs/en/configure/app/source/alias-strategy.mdx +1 -1
  114. package/docs/en/configure/app/source/alias.mdx +1 -1
  115. package/docs/en/configure/app/source/config-dir.mdx +1 -1
  116. package/docs/en/configure/app/source/decorators.mdx +1 -1
  117. package/docs/en/configure/app/source/define.mdx +1 -1
  118. package/docs/en/configure/app/source/disable-default-entries.mdx +1 -1
  119. package/docs/en/configure/app/source/disable-entry-dirs.mdx +1 -1
  120. package/docs/en/configure/app/source/enable-async-entry.mdx +1 -1
  121. package/docs/en/configure/app/source/enable-custom-entry.mdx +1 -1
  122. package/docs/en/configure/app/source/entries-dir.mdx +1 -1
  123. package/docs/en/configure/app/source/entries.mdx +1 -1
  124. package/docs/en/configure/app/source/exclude.mdx +1 -1
  125. package/docs/en/configure/app/source/global-vars.mdx +1 -1
  126. package/docs/en/configure/app/source/include.mdx +1 -1
  127. package/docs/en/configure/app/source/mainEntryName.mdx +1 -1
  128. package/docs/en/configure/app/source/module-scopes.mdx +1 -1
  129. package/docs/en/configure/app/source/pre-entry.mdx +1 -1
  130. package/docs/en/configure/app/source/resolve-extension-prefix.mdx +1 -1
  131. package/docs/en/configure/app/source/resolve-main-fields.mdx +1 -1
  132. package/docs/en/configure/app/source/transform-import.mdx +1 -1
  133. package/docs/en/configure/app/tools/autoprefixer.mdx +1 -1
  134. package/docs/en/configure/app/tools/babel.mdx +1 -1
  135. package/docs/en/configure/app/tools/bundler-chain.mdx +1 -1
  136. package/docs/en/configure/app/tools/css-extract.mdx +1 -1
  137. package/docs/en/configure/app/tools/css-loader.mdx +1 -1
  138. package/docs/en/configure/app/tools/dev-server.mdx +1 -1
  139. package/docs/en/configure/app/tools/esbuild.mdx +2 -2
  140. package/docs/en/configure/app/tools/html-plugin.mdx +1 -1
  141. package/docs/en/configure/app/tools/less.mdx +1 -1
  142. package/docs/en/configure/app/tools/minify-css.mdx +1 -1
  143. package/docs/en/configure/app/tools/postcss.mdx +1 -1
  144. package/docs/en/configure/app/tools/pug.mdx +1 -1
  145. package/docs/en/configure/app/tools/rspack.mdx +1 -1
  146. package/docs/en/configure/app/tools/sass.mdx +1 -1
  147. package/docs/en/configure/app/tools/style-loader.mdx +1 -1
  148. package/docs/en/configure/app/tools/styled-components.mdx +1 -1
  149. package/docs/en/configure/app/tools/swc.mdx +2 -2
  150. package/docs/en/configure/app/tools/tailwindcss.mdx +1 -1
  151. package/docs/en/configure/app/tools/terser.mdx +1 -1
  152. package/docs/en/configure/app/tools/ts-checker.mdx +1 -1
  153. package/docs/en/configure/app/tools/ts-loader.mdx +1 -1
  154. package/docs/en/configure/app/tools/webpack-chain.mdx +1 -1
  155. package/docs/en/configure/app/tools/webpack.mdx +1 -1
  156. package/docs/en/guides/_meta.json +38 -0
  157. package/docs/en/guides/advanced-features/_meta.json +26 -0
  158. package/docs/en/guides/advanced-features/bff/_meta.json +6 -0
  159. package/docs/en/guides/advanced-features/rsbuild-plugin.mdx +9 -9
  160. package/docs/en/guides/advanced-features/ssr/_meta.json +5 -0
  161. package/docs/en/guides/basic-features/_meta.json +22 -0
  162. package/docs/en/guides/basic-features/data/_meta.json +4 -0
  163. package/docs/en/guides/concept/_meta.json +4 -0
  164. package/docs/en/guides/{deprecat.md → deprecated.md} +1 -1
  165. package/docs/en/guides/get-started/_meta.json +7 -0
  166. package/docs/en/guides/get-started/quick-start.mdx +2 -2
  167. package/docs/en/guides/get-started/upgrade.mdx +1 -1
  168. package/docs/en/guides/rsbuild-plugins/plugin-esbuild.mdx +205 -0
  169. package/docs/en/guides/rsbuild-plugins/plugin-swc.mdx +356 -0
  170. package/docs/en/guides/topic-detail/_meta.json +26 -0
  171. package/docs/en/guides/topic-detail/framework-plugin/_meta.json +10 -0
  172. package/docs/en/guides/topic-detail/generator/_meta.json +17 -0
  173. package/docs/en/guides/topic-detail/generator/create/_meta.json +5 -0
  174. package/docs/en/guides/topic-detail/generator/new/_meta.json +5 -0
  175. package/docs/en/guides/topic-detail/generator/plugin/_meta.json +11 -0
  176. package/docs/en/guides/topic-detail/model/_meta.json +14 -0
  177. package/docs/en/guides/troubleshooting/_meta.json +6 -0
  178. package/docs/en/guides/troubleshooting/dependencies.mdx +4 -4
  179. package/docs/en/tutorials/_meta.json +17 -0
  180. package/docs/zh/_meta.json +27 -0
  181. package/docs/zh/apis/_meta.json +13 -0
  182. package/docs/zh/apis/app/hooks/_meta.json +28 -0
  183. package/docs/zh/apis/app/hooks/config/icon.mdx +1 -1
  184. package/docs/zh/apis/app/runtime/_meta.json +50 -0
  185. package/docs/zh/apis/app/runtime/web-server/unstable_middleware.mdx +2 -2
  186. package/docs/zh/community/_meta.json +11 -0
  187. package/docs/zh/community/blog/_meta.json +6 -0
  188. package/docs/zh/community/blog/v2-release-note.mdx +1 -2
  189. package/docs/zh/components/debug-app.mdx +1 -1
  190. package/docs/zh/configure/_meta.json +78 -0
  191. package/docs/zh/configure/app/auto-load-plugin.mdx +1 -1
  192. package/docs/zh/configure/app/bff/prefix.mdx +1 -1
  193. package/docs/zh/configure/app/builder-plugins.mdx +1 -1
  194. package/docs/zh/configure/app/deploy/microFrontend.mdx +1 -1
  195. package/docs/zh/configure/app/dev/asset-prefix.mdx +1 -1
  196. package/docs/zh/configure/app/dev/before-start-url.mdx +1 -1
  197. package/docs/zh/configure/app/dev/client.mdx +1 -1
  198. package/docs/zh/configure/app/dev/hmr.mdx +1 -1
  199. package/docs/zh/configure/app/dev/host.mdx +1 -1
  200. package/docs/zh/configure/app/dev/https.mdx +1 -1
  201. package/docs/zh/configure/app/dev/live-reload.mdx +1 -1
  202. package/docs/zh/configure/app/dev/port.mdx +1 -1
  203. package/docs/zh/configure/app/dev/progress-bar.mdx +1 -1
  204. package/docs/zh/configure/app/dev/proxy.mdx +1 -1
  205. package/docs/zh/configure/app/dev/setup-middlewares.mdx +1 -1
  206. package/docs/zh/configure/app/dev/start-url.mdx +1 -1
  207. package/docs/zh/configure/app/dev/watch-files.mdx +1 -1
  208. package/docs/zh/configure/app/dev/write-to-disk.mdx +1 -1
  209. package/docs/zh/configure/app/experiments/lazy-compilation.mdx +1 -1
  210. package/docs/zh/configure/app/experiments/source-build.mdx +1 -1
  211. package/docs/zh/configure/app/html/app-icon.mdx +1 -1
  212. package/docs/zh/configure/app/html/crossorigin.mdx +1 -1
  213. package/docs/zh/configure/app/html/disable-html-folder.mdx +1 -1
  214. package/docs/zh/configure/app/html/favicon-by-entries.mdx +1 -1
  215. package/docs/zh/configure/app/html/favicon.mdx +1 -1
  216. package/docs/zh/configure/app/html/inject-by-entries.mdx +1 -1
  217. package/docs/zh/configure/app/html/inject.mdx +1 -1
  218. package/docs/zh/configure/app/html/meta-by-entries.mdx +1 -1
  219. package/docs/zh/configure/app/html/meta.mdx +1 -1
  220. package/docs/zh/configure/app/html/mount-id.mdx +1 -1
  221. package/docs/zh/configure/app/html/script-loading.mdx +1 -1
  222. package/docs/zh/configure/app/html/tags-by-entries.mdx +1 -1
  223. package/docs/zh/configure/app/html/tags.mdx +1 -1
  224. package/docs/zh/configure/app/html/template-by-entries.mdx +1 -1
  225. package/docs/zh/configure/app/html/template-parameters-by-entries.mdx +1 -1
  226. package/docs/zh/configure/app/html/template-parameters.mdx +1 -1
  227. package/docs/zh/configure/app/html/template.mdx +1 -1
  228. package/docs/zh/configure/app/html/title-by-entries.mdx +1 -1
  229. package/docs/zh/configure/app/html/title.mdx +1 -1
  230. package/docs/zh/configure/app/output/asset-prefix.mdx +1 -1
  231. package/docs/zh/configure/app/output/assets-retry.mdx +1 -1
  232. package/docs/zh/configure/app/output/charset.mdx +1 -1
  233. package/docs/zh/configure/app/output/clean-dist-path.mdx +1 -1
  234. package/docs/zh/configure/app/output/convert-to-rem.mdx +1 -1
  235. package/docs/zh/configure/app/output/copy.mdx +1 -1
  236. package/docs/zh/configure/app/output/css-module-local-ident-name.mdx +1 -1
  237. package/docs/zh/configure/app/output/css-modules.mdx +1 -1
  238. package/docs/zh/configure/app/output/data-uri-limit.mdx +1 -1
  239. package/docs/zh/configure/app/output/disable-css-extract.mdx +1 -1
  240. package/docs/zh/configure/app/output/disable-css-module-extension.mdx +1 -1
  241. package/docs/zh/configure/app/output/disable-filename-hash.mdx +1 -1
  242. package/docs/zh/configure/app/output/disable-inline-runtime-chunk.mdx +1 -1
  243. package/docs/zh/configure/app/output/disable-minimize.mdx +1 -1
  244. package/docs/zh/configure/app/output/disable-node-polyfill.mdx +1 -1
  245. package/docs/zh/configure/app/output/disable-source-map.mdx +1 -1
  246. package/docs/zh/configure/app/output/disable-svgr.mdx +1 -1
  247. package/docs/zh/configure/app/output/disable-ts-checker.mdx +1 -1
  248. package/docs/zh/configure/app/output/dist-path.mdx +1 -1
  249. package/docs/zh/configure/app/output/enable-asset-fallback.mdx +1 -1
  250. package/docs/zh/configure/app/output/enable-asset-manifest.mdx +1 -1
  251. package/docs/zh/configure/app/output/enable-css-module-tsdeclaration.mdx +1 -1
  252. package/docs/zh/configure/app/output/enable-inline-route-manifests.mdx +1 -1
  253. package/docs/zh/configure/app/output/enable-inline-scripts.mdx +1 -1
  254. package/docs/zh/configure/app/output/enable-inline-styles.mdx +1 -1
  255. package/docs/zh/configure/app/output/enable-latest-decorators.mdx +1 -1
  256. package/docs/zh/configure/app/output/externals.mdx +1 -1
  257. package/docs/zh/configure/app/output/filename-hash.mdx +1 -1
  258. package/docs/zh/configure/app/output/filename.mdx +1 -1
  259. package/docs/zh/configure/app/output/legal-comments.mdx +1 -1
  260. package/docs/zh/configure/app/output/override-browserslist.mdx +1 -1
  261. package/docs/zh/configure/app/output/polyfill.mdx +1 -1
  262. package/docs/zh/configure/app/output/splitRouteChunks.mdx +1 -1
  263. package/docs/zh/configure/app/output/ssg.mdx +1 -1
  264. package/docs/zh/configure/app/output/svg-default-export.mdx +1 -1
  265. package/docs/zh/configure/app/output/temp-dir.mdx +1 -1
  266. package/docs/zh/configure/app/performance/build-cache.mdx +1 -1
  267. package/docs/zh/configure/app/performance/bundle-analyze.mdx +1 -1
  268. package/docs/zh/configure/app/performance/chunk-split.mdx +1 -1
  269. package/docs/zh/configure/app/performance/dns-prefetch.mdx +1 -1
  270. package/docs/zh/configure/app/performance/preconnect.mdx +1 -1
  271. package/docs/zh/configure/app/performance/prefetch.mdx +1 -1
  272. package/docs/zh/configure/app/performance/preload.mdx +1 -1
  273. package/docs/zh/configure/app/performance/print-file-size.mdx +1 -1
  274. package/docs/zh/configure/app/performance/profile.mdx +1 -1
  275. package/docs/zh/configure/app/performance/remove-console.mdx +1 -1
  276. package/docs/zh/configure/app/performance/remove-moment-locale.mdx +1 -1
  277. package/docs/zh/configure/app/performance/transform-lodash.mdx +1 -1
  278. package/docs/zh/configure/app/plugins.mdx +1 -1
  279. package/docs/zh/configure/app/runtime/{intro.mdx → 0-intro.mdx} +1 -1
  280. package/docs/zh/configure/app/runtime/master-app.mdx +1 -1
  281. package/docs/zh/configure/app/runtime/router.mdx +3 -1
  282. package/docs/zh/configure/app/runtime/state.mdx +1 -1
  283. package/docs/zh/configure/app/security/check-syntax.mdx +1 -1
  284. package/docs/zh/configure/app/security/nonce.mdx +1 -1
  285. package/docs/zh/configure/app/security/sri.mdx +1 -1
  286. package/docs/zh/configure/app/server/base-url.mdx +1 -1
  287. package/docs/zh/configure/app/server/enable-framework-ext.mdx +1 -1
  288. package/docs/zh/configure/app/server/port.mdx +1 -1
  289. package/docs/zh/configure/app/server/public-routes.mdx +1 -1
  290. package/docs/zh/configure/app/server/routes.mdx +1 -1
  291. package/docs/zh/configure/app/server/ssr-by-entries.mdx +1 -1
  292. package/docs/zh/configure/app/server/ssr.mdx +1 -1
  293. package/docs/zh/configure/app/source/alias-strategy.mdx +1 -1
  294. package/docs/zh/configure/app/source/alias.mdx +1 -1
  295. package/docs/zh/configure/app/source/config-dir.mdx +1 -1
  296. package/docs/zh/configure/app/source/decorators.mdx +1 -1
  297. package/docs/zh/configure/app/source/define.mdx +1 -1
  298. package/docs/zh/configure/app/source/disable-default-entries.mdx +1 -1
  299. package/docs/zh/configure/app/source/disable-entry-dirs.mdx +1 -1
  300. package/docs/zh/configure/app/source/enable-async-entry.mdx +1 -1
  301. package/docs/zh/configure/app/source/enable-custom-entry.mdx +1 -1
  302. package/docs/zh/configure/app/source/entries-dir.mdx +1 -1
  303. package/docs/zh/configure/app/source/entries.mdx +1 -1
  304. package/docs/zh/configure/app/source/exclude.mdx +1 -1
  305. package/docs/zh/configure/app/source/global-vars.mdx +1 -1
  306. package/docs/zh/configure/app/source/include.mdx +1 -1
  307. package/docs/zh/configure/app/source/mainEntryName.mdx +1 -1
  308. package/docs/zh/configure/app/source/module-scopes.mdx +1 -1
  309. package/docs/zh/configure/app/source/pre-entry.mdx +1 -1
  310. package/docs/zh/configure/app/source/resolve-extension-prefix.mdx +1 -1
  311. package/docs/zh/configure/app/source/resolve-main-fields.mdx +1 -1
  312. package/docs/zh/configure/app/source/transform-import.mdx +1 -1
  313. package/docs/zh/configure/app/tools/autoprefixer.mdx +1 -1
  314. package/docs/zh/configure/app/tools/babel.mdx +1 -1
  315. package/docs/zh/configure/app/tools/bundler-chain.mdx +1 -1
  316. package/docs/zh/configure/app/tools/css-extract.mdx +1 -1
  317. package/docs/zh/configure/app/tools/css-loader.mdx +1 -1
  318. package/docs/zh/configure/app/tools/dev-server.mdx +1 -1
  319. package/docs/zh/configure/app/tools/esbuild.mdx +2 -2
  320. package/docs/zh/configure/app/tools/html-plugin.mdx +1 -1
  321. package/docs/zh/configure/app/tools/less.mdx +1 -1
  322. package/docs/zh/configure/app/tools/minify-css.mdx +1 -1
  323. package/docs/zh/configure/app/tools/postcss.mdx +1 -1
  324. package/docs/zh/configure/app/tools/pug.mdx +1 -1
  325. package/docs/zh/configure/app/tools/rspack.mdx +1 -1
  326. package/docs/zh/configure/app/tools/sass.mdx +1 -1
  327. package/docs/zh/configure/app/tools/style-loader.mdx +1 -1
  328. package/docs/zh/configure/app/tools/styled-components.mdx +1 -1
  329. package/docs/zh/configure/app/tools/swc.mdx +2 -2
  330. package/docs/zh/configure/app/tools/tailwindcss.mdx +1 -1
  331. package/docs/zh/configure/app/tools/terser.mdx +1 -1
  332. package/docs/zh/configure/app/tools/ts-checker.mdx +1 -1
  333. package/docs/zh/configure/app/tools/ts-loader.mdx +1 -1
  334. package/docs/zh/configure/app/tools/webpack-chain.mdx +1 -1
  335. package/docs/zh/configure/app/tools/webpack.mdx +1 -1
  336. package/docs/zh/guides/_meta.json +38 -0
  337. package/docs/zh/guides/advanced-features/_meta.json +26 -0
  338. package/docs/zh/guides/advanced-features/bff/_meta.json +6 -0
  339. package/docs/zh/guides/advanced-features/rsbuild-plugin.mdx +9 -9
  340. package/docs/zh/guides/advanced-features/ssr/_meta.json +5 -0
  341. package/docs/zh/guides/basic-features/_meta.json +22 -0
  342. package/docs/zh/guides/basic-features/data/_meta.json +4 -0
  343. package/docs/zh/guides/basic-features/mock.mdx +1 -1
  344. package/docs/zh/guides/concept/_meta.json +4 -0
  345. package/docs/zh/guides/get-started/_meta.json +7 -0
  346. package/docs/zh/guides/get-started/quick-start.mdx +2 -2
  347. package/docs/zh/guides/get-started/upgrade.mdx +1 -1
  348. package/docs/zh/guides/rsbuild-plugins/plugin-esbuild.mdx +201 -0
  349. package/docs/zh/guides/rsbuild-plugins/plugin-swc.mdx +344 -0
  350. package/docs/zh/guides/topic-detail/_meta.json +26 -0
  351. package/docs/zh/guides/topic-detail/framework-plugin/_meta.json +10 -0
  352. package/docs/zh/guides/topic-detail/generator/_meta.json +17 -0
  353. package/docs/zh/guides/topic-detail/generator/create/_meta.json +5 -0
  354. package/docs/zh/guides/topic-detail/generator/new/_meta.json +5 -0
  355. package/docs/zh/guides/topic-detail/generator/plugin/_meta.json +11 -0
  356. package/docs/zh/guides/topic-detail/model/_meta.json +14 -0
  357. package/docs/zh/guides/troubleshooting/_meta.json +6 -0
  358. package/docs/zh/guides/troubleshooting/dependencies.mdx +4 -4
  359. package/docs/zh/tutorials/_meta.json +17 -0
  360. package/i18n.json +110 -0
  361. package/package.json +9 -10
  362. package/rspress.config.ts +3 -20
  363. package/src/components/ContentCard/index.tsx +1 -1
  364. package/src/components/FeatureLayout/index.tsx +1 -1
  365. package/src/components/Footer/index.tsx +2 -2
  366. package/src/components/ListCard/index.tsx +1 -1
  367. package/src/components/Sandpack/index.tsx +4 -2
  368. package/src/components/SecondaryTitle/index.tsx +1 -1
  369. package/src/i18n/zhCN.ts +1 -1
  370. package/src/index.ts +0 -1
  371. package/src/pages/index.tsx +13 -5
  372. package/docs/en/apis/app/hooks/_category_.json +0 -5
  373. package/docs/en/apis/app/hooks/api/_category_.json +0 -4
  374. package/docs/en/apis/app/hooks/config/_category_.json +0 -4
  375. package/docs/en/apis/app/hooks/server/_category_.json +0 -4
  376. package/docs/en/apis/app/hooks/src/_category_.json +0 -4
  377. package/docs/en/apis/app/runtime/_category_.json +0 -5
  378. package/docs/en/apis/app/runtime/app/_category_.json +0 -4
  379. package/docs/en/apis/app/runtime/bff/_category_.json +0 -4
  380. package/docs/en/apis/app/runtime/core/_category_.json +0 -5
  381. package/docs/en/apis/app/runtime/model/_category_.json +0 -4
  382. package/docs/en/apis/app/runtime/router/_category_.json +0 -4
  383. package/docs/en/apis/app/runtime/ssr/_category_.json +0 -4
  384. package/docs/en/apis/app/runtime/utility/_category_.json +0 -4
  385. package/docs/en/apis/app/runtime/web-server/_category_.json +0 -4
  386. package/docs/en/community/blog/_category_.json +0 -6
  387. package/docs/en/configure/app/bff/_category_.json +0 -4
  388. package/docs/en/configure/app/deploy/_category_.json +0 -4
  389. package/docs/en/configure/app/dev/_category_.json +0 -4
  390. package/docs/en/configure/app/experiments/_category_.json +0 -4
  391. package/docs/en/configure/app/html/_category_.json +0 -4
  392. package/docs/en/configure/app/output/_category_.json +0 -4
  393. package/docs/en/configure/app/performance/_category_.json +0 -4
  394. package/docs/en/configure/app/runtime/_category_.json +0 -4
  395. package/docs/en/configure/app/security/_category_.json +0 -4
  396. package/docs/en/configure/app/server/_category_.json +0 -4
  397. package/docs/en/configure/app/source/_category_.json +0 -4
  398. package/docs/en/configure/app/tools/_category_.json +0 -4
  399. package/docs/en/guides/advanced-features/_category_.json +0 -5
  400. package/docs/en/guides/advanced-features/bff/_category_.json +0 -8
  401. package/docs/en/guides/advanced-features/ssr/_category_.json +0 -8
  402. package/docs/en/guides/basic-features/_category_.json +0 -5
  403. package/docs/en/guides/basic-features/data/_category_.json +0 -4
  404. package/docs/en/guides/concept/_category_.json +0 -5
  405. package/docs/en/guides/get-started/_category_.json +0 -5
  406. package/docs/en/guides/topic-detail/_category_.json +0 -5
  407. package/docs/en/guides/topic-detail/framework-plugin/_category_.json +0 -4
  408. package/docs/en/guides/topic-detail/generator/_category_.json +0 -4
  409. package/docs/en/guides/topic-detail/generator/create/_category_.json +0 -4
  410. package/docs/en/guides/topic-detail/generator/new/_category_.json +0 -4
  411. package/docs/en/guides/topic-detail/generator/plugin/_category_.json +0 -4
  412. package/docs/en/guides/topic-detail/generator/plugin/api/_category_.json +0 -4
  413. package/docs/en/guides/topic-detail/micro-frontend/_category_.json +0 -4
  414. package/docs/en/guides/topic-detail/model/_category_.json +0 -4
  415. package/docs/en/guides/troubleshooting/_category_.json +0 -5
  416. package/docs/en/tutorials/examples/_category_.json +0 -5
  417. package/docs/en/tutorials/first-app/_category_.json +0 -5
  418. package/docs/en/tutorials/foundations/_category_.json +0 -5
  419. package/docs/zh/apis/app/hooks/_category_.json +0 -5
  420. package/docs/zh/apis/app/hooks/api/_category_.json +0 -4
  421. package/docs/zh/apis/app/hooks/config/_category_.json +0 -4
  422. package/docs/zh/apis/app/hooks/server/_category_.json +0 -4
  423. package/docs/zh/apis/app/hooks/src/_category_.json +0 -4
  424. package/docs/zh/apis/app/runtime/_category_.json +0 -5
  425. package/docs/zh/apis/app/runtime/app/_category_.json +0 -4
  426. package/docs/zh/apis/app/runtime/bff/_category_.json +0 -4
  427. package/docs/zh/apis/app/runtime/core/_category_.json +0 -4
  428. package/docs/zh/apis/app/runtime/model/_category_.json +0 -4
  429. package/docs/zh/apis/app/runtime/router/_category_.json +0 -4
  430. package/docs/zh/apis/app/runtime/ssr/_category_.json +0 -4
  431. package/docs/zh/apis/app/runtime/utility/_category_.json +0 -4
  432. package/docs/zh/apis/app/runtime/web-server/_category_.json +0 -4
  433. package/docs/zh/community/blog/_category_.json +0 -6
  434. package/docs/zh/configure/app/bff/_category_.json +0 -4
  435. package/docs/zh/configure/app/deploy/_category_.json +0 -4
  436. package/docs/zh/configure/app/dev/_category_.json +0 -4
  437. package/docs/zh/configure/app/experiments/_category_.json +0 -4
  438. package/docs/zh/configure/app/html/_category_.json +0 -4
  439. package/docs/zh/configure/app/output/_category_.json +0 -4
  440. package/docs/zh/configure/app/performance/_category_.json +0 -4
  441. package/docs/zh/configure/app/runtime/_category_.json +0 -4
  442. package/docs/zh/configure/app/security/_category_.json +0 -4
  443. package/docs/zh/configure/app/server/_category_.json +0 -4
  444. package/docs/zh/configure/app/source/_category_.json +0 -4
  445. package/docs/zh/configure/app/tools/_category_.json +0 -4
  446. package/docs/zh/guides/advanced-features/_category_.json +0 -5
  447. package/docs/zh/guides/advanced-features/bff/_category_.json +0 -8
  448. package/docs/zh/guides/advanced-features/ssr/_category_.json +0 -8
  449. package/docs/zh/guides/basic-features/_category_.json +0 -5
  450. package/docs/zh/guides/basic-features/data/_category_.json +0 -4
  451. package/docs/zh/guides/concept/_category_.json +0 -5
  452. package/docs/zh/guides/get-started/_category_.json +0 -5
  453. package/docs/zh/guides/topic-detail/_category_.json +0 -5
  454. package/docs/zh/guides/topic-detail/framework-plugin/_category_.json +0 -4
  455. package/docs/zh/guides/topic-detail/generator/_category_.json +0 -4
  456. package/docs/zh/guides/topic-detail/generator/create/_category_.json +0 -4
  457. package/docs/zh/guides/topic-detail/generator/new/_category_.json +0 -4
  458. package/docs/zh/guides/topic-detail/generator/plugin/_category_.json +0 -4
  459. package/docs/zh/guides/topic-detail/generator/plugin/api/_category_.json +0 -4
  460. package/docs/zh/guides/topic-detail/micro-frontend/_category_.json +0 -4
  461. package/docs/zh/guides/topic-detail/model/_category_.json +0 -4
  462. package/docs/zh/guides/troubleshooting/_category_.json +0 -5
  463. package/docs/zh/tutorials/examples/_category_.json +0 -5
  464. package/docs/zh/tutorials/first-app/_category_.json +0 -5
  465. package/docs/zh/tutorials/foundations/_category_.json +0 -5
  466. package/src/.eslintrc.json +0 -3
  467. /package/docs/zh/guides/{deprecat.md → deprecated.md} +0 -0
@@ -0,0 +1,344 @@
1
+ ---
2
+ sidebar_position: 2
3
+ ---
4
+
5
+ # SWC 插件
6
+
7
+ import SWC from '@modern-js/builder-doc/docs/zh/shared/swc.md';
8
+
9
+ <SWC />
10
+
11
+ ## 适用场景
12
+
13
+ 在使用 SWC 插件之前,请先了解一下 SWC 插件的适用场景和局限性,以明确你的项目是否需要使用 SWC 插件。
14
+
15
+ ### Rspack 场景
16
+
17
+ 如果你的项目中已经使用了 Rspack 作为打包工具,那么你不需要接入 SWC 插件,因为 Rspack 默认会使用 SWC 进行转译和压缩,各个 SWC 编译能力可以开箱即用。
18
+
19
+ 如果你使用 Rspack 时配置了当前的 SWC 插件,它将不会产生任何效果。
20
+
21
+ ### Babel 插件
22
+
23
+ 如果你的项目需要注册一些自定义的 Babel 插件,由于 SWC 替代了 Babel 作为转译工具,因此使用 SWC 后,你将无法注册和使用 Babel 插件。
24
+
25
+ 对于大部分常见的 Babel 插件,你可以在 SWC 中找到对应的替代品,比如:
26
+
27
+ - `@babel/preset-env`: 使用 [presetEnv](#presetenv) 代替。
28
+ - `@babel/preset-react`: 使用 [presetReact](#presetreact) 代替。
29
+ - `babel-plugin-import`:使用 [source.transformImport](/configure/app/source/transform-import) 代替。
30
+ - `babel-plugin-lodash`:使用 [extensions.lodash](#extensionslodash) 代替。
31
+ - `@emotion/babel-plugin`:使用 [extensions.emotion](#extensionsemotion) 代替。
32
+ - `babel-plugin-styled-components`:使用 [extensions.styledComponents](#extensionsstyledcomponents) 代替。
33
+ - `@babel/plugin-react-transform-remove-prop-types`: 使用 [reactUtils.removePropTypes](#extensionsreactutils) 代替。
34
+
35
+ 如果你使用了 SWC 尚未支持的 Babel 插件能力,在切换到 SWC 编译后,将无法再使用它们。你可以到 [swc-plugins](https://github.com/web-infra-dev/swc-plugins) 仓库下通过 issues 进行反馈,我们会评估是否需要内置支持。
36
+
37
+ ### 产物体积
38
+
39
+ 在使用 SWC 来代替 [terser](https://github.com/terser/terser) 和 [cssnano](https://github.com/cssnano/cssnano) 进行代码压缩时,构建产物的体积可能会出现少量变化。在 JavaScript 代码压缩方面,SWC 的压缩率是优于 terser 的;在 CSS 代码压缩方面,SWC 的压缩率稍逊于 cssnano。
40
+
41
+ 对于压缩工具之间的详细对比,可以参考 [minification-benchmarks](https://github.com/privatenumber/minification-benchmarks)。
42
+
43
+ ## 快速开始
44
+
45
+ ### 在 Modern.js 框架中使用
46
+
47
+ Modern.js 框架对 Builder 的 SWC 插件进行了封装,你可以通过以下方式来使用:
48
+
49
+ import EnableSWC from '@modern-js/builder-doc/docs/zh/shared/enableSwc.md';
50
+
51
+ <EnableSWC />
52
+
53
+ That's it! 现在你可以在项目中无缝使用 SWC 的转译和压缩能力了。
54
+
55
+ ## 配置
56
+
57
+ - **类型:**
58
+
59
+ ```ts
60
+ type PluginConfig =
61
+ | ObjPluginConfig
62
+ | ((
63
+ config: ObjPluginConfig,
64
+ utils: { mergeConfig: typeof lodash.merge; setConfig: typeof lodash.set },
65
+ ) => ObjPluginConfig | void);
66
+
67
+ // SwcOptions 为 swc 配置项 https://swc.rs/docs/configuration/compilation
68
+ interface ObjPluginConfig extends SwcOptions {
69
+ presetReact?: ReactConfig;
70
+ presetEnv?: EnvConfig;
71
+ jsMinify?: boolean | JsMinifyOptions;
72
+ cssMinify?: boolean | CssMinifyOptions;
73
+ extensions?: Extensions;
74
+ overrides?: Overrides;
75
+ }
76
+ ```
77
+
78
+ 插件配置在 SWC 配置的基础上,为了简化部分深层配置和为提高开发体验,进行了部分拓展,例如当使用对象形式配置时,可以使用 `presetReact` 以及 `presetEnv` 快速配置 react 以及语法降级相关功能,另外不属于插件特有的配置也会直接透传给 swc。
79
+
80
+ 当使用函数形式配置时,则会传入插件内部产出的默认配置,可以对其进行修改或返回新的配置。
81
+
82
+ ### presetReact
83
+
84
+ - **类型:** SWC 中的 [react](https://swc.rs/docs/configuration/compilation#jsctransformreact) 配置。
85
+
86
+ 对标 `@babel/preset-react`。传入的值会与默认配置进行合并。
87
+
88
+ 插件默认会自动根据你的 `react` 版本确定 `runtime` 字段,如果 `react` 版本大于 17.0.0,会设置成 `automatic`,否则设置成 `classic`。
89
+
90
+ ### presetEnv
91
+
92
+ - **类型:** SWC 中的 [presetEnv](https://swc.rs/docs/configuration/supported-browsers#options)。
93
+
94
+ 对标 `@babel/preset-env`。传入的值会与默认配置进行合并。
95
+ 默认配置为:
96
+
97
+ ```ts
98
+ {
99
+ targets: '', // 自动从项目中获取 browserslist
100
+ mode: 'usage',
101
+ }
102
+ ```
103
+
104
+ ### jsMinify
105
+
106
+ - **类型:** `boolean` 或者 [terser 中的 compress 配置](https://terser.org/docs/api-reference.html#compress-options)。
107
+ - **默认值:** `{ compress: {}, mangle: true }`。
108
+
109
+ 如果配置 `false` 将不会使用 SWC 的压缩能力,配置 `true` 会启用默认压缩配置,如果配置是对象,则会与默认配置进行合并。
110
+
111
+ ### cssMinify
112
+
113
+ - **类型:** `boolean`
114
+ - **默认值:** `true`
115
+
116
+ 是否启用 SWC 对 CSS 文件进行压缩,若启用会使得 CSS 压缩性能提高,但压缩率会略微降低。
117
+
118
+ ### overrides
119
+
120
+ - **类型:**
121
+
122
+ ```ts
123
+ interface Overrides extends SwcOptions {
124
+ test: RegExp;
125
+ include: RegExp[];
126
+ exclude: RegExp[];
127
+ }
128
+ ```
129
+
130
+ - **默认值:** `undefined`
131
+
132
+ 对指定文件运用另外的配置。例如需要对 `foo.ts` 的语法降级成 ie 11,则可以如下配置:
133
+
134
+ ```ts
135
+ {
136
+ test: /foo.ts/,
137
+ env: { targets: 'ie 11' }
138
+ }
139
+ ```
140
+
141
+ 该配置会与默认配置进行合并,并且不会影响到其他文件。
142
+
143
+ ### extensions
144
+
145
+ - **类型:** `Object`
146
+
147
+ `extensions` 包含了从 Babel 移植过来的一些插件能力。
148
+
149
+ #### extensions.reactUtils
150
+
151
+ - **类型:**
152
+
153
+ ```ts
154
+ type ReactUtilsOptions = {
155
+ autoImportReact?: boolean;
156
+ removeEffect?: boolean;
157
+ removePropTypes?: {
158
+ mode?: 'remove' | 'unwrap' | 'unsafe-wrap';
159
+ removeImport?: boolean;
160
+ ignoreFilenames?: string[];
161
+ additionalLibraries?: string[];
162
+ classNameMatchers?: string[];
163
+ };
164
+ };
165
+ ```
166
+
167
+ 一些用于 `React` 的工具,包括以下配置项:
168
+
169
+ **reactUtils.autoImportReact**
170
+
171
+ - **类型:** `boolean`
172
+
173
+ 自动引入 `React`, `import React from 'react'`,用于 `jsx` 转换使用 `React.createElement`。
174
+
175
+ **reactUtils.removeEffect**
176
+
177
+ - **类型:** `boolean`
178
+
179
+ 移除 `useEffect` 调用。
180
+
181
+ **reactUtils.removePropTypes**
182
+
183
+ - **类型:**
184
+
185
+ ```ts
186
+ type RemovePropTypesOptions = {
187
+ mode?: 'remove' | 'unwrap' | 'unsafe-wrap';
188
+ removeImport?: boolean;
189
+ ignoreFilenames?: string[];
190
+ additionalLibraries?: string[];
191
+ classNameMatchers?: string[];
192
+ };
193
+ ```
194
+
195
+ 移除 `React` 组件在运行时的类型判断。移植自 [@babel/plugin-react-transform-remove-prop-types](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types)。
196
+
197
+ 相应配置和 `@babel/plugin-react-transform-remove-prop-types` 插件保持一致。
198
+
199
+ #### extensions.lodash
200
+
201
+ - **类型:**
202
+
203
+ ```ts
204
+ type LodashOptions = {
205
+ cwd?: string;
206
+ ids?: string[];
207
+ };
208
+ ```
209
+
210
+ - **默认值:**
211
+
212
+ ```ts
213
+ const defaultOptions = {
214
+ cwd: process.cwd(),
215
+ ids: ['lodash', 'lodash-es'],
216
+ };
217
+ ```
218
+
219
+ 移植自 [babel-plugin-lodash](https://github.com/lodash/babel-plugin-lodash),用于自动将 Lodash 的引用转换为按需引入,从而减少打包后的 Lodash 代码大小。
220
+
221
+ ```ts
222
+ // Input
223
+ import { get, throttle } from 'lodash';
224
+
225
+ // Output
226
+ import get from 'lodash/get';
227
+ import throttle from 'lodash/throttle';
228
+ ```
229
+
230
+ #### extensions.styledComponents
231
+
232
+ - **类型:**
233
+
234
+ ```ts
235
+ boolean | {
236
+ displayName?: boolean; // 默认开发模式开启, 生产模式关闭,
237
+ ssr?: boolean; // 默认开启
238
+ fileName?: boolean; // 默认开启
239
+ topLevelImportPaths?: string[]; // 默认空
240
+ meaninglessFileNames?: string[]; // 默认为 ["index"].
241
+ cssProp?: boolean; // 默认开启
242
+ namespace?: string; // 默认空
243
+ };
244
+ ```
245
+
246
+ 由 Next.js 团队移植自 [babel-plugin-styled-components](https://github.com/styled-components/babel-plugin-styled-components)。
247
+
248
+ #### extensions.emotion
249
+
250
+ - **类型:**
251
+
252
+ ```ts
253
+ boolean | {
254
+ sourceMap?: boolean, // 默认开启
255
+ autoLabel?: 'never' | 'dev-only' | 'always', // 默认 'dev-only'
256
+ // 默认 '[local]'.
257
+ // 允许的值为: `[local]` `[filename]` 以及 `[dirname]`
258
+ // 只有当 autoLabel 设置成 'dev-only' 或者 'always' 才会生效.
259
+ // 该配置允许你定义结果标签的格式,该格式的组成是字符串以及可以由方括号包裹字符串作为变量
260
+ // 例如对于 "my-classname--[local]",其中的 [local] 会被替换成相应的变量
261
+ labelFormat?: string,
262
+ // 默认值 undefined.
263
+ // 该配置允许让编译器知道哪一个引入需要进行转换,所以如果你重导出了 emotion
264
+ // 的导出,你仍然可以使用该插件进行转换
265
+ importMap?: {
266
+ [packageName: string]: {
267
+ [exportName: string]: {
268
+ canonicalImport?: [string, string],
269
+ styledBaseImport?: [string, string],
270
+ }
271
+ }
272
+ },
273
+ },
274
+ ```
275
+
276
+ 由 Next.js 团队移植自 [@emotion/babel-plugin](https://www.npmjs.com/package/@emotion/babel-plugin)。
277
+
278
+ #### extensions.pluginImport
279
+
280
+ :::tip
281
+ Builder 提供了 [source.transformImport](/configure/app/source/transform-import) 配置项,因此你不需要手动配置 `extensions.pluginImport`。
282
+ :::
283
+
284
+ 移植自 [babel-plugin-import](https://github.com/umijs/babel-plugin-import),配置选项保持一致。
285
+
286
+ 一些配置可以传入函数,例如 `customName`,`customStyleName` 等,这些 JavaScript 函数会由 Rust 通过 Node-API 调用,这种调用会造成一些性能劣化。
287
+
288
+ 简单的函数逻辑其实可以通过模版语言来代替,因此`customName`,`customStyleName` 等这些配置除了可以传入函数,也可以传入字符串作为模版来代替函数,提高性能。
289
+
290
+ 我们以下面代码为例说明:
291
+
292
+ ```ts
293
+ import { MyButton as Btn } from 'foo';
294
+ ```
295
+
296
+ 添加以下配置:
297
+
298
+ ```ts
299
+ PluginSWC({
300
+ extensions: {
301
+ pluginImport: [
302
+ {
303
+ libraryName: 'foo',
304
+ customName: 'foo/es/{{ member }}',
305
+ },
306
+ ],
307
+ },
308
+ });
309
+ ```
310
+
311
+ 其中的 `{{ member }}` 会被替换为相应的引入成员,转换后:
312
+
313
+ ```ts
314
+ import Btn from 'foo/es/MyButton';
315
+ ```
316
+
317
+ 可以看出配置 `customName: "foo/es/{{ member }}"` 的效果等同于配置 `` customName: (member) => `foo/es/${member}` ``,但是不会有 Node-API 的调用开销。
318
+
319
+ 这里使用到的模版是 [handlebars](https://handlebarsjs.com),模版配置中还内置了一些有用的辅助工具,还是以上面的导入语句为例,配置成:
320
+
321
+ ```ts
322
+ PluginSWC({
323
+ extensions: {
324
+ pluginImport: [
325
+ {
326
+ libraryName: 'foo',
327
+ customName: 'foo/es/{{ kebabCase member }}',
328
+ },
329
+ ],
330
+ },
331
+ });
332
+ ```
333
+
334
+ 会转换成下面的结果:
335
+
336
+ ```ts
337
+ import Btn from 'foo/es/my-button';
338
+ ```
339
+
340
+ 除了 `kebabCase` 以外还有 `camelCase`,`snakeCase`,`upperCase`,`lowerCase` 可以使用。
341
+
342
+ ## 限制
343
+
344
+ 不支持 `@babel/plugin-transform-runtime` 以及其他自定义的 Babel 插件。
@@ -0,0 +1,26 @@
1
+ [
2
+ {
3
+ "type": "dir",
4
+ "name": "micro-frontend",
5
+ "label": "micro-frontend",
6
+ "collapsed": true
7
+ },
8
+ {
9
+ "type": "dir",
10
+ "name": "framework-plugin",
11
+ "label": "framework-plugin",
12
+ "collapsed": true
13
+ },
14
+ {
15
+ "type": "dir",
16
+ "name": "model",
17
+ "label": "reduck",
18
+ "collapsed": true
19
+ },
20
+ {
21
+ "type": "dir",
22
+ "name": "generator",
23
+ "label": "generator",
24
+ "collapsed": true
25
+ }
26
+ ]
@@ -0,0 +1,10 @@
1
+ [
2
+ "introduction",
3
+ "lifecycle",
4
+ "hook",
5
+ "implement",
6
+ "relationship",
7
+ "extend",
8
+ "plugin-api",
9
+ "hook-list"
10
+ ]
@@ -0,0 +1,17 @@
1
+ [
2
+ {
3
+ "type": "dir",
4
+ "name": "create",
5
+ "label": "@modern-js/create"
6
+ },
7
+ {
8
+ "type": "dir",
9
+ "name": "new",
10
+ "label": "new-command"
11
+ },
12
+ {
13
+ "type": "dir",
14
+ "name": "plugin",
15
+ "label": "generator-plugin"
16
+ }
17
+ ]
@@ -0,0 +1,5 @@
1
+ [
2
+ "use",
3
+ "option",
4
+ "config"
5
+ ]
@@ -0,0 +1,5 @@
1
+ [
2
+ "use",
3
+ "option",
4
+ "config"
5
+ ]
@@ -0,0 +1,11 @@
1
+ [
2
+ "structure",
3
+ "category",
4
+ "use",
5
+ "context",
6
+ {
7
+ "type": "dir",
8
+ "name": "api",
9
+ "label": "API"
10
+ }
11
+ ]
@@ -0,0 +1,14 @@
1
+ [
2
+ "quick-start",
3
+ "define-model",
4
+ "use-model",
5
+ "computed-state",
6
+ "manage-effects",
7
+ "auto-actions",
8
+ "model-communicate",
9
+ "performance",
10
+ "typescript-best-practice",
11
+ "redux-integration",
12
+ "use-out-of-modernjs",
13
+ "faq"
14
+ ]
@@ -0,0 +1,6 @@
1
+ [
2
+ "dependencies",
3
+ "cli",
4
+ "builder",
5
+ "hmr"
6
+ ]
@@ -18,8 +18,8 @@ sidebar_position: 1
18
18
 
19
19
  ```
20
20
  project
21
- └─┬ @modern-js/app-tools@2.0.0
22
- └── @modern-js/core@2.0.0
21
+ └─┬ @modern-js/app-tools@x.y.z
22
+ └── @modern-js/core@x.y.z
23
23
  ```
24
24
 
25
25
  **pnpm**
@@ -30,8 +30,8 @@ project
30
30
 
31
31
  ```
32
32
  devDependencies:
33
- @modern-js/app-tools 2.0.0
34
- └── @modern-js/core 2.0.0
33
+ @modern-js/app-tools x.y.z
34
+ └── @modern-js/core x.y.z
35
35
  ```
36
36
 
37
37
  ---
@@ -0,0 +1,17 @@
1
+ [
2
+ {
3
+ "type": "dir",
4
+ "name": "foundations",
5
+ "label": "foundations"
6
+ },
7
+ {
8
+ "type": "dir",
9
+ "name": "first-app",
10
+ "label": "first-app"
11
+ },
12
+ {
13
+ "type": "dir",
14
+ "name": "examples",
15
+ "label": "examples"
16
+ }
17
+ ]
package/i18n.json ADDED
@@ -0,0 +1,110 @@
1
+ {
2
+ "guide": {
3
+ "zh": "指南",
4
+ "en": "Guide"
5
+ },
6
+ "tutorials": {
7
+ "zh": "教程",
8
+ "en": "Tutorials"
9
+ },
10
+ "configure": {
11
+ "zh": "配置",
12
+ "en": "Config"
13
+ },
14
+ "apis": {
15
+ "zh": "API",
16
+ "en": "API"
17
+ },
18
+ "community": {
19
+ "zh": "社区",
20
+ "en": "Community"
21
+ },
22
+ "gettingStarted": {
23
+ "zh": "开始",
24
+ "en": "Start"
25
+ },
26
+ "concept": {
27
+ "zh": "核心概念",
28
+ "en": "Core Concept"
29
+ },
30
+ "basic": {
31
+ "zh": "基础功能",
32
+ "en": "Basic Features"
33
+ },
34
+ "advanced": {
35
+ "zh": "进阶功能",
36
+ "en": "Advanced Features"
37
+ },
38
+ "topic": {
39
+ "zh": "专题详解",
40
+ "en": "Topic Detail"
41
+ },
42
+ "troubleshooting": {
43
+ "zh": "常见问题",
44
+ "en": "FAQ"
45
+ },
46
+ "data-solution": {
47
+ "zh": "数据管理",
48
+ "en": "Data Solution"
49
+ },
50
+ "rendering": {
51
+ "zh": "渲染",
52
+ "en": "Rendering"
53
+ },
54
+ "use-bff": {
55
+ "zh": "使用 BFF",
56
+ "en": "Using BFF"
57
+ },
58
+ "use-ssr": {
59
+ "zh": "服务端渲染",
60
+ "en": "SSR"
61
+ },
62
+ "micro-frontend": {
63
+ "zh": "微前端",
64
+ "en": "Micro Frontend"
65
+ },
66
+ "framework-plugin": {
67
+ "zh": "框架插件",
68
+ "en": "Framework Plugin"
69
+ },
70
+ "reduck": {
71
+ "zh": "Reduck 状态管理",
72
+ "en": "Reduck State Manager"
73
+ },
74
+ "generator": {
75
+ "zh": "项目生成器",
76
+ "en": "Project Generator"
77
+ },
78
+ "new-command": {
79
+ "zh": "New 命令",
80
+ "en": "New Command"
81
+ },
82
+ "generator-plugin": {
83
+ "zh": "生成器插件",
84
+ "en": "Generator Plugin"
85
+ },
86
+ "examples": {
87
+ "zh": "示例",
88
+ "en": "Examples"
89
+ },
90
+ "first-app": {
91
+ "zh": "第一个应用",
92
+ "en": "First App"
93
+ },
94
+ "foundations": {
95
+ "zh": "基础",
96
+ "en": "Foundations"
97
+ },
98
+ "file-conventions": {
99
+ "zh": "文件约定",
100
+ "en": "File Conventions"
101
+ },
102
+ "runtime-api": {
103
+ "zh": "运行时",
104
+ "en": "Runtime"
105
+ },
106
+ "blog": {
107
+ "zh": "博客",
108
+ "en": "Blog"
109
+ }
110
+ }
package/package.json CHANGED
@@ -15,32 +15,31 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.58.0",
18
+ "version": "2.58.2",
19
19
  "publishConfig": {
20
20
  "registry": "https://registry.npmjs.org/",
21
21
  "access": "public",
22
22
  "provenance": true
23
23
  },
24
24
  "dependencies": {
25
- "@modern-js/sandpack-react": "2.58.0"
25
+ "@modern-js/sandpack-react": "2.58.2"
26
26
  },
27
27
  "peerDependencies": {
28
- "@modern-js/builder-doc": "^2.58.0"
28
+ "@modern-js/builder-doc": "^2.58.2"
29
29
  },
30
30
  "devDependencies": {
31
+ "@rspress/shared": "1.27.0",
32
+ "@types/fs-extra": "9.0.13",
33
+ "@types/node": "^16",
31
34
  "classnames": "^2",
32
35
  "clsx": "^1.2.1",
36
+ "fs-extra": "^10",
33
37
  "react": "^18",
34
38
  "react-dom": "^18",
39
+ "rspress": "1.27.0",
35
40
  "ts-node": "^10.9.1",
36
41
  "typescript": "^5",
37
- "fs-extra": "^10",
38
- "rspress": "1.26.1",
39
- "@rspress/shared": "1.26.1",
40
- "@types/node": "^16",
41
- "@types/fs-extra": "9.0.13",
42
- "@modern-js/doc-plugin-auto-sidebar": "2.58.0",
43
- "@modern-js/builder-doc": "2.58.0"
42
+ "@modern-js/builder-doc": "2.58.2"
44
43
  },
45
44
  "scripts": {
46
45
  "dev": "rspress dev",
package/rspress.config.ts CHANGED
@@ -1,15 +1,6 @@
1
1
  import path from 'path';
2
2
  import { defineConfig } from 'rspress/config';
3
- import { NavItem } from '@rspress/shared';
4
- import { pluginAutoSidebar } from '@modern-js/doc-plugin-auto-sidebar';
5
-
6
- const rootCategories = [
7
- 'tutorials',
8
- 'guides',
9
- 'apis/app',
10
- 'configure/app',
11
- 'community',
12
- ];
3
+ import type { NavItem } from '@rspress/shared';
13
4
 
14
5
  const { version } = require('./package.json');
15
6
 
@@ -104,7 +95,7 @@ export default defineConfig({
104
95
  title: 'Modern.js',
105
96
  description:
106
97
  'A Progressive React Framework for modern web development.',
107
- nav: getNavbar('zh'),
98
+ // nav: getNavbar('zh'),
108
99
  label: '简体中文',
109
100
  },
110
101
  {
@@ -112,7 +103,7 @@ export default defineConfig({
112
103
  title: 'Modern.js',
113
104
  description:
114
105
  'A Progressive React Framework for modern web development.',
115
- nav: getNavbar('en'),
106
+ // nav: getNavbar('en'),
116
107
  label: 'English',
117
108
  },
118
109
  ],
@@ -158,12 +149,4 @@ export default defineConfig({
158
149
  },
159
150
  },
160
151
  },
161
- plugins: [
162
- pluginAutoSidebar({
163
- root: docPath,
164
- categories: ['zh', 'en'].flatMap(lang =>
165
- rootCategories.map(category => `${lang}/${category}`),
166
- ),
167
- }),
168
- ],
169
152
  });
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import type React from 'react';
2
2
  import cl from 'classnames';
3
3
  import { withBase } from 'rspress/runtime';
4
4
  import styles from './index.module.scss';