@rspress/core 2.0.0-rc.1 → 2.0.0-rc.3

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 (307) hide show
  1. package/bin/rspress.js +1 -1
  2. package/dist/0~7675.723d12b2.js +1794 -0
  3. package/dist/3521.56e42d70.js +56 -0
  4. package/dist/4669.12208c6a.js +2 -0
  5. package/dist/5485.077f14ff.js +98 -0
  6. package/dist/6289.c67fe0d5.js +5 -0
  7. package/dist/8813.9da1f210.js +2 -0
  8. package/dist/9643.f109822d.js +5 -0
  9. package/dist/_private/react/render.js +17 -4
  10. package/dist/cli/config/index.js +4 -0
  11. package/dist/cli/config/loadConfigFile.js +30 -0
  12. package/dist/cli/index.cb89dbd1.js +3 -0
  13. package/dist/cli/index.js +122 -0
  14. package/dist/eject-theme/components/Badge/index.scss +1 -0
  15. package/dist/eject-theme/components/Banner/index.tsx +6 -5
  16. package/dist/eject-theme/components/Callout/index.scss +0 -2
  17. package/dist/eject-theme/components/Callout/index.tsx +8 -2
  18. package/dist/eject-theme/components/CodeBlock/index.scss +12 -18
  19. package/dist/eject-theme/components/CodeBlock/index.tsx +10 -1
  20. package/dist/eject-theme/components/CodeBlockRuntime/index.tsx +50 -11
  21. package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +1 -3
  22. package/dist/eject-theme/components/CodeButtonGroup/index.scss +5 -1
  23. package/dist/eject-theme/components/CodeButtonGroup/index.tsx +1 -3
  24. package/dist/eject-theme/components/DocContent/doc.scss +27 -7
  25. package/dist/eject-theme/components/DocContent/docComponents/pre.tsx +2 -1
  26. package/dist/eject-theme/components/DocContent/docComponents/table.tsx +10 -4
  27. package/dist/eject-theme/components/DocContent/index.tsx +21 -4
  28. package/dist/eject-theme/components/DocFooter/index.tsx +1 -6
  29. package/dist/eject-theme/components/{DocContent/FallbackHeading.tsx → FallbackHeading/index.tsx} +20 -11
  30. package/dist/eject-theme/components/HoverGroup/index.scss +1 -1
  31. package/dist/eject-theme/components/LastUpdated/index.tsx +8 -1
  32. package/dist/eject-theme/components/Link/index.tsx +22 -6
  33. package/dist/eject-theme/components/Nav/NavMenu.tsx +2 -3
  34. package/dist/eject-theme/components/NavHamburger/index.tsx +3 -4
  35. package/dist/eject-theme/components/NavScreen/NavScreenLangs.scss +6 -0
  36. package/dist/eject-theme/components/NavScreen/NavScreenLangs.tsx +23 -9
  37. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +2 -3
  38. package/dist/eject-theme/components/NavScreen/NavScreenVersions.scss +6 -0
  39. package/dist/eject-theme/components/NavScreen/NavScreenVersions.tsx +22 -9
  40. package/dist/eject-theme/components/Overview/index.tsx +7 -8
  41. package/dist/eject-theme/components/{Overview/OverviewGroup.scss → OverviewGroup/index.scss} +66 -12
  42. package/dist/eject-theme/components/{Overview/OverviewGroup.tsx → OverviewGroup/index.tsx} +51 -5
  43. package/dist/eject-theme/components/PackageManagerTabs/index.tsx +12 -0
  44. package/dist/eject-theme/components/PrevNextPage/index.tsx +6 -3
  45. package/dist/eject-theme/components/Root/index.tsx +58 -0
  46. package/dist/eject-theme/components/Search/NoSearchResult.tsx +2 -3
  47. package/dist/eject-theme/components/Search/SearchButton.tsx +3 -4
  48. package/dist/eject-theme/components/Search/SearchPanel.tsx +12 -7
  49. package/dist/eject-theme/components/Search/SuggestItem.tsx +15 -12
  50. package/dist/eject-theme/components/Search/logic/util.test.ts +1 -1
  51. package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +2 -3
  52. package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +1 -0
  53. package/dist/eject-theme/components/SidebarMenu/index.tsx +4 -4
  54. package/dist/eject-theme/components/SocialLinks/index.tsx +2 -3
  55. package/dist/eject-theme/components/SourceCode/index.tsx +6 -4
  56. package/dist/eject-theme/components/SwitchAppearance/index.tsx +3 -5
  57. package/dist/eject-theme/components/Tabs/index.scss +31 -26
  58. package/dist/eject-theme/components/Tabs/index.tsx +16 -0
  59. package/dist/eject-theme/components/Tag/index.tsx +84 -5
  60. package/dist/eject-theme/components/Toc/TocItem.scss +3 -3
  61. package/dist/eject-theme/components/Toc/TocItem.tsx +1 -0
  62. package/dist/index.d.ts +6 -6
  63. package/dist/index.js +16 -3134
  64. package/dist/node/PluginDriver.d.ts +1 -1
  65. package/dist/node/PluginDriver.js +142 -0
  66. package/dist/node/auto-nav-sidebar/index.js +44 -0
  67. package/dist/node/auto-nav-sidebar/locales.js +26 -0
  68. package/dist/node/auto-nav-sidebar/normalize.js +230 -0
  69. package/dist/node/auto-nav-sidebar/utils.js +68 -0
  70. package/dist/node/auto-nav-sidebar/walk.js +67 -0
  71. package/dist/node/build.js +31 -0
  72. package/dist/node/constants.d.ts +2 -0
  73. package/dist/node/constants.js +34 -0
  74. package/dist/node/dev.js +32 -0
  75. package/dist/node/eject.js +111 -0
  76. package/dist/node/index.d.ts +5 -5
  77. package/dist/node/initRsbuild.d.ts +2 -2
  78. package/dist/node/initRsbuild.js +346 -0
  79. package/dist/node/last-updated/index.js +28 -0
  80. package/dist/node/logger/hint.d.ts +1 -1
  81. package/dist/node/logger/hint.js +85 -0
  82. package/dist/node/mdx/loader.d.ts +1 -1
  83. package/dist/node/mdx/loader.e1578c62.js +13 -0
  84. package/dist/{loader.js → node/mdx/loader.js} +4 -3
  85. package/dist/node/mdx/options.d.ts +2 -2
  86. package/dist/node/mdx/options.js +103 -0
  87. package/dist/node/mdx/processor.d.ts +2 -2
  88. package/dist/node/mdx/processor.js +71 -0
  89. package/dist/node/mdx/rehypePlugins/codeMeta.js +10 -0
  90. package/dist/node/mdx/rehypePlugins/headerAnchor.js +53 -0
  91. package/dist/node/mdx/rehypePlugins/shiki.js +34 -0
  92. package/dist/node/mdx/rehypePlugins/transformers/add-lang.js +15 -0
  93. package/dist/node/mdx/rehypePlugins/transformers/add-line-numbers.js +22 -0
  94. package/dist/node/mdx/rehypePlugins/transformers/add-title.js +24 -0
  95. package/dist/node/mdx/rehypePlugins/transformers/add-wrap-code.js +22 -0
  96. package/dist/node/mdx/rehypePlugins/transformers/index.d.ts +5 -5
  97. package/dist/node/mdx/rehypePlugins/transformers/index.js +5 -0
  98. package/dist/node/mdx/rehypePlugins/transformers/meta-highlight.js +41 -0
  99. package/dist/node/mdx/remarkPlugins/builtin.js +11 -0
  100. package/dist/node/mdx/remarkPlugins/containerSyntax.js +190 -0
  101. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +66 -0
  102. package/dist/node/mdx/remarkPlugins/image.js +67 -0
  103. package/dist/node/mdx/remarkPlugins/link.d.ts +1 -1
  104. package/dist/node/mdx/remarkPlugins/link.js +99 -0
  105. package/dist/node/mdx/remarkPlugins/toc.js +50 -0
  106. package/dist/node/mdx/types.d.ts +3 -3
  107. package/dist/node/medium-zoom/index.d.ts +1 -1
  108. package/dist/node/medium-zoom/index.js +14 -0
  109. package/dist/node/route/RoutePage.d.ts +1 -1
  110. package/dist/node/route/RoutePage.js +61 -0
  111. package/dist/node/route/RouteService.d.ts +1 -1
  112. package/dist/node/route/RouteService.js +177 -0
  113. package/dist/node/route/extractPageData.d.ts +1 -1
  114. package/dist/node/route/extractPageData.js +112 -0
  115. package/dist/node/route/normalizeRoutePath.js +54 -0
  116. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +21 -0
  117. package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +150 -0
  118. package/dist/node/runtimeModule/globalStyles.d.ts +1 -1
  119. package/dist/node/runtimeModule/globalStyles.js +12 -0
  120. package/dist/node/runtimeModule/globalUIComponents.d.ts +1 -1
  121. package/dist/node/runtimeModule/globalUIComponents.js +25 -0
  122. package/dist/node/runtimeModule/i18n.d.ts +2 -2
  123. package/dist/node/runtimeModule/i18n.js +83 -0
  124. package/dist/node/runtimeModule/pageData/createPageData.d.ts +1 -1
  125. package/dist/node/runtimeModule/pageData/createPageData.js +64 -0
  126. package/dist/node/runtimeModule/pageData/rsbuildPlugin.d.ts +1 -1
  127. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +51 -0
  128. package/dist/node/runtimeModule/routeList.d.ts +1 -1
  129. package/dist/node/runtimeModule/routeList.js +7 -0
  130. package/dist/node/runtimeModule/searchHooks.d.ts +1 -1
  131. package/dist/node/runtimeModule/searchHooks.js +11 -0
  132. package/dist/node/runtimeModule/siteData/createSiteData.js +34 -0
  133. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +94 -0
  134. package/dist/node/runtimeModule/siteData/rsbuildPlugin.d.ts +1 -1
  135. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +24 -0
  136. package/dist/node/runtimeModule/socialLinks.d.ts +1 -1
  137. package/dist/node/runtimeModule/socialLinks.js +8 -0
  138. package/dist/node/runtimeModule/types.d.ts +2 -2
  139. package/dist/node/serve.js +23 -0
  140. package/dist/node/ssg/renderHtmlTemplate.js +33 -0
  141. package/dist/node/ssg/renderPage.js +34 -0
  142. package/dist/node/ssg/renderPageWorker.474f9f73.js +2 -0
  143. package/dist/node/ssg/renderPageWorker.js +15 -0
  144. package/dist/node/ssg/renderPages.d.ts +1 -1
  145. package/dist/node/ssg/renderPages.js +105 -0
  146. package/dist/node/ssg/renderPages.js.LICENSE.txt +4 -0
  147. package/dist/node/ssg/rsbuildPluginCSR.d.ts +1 -1
  148. package/dist/node/ssg/rsbuildPluginCSR.js +27 -0
  149. package/dist/node/ssg/rsbuildPluginSSG.d.ts +1 -1
  150. package/dist/node/ssg/rsbuildPluginSSG.js +72 -0
  151. package/dist/node/ssg/ssgEnv.js +33 -0
  152. package/dist/node/ssg/ssgEnv.js.LICENSE.txt +5 -0
  153. package/dist/node/ssg-md/llms/emitLlmsTxt.d.ts +1 -1
  154. package/dist/node/ssg-md/llms/emitLlmsTxt.js +84 -0
  155. package/dist/node/ssg-md/llms/llmsTxt.d.ts +1 -1
  156. package/dist/node/ssg-md/llms/llmsTxt.js +66 -0
  157. package/dist/node/ssg-md/react/index.d.ts +1 -1
  158. package/dist/node/ssg-md/remarkSplitMdx.js +244 -0
  159. package/dist/node/ssg-md/renderPage.js +31 -0
  160. package/dist/node/ssg-md/renderPages.d.ts +1 -1
  161. package/dist/node/ssg-md/renderPages.js +27 -0
  162. package/dist/node/ssg-md/rsbuildPluginSSGMD.d.ts +1 -1
  163. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +47 -0
  164. package/dist/node/utils/applyReplaceRules.js +6 -0
  165. package/dist/node/utils/checkLanguageParity.js +77 -0
  166. package/dist/node/utils/createHash.js +5 -0
  167. package/dist/node/utils/error.d.ts +9 -0
  168. package/dist/node/utils/error.js +10 -0
  169. package/dist/node/utils/escapeHeadingIds.js +5 -0
  170. package/dist/node/utils/flattenMdxContent.js +74 -0
  171. package/dist/node/utils/fs.js +14 -0
  172. package/dist/node/utils/getImportAstNode.js +63 -0
  173. package/dist/node/utils/getPageKey.js +6 -0
  174. package/dist/node/utils/getSocialIcons.js +32 -0
  175. package/dist/node/utils/index.d.ts +10 -9
  176. package/dist/node/utils/normalizePath.js +10 -0
  177. package/dist/node/utils/reactAlias.d.ts +2 -0
  178. package/dist/node/utils/reactAlias.js +83 -0
  179. package/dist/rslib-runtime.99091bf6.js +18 -0
  180. package/dist/runtime/App.js +2 -2
  181. package/dist/runtime/ClientApp.d.ts +1 -1
  182. package/dist/runtime/ClientApp.js +0 -4
  183. package/dist/runtime/initPageData.js +1 -1
  184. package/dist/runtime/ssrMdServerEntry.js +1 -1
  185. package/dist/runtime/ssrServerEntry.js +2 -1
  186. package/dist/runtime.72d450ac.js +1 -0
  187. package/dist/runtime.js +3 -2
  188. package/dist/shiki-transformers.d.ts +1 -1
  189. package/dist/shiki-transformers.js +6 -120
  190. package/dist/theme/assets/deprecated.js +18 -0
  191. package/dist/theme/assets/experimental.js +21 -0
  192. package/dist/theme/components/Badge/index.css +1 -0
  193. package/dist/theme/components/Banner/index.d.ts +1 -1
  194. package/dist/theme/components/Banner/index.js +4 -5
  195. package/dist/theme/components/Callout/index.css +0 -2
  196. package/dist/theme/components/Callout/index.js +5 -2
  197. package/dist/theme/components/CodeBlock/index.css +11 -21
  198. package/dist/theme/components/CodeBlock/index.js +5 -1
  199. package/dist/theme/components/CodeBlockRuntime/index.d.ts +1 -1
  200. package/dist/theme/components/CodeBlockRuntime/index.js +38 -8
  201. package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +3 -5
  202. package/dist/theme/components/CodeButtonGroup/index.css +5 -1
  203. package/dist/theme/components/CodeButtonGroup/index.js +3 -5
  204. package/dist/theme/components/DocContent/doc.css +28 -7
  205. package/dist/theme/components/DocContent/docComponents/index.d.ts +3 -3
  206. package/dist/theme/components/DocContent/docComponents/pre.js +3 -1
  207. package/dist/theme/components/DocContent/docComponents/table.d.ts +2 -2
  208. package/dist/theme/components/DocContent/docComponents/table.js +8 -3
  209. package/dist/theme/components/DocContent/index.d.ts +11 -2
  210. package/dist/theme/components/DocContent/index.js +6 -6
  211. package/dist/theme/components/DocFooter/index.js +1 -5
  212. package/dist/theme/components/{DocContent/FallbackHeading.js → FallbackHeading/index.js} +19 -11
  213. package/dist/theme/components/HoverGroup/index.css +3 -3
  214. package/dist/theme/components/HoverGroup/useHoverGroup.d.ts +1 -1
  215. package/dist/theme/components/LastUpdated/index.d.ts +1 -1
  216. package/dist/theme/components/LastUpdated/index.js +5 -1
  217. package/dist/theme/components/Link/index.d.ts +1 -1
  218. package/dist/theme/components/Link/index.js +17 -7
  219. package/dist/theme/components/Nav/NavMenu.js +2 -3
  220. package/dist/theme/components/NavHamburger/index.js +3 -4
  221. package/dist/theme/components/NavScreen/NavScreenLangs.css +6 -0
  222. package/dist/theme/components/NavScreen/NavScreenLangs.js +13 -3
  223. package/dist/theme/components/NavScreen/NavScreenMenuItem.js +2 -3
  224. package/dist/theme/components/NavScreen/NavScreenVersions.css +6 -0
  225. package/dist/theme/components/NavScreen/NavScreenVersions.js +12 -3
  226. package/dist/theme/components/Overview/index.d.ts +0 -1
  227. package/dist/theme/components/Overview/index.js +2 -3
  228. package/dist/theme/components/{Overview/OverviewGroup.css → OverviewGroup/index.css} +60 -8
  229. package/dist/theme/components/{Overview/OverviewGroup.d.ts → OverviewGroup/index.d.ts} +1 -1
  230. package/dist/theme/components/OverviewGroup/index.js +88 -0
  231. package/dist/theme/components/PackageManagerTabs/index.d.ts +1 -1
  232. package/dist/theme/components/PackageManagerTabs/index.js +4 -0
  233. package/dist/theme/components/PrevNextPage/index.js +3 -4
  234. package/dist/theme/components/Root/index.d.ts +54 -0
  235. package/dist/theme/components/Root/index.js +7 -0
  236. package/dist/theme/components/Search/NoSearchResult.js +2 -3
  237. package/dist/theme/components/Search/SearchButton.js +3 -4
  238. package/dist/theme/components/Search/SearchPanel.js +12 -15
  239. package/dist/theme/components/Search/SuggestItem.d.ts +1 -1
  240. package/dist/theme/components/Search/SuggestItem.js +7 -11
  241. package/dist/theme/components/Search/logic/Provider.d.ts +1 -1
  242. package/dist/theme/components/Search/logic/providers/LocalProvider.d.ts +2 -2
  243. package/dist/theme/components/Search/logic/search.d.ts +1 -1
  244. package/dist/theme/components/Search/logic/util.test.js +1 -1
  245. package/dist/theme/components/Sidebar/SidebarGroup.js +2 -3
  246. package/dist/theme/components/Sidebar/SidebarItem.js +1 -0
  247. package/dist/theme/components/SidebarMenu/index.js +3 -5
  248. package/dist/theme/components/SocialLinks/index.js +2 -3
  249. package/dist/theme/components/SourceCode/index.js +2 -4
  250. package/dist/theme/components/SwitchAppearance/index.js +3 -5
  251. package/dist/theme/components/Tabs/index.css +19 -27
  252. package/dist/theme/components/Tabs/index.js +9 -0
  253. package/dist/theme/components/Tag/index.d.ts +3 -0
  254. package/dist/theme/components/Tag/index.js +63 -8
  255. package/dist/theme/components/Toc/TocItem.css +2 -3
  256. package/dist/theme/components/Toc/TocItem.js +1 -0
  257. package/dist/theme/hooks/useActiveAnchor.js +1 -1
  258. package/dist/theme/icons.d.ts +27 -0
  259. package/dist/theme/icons.js +51 -0
  260. package/dist/theme/index.d.ts +64 -59
  261. package/dist/theme/index.js +7 -2
  262. package/dist/theme/layout/DocLayout/index.css +2 -4
  263. package/dist/theme/layout/Layout/index.js +1 -2
  264. package/dist/theme/layout/NotFountLayout/index.js +1 -1
  265. package/dist/theme/logic/useAppearance.js +1 -1
  266. package/dist/theme/logic/useFullTextSearch.d.ts +1 -1
  267. package/dist/theme/logic/useMediaQuery.js +1 -1
  268. package/dist/theme/styles/base.css +1 -0
  269. package/dist/theme/styles/scrollbar.css +1 -0
  270. package/dist/theme/styles/shiki.css +9 -3
  271. package/dist/theme/styles/vars/base-vars.css +7 -5
  272. package/dist/theme/styles/vars/code-vars.css +2 -0
  273. package/dist/theme/styles/vars/home-vars.css +2 -1
  274. package/package.json +22 -23
  275. package/dist/3~128.js +0 -74
  276. package/dist/3~517.js +0 -1786
  277. package/dist/3~894.js +0 -26
  278. package/dist/cli.js +0 -259
  279. package/dist/index.js.LICENSE.txt +0 -10
  280. package/dist/node/auto-nav-sidebar/fixtures/docs/guide/c.d.ts +0 -2
  281. package/dist/node/auto-nav-sidebar/fixtures/docs-locales/en/guide/c.d.ts +0 -2
  282. package/dist/node/auto-nav-sidebar/fixtures/docs-locales/zh/guide/c.d.ts +0 -2
  283. package/dist/node/auto-nav-sidebar/locales.test.d.ts +0 -1
  284. package/dist/node/auto-nav-sidebar/walk.test.d.ts +0 -1
  285. package/dist/node/mdx/rehypePlugins/headerAnchor.test.d.ts +0 -1
  286. package/dist/node/mdx/remarkPlugins/containerSyntax.test.d.ts +0 -1
  287. package/dist/node/mdx/remarkPlugins/fileCodeBlock.test.d.ts +0 -1
  288. package/dist/node/mdx/remarkPlugins/image.test.d.ts +0 -1
  289. package/dist/node/mdx/remarkPlugins/link.test.d.ts +0 -1
  290. package/dist/node/route/RouteService.test.d.ts +0 -1
  291. package/dist/node/route/extractPageData.test.d.ts +0 -1
  292. package/dist/node/route/fixtures/basic/guide/c.d.ts +0 -2
  293. package/dist/node/route/normalizeRoutePath.test.d.ts +0 -1
  294. package/dist/node/runtimeModule/i18n.test.d.ts +0 -1
  295. package/dist/node/ssg-md/remarkSplitMdx.test.d.ts +0 -4
  296. package/dist/node/utils/checkLanguageParity.test.d.ts +0 -1
  297. package/dist/node/utils/detectCustomIcon.d.ts +0 -1
  298. package/dist/node/utils/detectReactVersion.d.ts +0 -3
  299. package/dist/processor.js +0 -4539
  300. package/dist/renderPageWorker.js +0 -196
  301. package/dist/theme/components/Overview/OverviewGroup.js +0 -58
  302. package/dist/theme/components/Search/logic/util.test.d.ts +0 -1
  303. /package/dist/cli/{config.d.ts → config/index.d.ts} +0 -0
  304. /package/dist/eject-theme/components/{Overview → OverviewGroup}/icons/plugin.svg +0 -0
  305. /package/dist/{shiki-transformers.js.LICENSE.txt → node/mdx/rehypePlugins/transformers/meta-highlight.js.LICENSE.txt} +0 -0
  306. /package/dist/theme/components/{DocContent/FallbackHeading.d.ts → FallbackHeading/index.d.ts} +0 -0
  307. /package/dist/theme/components/{Overview → OverviewGroup}/icons/plugin.js +0 -0
@@ -0,0 +1,32 @@
1
+ import { PluginDriver } from "./PluginDriver.js";
2
+ import { RouteService } from "./route/RouteService.js";
3
+ import { initRsbuild } from "./initRsbuild.js";
4
+ import { checkLanguageParity } from "./utils/checkLanguageParity.js";
5
+ async function dev(options) {
6
+ const { docDirectory, config, extraBuilderConfig, configFilePath } = options;
7
+ const isProd = false;
8
+ const pluginDriver = await PluginDriver.create(config, configFilePath, isProd);
9
+ const modifiedConfig = await pluginDriver.modifyConfig();
10
+ try {
11
+ const additionalPages = await pluginDriver.addPages();
12
+ const routeService = await RouteService.create({
13
+ config: modifiedConfig,
14
+ scanDir: docDirectory,
15
+ externalPages: additionalPages
16
+ });
17
+ await pluginDriver.routeGenerated(routeService.getRoutes());
18
+ await pluginDriver.routeServiceGenerated(routeService);
19
+ await pluginDriver.beforeBuild();
20
+ const rsbuild = await initRsbuild(docDirectory, modifiedConfig, pluginDriver, routeService, false, extraBuilderConfig);
21
+ rsbuild.onAfterDevCompile(async ()=>{
22
+ await pluginDriver.afterBuild();
23
+ });
24
+ const { server } = await rsbuild.startDevServer({
25
+ getPortSilently: true
26
+ });
27
+ return server;
28
+ } finally{
29
+ await checkLanguageParity(modifiedConfig);
30
+ }
31
+ }
32
+ export { dev };
@@ -0,0 +1,111 @@
1
+ import { node_path, logger, promises, picocolors } from "../6289.c67fe0d5.js";
2
+ import { EJECTED_THEME } from "./constants.js";
3
+ let _themeComponentsPathOverride;
4
+ function __setThemeComponentsPathForTesting(themePath) {
5
+ _themeComponentsPathOverride = themePath;
6
+ }
7
+ function getThemeComponentsPath() {
8
+ if (_themeComponentsPathOverride) return _themeComponentsPathOverride;
9
+ return node_path.join(EJECTED_THEME, 'components');
10
+ }
11
+ async function getAvailableComponents() {
12
+ return [
13
+ 'Banner',
14
+ 'Badge',
15
+ 'Callout',
16
+ 'DocFooter',
17
+ 'FallbackHeading',
18
+ 'HomeFeature',
19
+ 'HomeHero',
20
+ 'HomeBackground',
21
+ 'HomeFooter',
22
+ 'SourceCode',
23
+ 'Toc',
24
+ 'Tabs',
25
+ 'Tag',
26
+ 'PackageManagerTabs',
27
+ 'PrevNextPage',
28
+ 'OverviewGroup',
29
+ 'Root',
30
+ 'SocialLinks',
31
+ 'Steps'
32
+ ];
33
+ }
34
+ async function componentExists(componentName) {
35
+ const themePath = getThemeComponentsPath();
36
+ const componentPath = node_path.join(themePath, componentName);
37
+ try {
38
+ const stat = await promises.stat(componentPath);
39
+ return stat.isDirectory();
40
+ } catch {
41
+ return false;
42
+ }
43
+ }
44
+ async function copyDir(src, dest) {
45
+ await promises.mkdir(dest, {
46
+ recursive: true
47
+ });
48
+ const entries = await promises.readdir(src, {
49
+ withFileTypes: true
50
+ });
51
+ for (const entry of entries){
52
+ const srcPath = node_path.join(src, entry.name);
53
+ const destPath = node_path.join(dest, entry.name);
54
+ if (entry.isDirectory()) await copyDir(srcPath, destPath);
55
+ else await promises.copyFile(srcPath, destPath);
56
+ }
57
+ }
58
+ async function transformImports(filePath) {
59
+ const content = await promises.readFile(filePath, 'utf-8');
60
+ const transformed = content;
61
+ if (transformed !== content) await promises.writeFile(filePath, transformed, 'utf-8');
62
+ }
63
+ async function transformDirectory(dir) {
64
+ const entries = await promises.readdir(dir, {
65
+ withFileTypes: true
66
+ });
67
+ for (const entry of entries){
68
+ const fullPath = node_path.join(dir, entry.name);
69
+ if (entry.isDirectory()) await transformDirectory(fullPath);
70
+ else if (entry.name.endsWith('.ts') || entry.name.endsWith('.tsx')) await transformImports(fullPath);
71
+ }
72
+ }
73
+ async function ejectComponent(componentName, cwd = process.cwd()) {
74
+ const exists = await componentExists(componentName);
75
+ if (!exists) {
76
+ logger.error(`Component ${picocolors.cyan(componentName)} not found in theme.`);
77
+ const available = await getAvailableComponents();
78
+ logger.info(`\nAvailable components:\n${available.map((c)=>` - ${c}`).join('\n')}`);
79
+ process.exit(1);
80
+ }
81
+ const themePath = getThemeComponentsPath();
82
+ const sourceComponentPath = node_path.join(themePath, componentName);
83
+ const destThemePath = node_path.join(cwd, 'theme', 'components');
84
+ const destComponentPath = node_path.join(destThemePath, componentName);
85
+ try {
86
+ await promises.access(destComponentPath);
87
+ logger.warn(`Component ${picocolors.cyan(componentName)} already exists in ${picocolors.yellow(node_path.relative(cwd, destComponentPath))}`);
88
+ logger.info('Overwriting existing component...');
89
+ } catch {}
90
+ try {
91
+ await promises.mkdir(destThemePath, {
92
+ recursive: true
93
+ });
94
+ await copyDir(sourceComponentPath, destComponentPath);
95
+ await transformDirectory(destComponentPath);
96
+ logger.success(`✨ Component ${picocolors.cyan(componentName)} ejected successfully!`);
97
+ logger.info(`Component files copied to: ${picocolors.green(node_path.relative(cwd, destComponentPath))}\nYou can now customize the component. To use it in your theme, you'll need to:\n 1. Re-export it in your custom \`theme/index.tsx\` file\n 2. Edit it by yourself`);
98
+ } catch (error) {
99
+ logger.error(`Failed to eject component: ${error}`);
100
+ throw error;
101
+ }
102
+ }
103
+ async function listComponents() {
104
+ const components = await getAvailableComponents();
105
+ logger.info(`📦 Available components to eject:\n`);
106
+ components.forEach((component)=>{
107
+ logger.info(` ${picocolors.cyan('•')} ${component}`);
108
+ });
109
+ logger.info(`💡 Usage: ${picocolors.dim('rspress eject <ComponentName>')}\n`);
110
+ }
111
+ export { __setThemeComponentsPathForTesting, ejectComponent, getAvailableComponents, listComponents };
@@ -1,5 +1,5 @@
1
- export { build } from './build';
2
- export { dev } from './dev';
3
- export { remarkFileCodeBlock } from './mdx/remarkPlugins/fileCodeBlock';
4
- export { remarkLink } from './mdx/remarkPlugins/link';
5
- export { serve } from './serve';
1
+ export { build } from './build.js';
2
+ export { dev } from './dev.js';
3
+ export { remarkFileCodeBlock } from './mdx/remarkPlugins/fileCodeBlock.js';
4
+ export { remarkLink } from './mdx/remarkPlugins/link.js';
5
+ export { serve } from './serve.js';
@@ -1,5 +1,5 @@
1
1
  import type { RsbuildConfig, RsbuildInstance } from '@rsbuild/core';
2
2
  import { type UserConfig } from '@rspress/shared';
3
- import type { PluginDriver } from './PluginDriver';
4
- import type { RouteService } from './route/RouteService';
3
+ import type { PluginDriver } from './PluginDriver.js';
4
+ import type { RouteService } from './route/RouteService.js';
5
5
  export declare function initRsbuild(rootDir: string, config: UserConfig, pluginDriver: PluginDriver, routeService: RouteService, enableSSG: boolean, extraRsbuildConfig?: RsbuildConfig): Promise<RsbuildInstance>;
@@ -0,0 +1,346 @@
1
+ import { createRequire, fileURLToPath, package_namespaceObject } from "../5485.077f14ff.js";
2
+ import { node_path } from "../6289.c67fe0d5.js";
3
+ import { cwd } from "../9643.f109822d.js";
4
+ import { PLUGIN_REACT_NAME, pluginReact, pluginVirtualModule } from "../3521.56e42d70.js";
5
+ import { removeTrailingSlash, MDX_OR_MD_REGEXP } from "../4669.12208c6a.js";
6
+ import { createError } from "./utils/error.js";
7
+ import { PUBLIC_DIR, CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, inlineThemeScript, NODE_SSG_BUNDLE_FOLDER, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
8
+ import { hintBuilderPluginsBreakingChange, hintThemeBreakingChange } from "./logger/hint.js";
9
+ import { resolveReactRouterDomAlias, resolveReactAlias } from "./utils/reactAlias.js";
10
+ import { rsbuildPluginDocVM } from "./runtimeModule/pageData/rsbuildPlugin.js";
11
+ import { socialLinksVMPlugin } from "./runtimeModule/socialLinks.js";
12
+ import { i18nVMPlugin } from "./runtimeModule/i18n.js";
13
+ import { globalUIComponentsVMPlugin } from "./runtimeModule/globalUIComponents.js";
14
+ import { globalStylesVMPlugin } from "./runtimeModule/globalStyles.js";
15
+ import { searchHookVMPlugin } from "./runtimeModule/searchHooks.js";
16
+ import { routeListVMPlugin } from "./runtimeModule/routeList.js";
17
+ import { siteDataVMPlugin } from "./runtimeModule/siteData/rsbuildPlugin.js";
18
+ import { rsbuildPluginSSG } from "./ssg/rsbuildPluginSSG.js";
19
+ import { rsbuildPluginCSR } from "./ssg/rsbuildPluginCSR.js";
20
+ import { rsbuildPluginSSGMD } from "./ssg-md/rsbuildPluginSSGMD.js";
21
+ function isPluginIncluded(config, pluginName) {
22
+ return Boolean(config.builderConfig?.plugins?.some((plugin)=>plugin && plugin.name === pluginName));
23
+ }
24
+ const initRsbuild_require = createRequire(import.meta.url);
25
+ async function getVirtualModulesFromPlugins(pluginDriver) {
26
+ const runtimeModule = {};
27
+ const modulesByPlugin = await pluginDriver.addRuntimeModules();
28
+ Object.keys(modulesByPlugin).forEach((key)=>{
29
+ if (runtimeModule[key]) throw createError(`The runtime module ${key} is duplicated, please check your plugin`);
30
+ runtimeModule[key] = ()=>modulesByPlugin[key];
31
+ });
32
+ return runtimeModule;
33
+ }
34
+ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver) {
35
+ const CUSTOM_THEME_DIR = node_path.isAbsolute(config.themeDir) ? config.themeDir : node_path.join(cwd(), config.themeDir);
36
+ const outDir = config?.outDir ?? OUTPUT_DIR;
37
+ const base = config?.base ?? '';
38
+ const assetPrefix = isProduction() ? removeTrailingSlash(config?.builderConfig?.output?.assetPrefix ?? base) : '';
39
+ const normalizeIcon = (icon)=>{
40
+ if (!icon) return;
41
+ icon = icon.toString();
42
+ if (icon.startsWith('file://')) icon = fileURLToPath(icon);
43
+ else if (node_path.isAbsolute(icon)) return node_path.join(userDocRoot, PUBLIC_DIR, icon);
44
+ return icon;
45
+ };
46
+ await hintThemeBreakingChange(CUSTOM_THEME_DIR);
47
+ const [reactCSRAlias, reactSSRAlias, reactRouterDomAlias] = await Promise.all([
48
+ resolveReactAlias(false),
49
+ enableSSG ? resolveReactAlias(true) : Promise.resolve({}),
50
+ resolveReactRouterDomAlias()
51
+ ]);
52
+ const context = {
53
+ userDocRoot,
54
+ config,
55
+ routeService,
56
+ pluginDriver
57
+ };
58
+ return {
59
+ plugins: [
60
+ ...isPluginIncluded(config, PLUGIN_REACT_NAME) ? [] : [
61
+ pluginReact()
62
+ ],
63
+ rsbuildPluginDocVM({
64
+ config,
65
+ pluginDriver,
66
+ routeService,
67
+ userDocRoot
68
+ }),
69
+ pluginVirtualModule({
70
+ tempDir: '.rspress/runtime',
71
+ virtualModules: {
72
+ ...socialLinksVMPlugin(context),
73
+ ...i18nVMPlugin(context),
74
+ ...globalUIComponentsVMPlugin(context),
75
+ ...globalStylesVMPlugin(context),
76
+ ...searchHookVMPlugin(context),
77
+ ...routeListVMPlugin(context),
78
+ ...await getVirtualModulesFromPlugins(pluginDriver),
79
+ ...siteDataVMPlugin(context)
80
+ }
81
+ }),
82
+ enableSSG && config.ssg ? rsbuildPluginSSG({
83
+ routeService,
84
+ config
85
+ }) : rsbuildPluginCSR({
86
+ routeService,
87
+ config
88
+ }),
89
+ enableSSG && config.llms ? rsbuildPluginSSGMD({
90
+ routeService,
91
+ config
92
+ }) : null
93
+ ],
94
+ server: {
95
+ port: !isProduction() && process.env.PORT ? Number(process.env.PORT) : void 0,
96
+ publicDir: {
97
+ name: node_path.join(userDocRoot, PUBLIC_DIR)
98
+ },
99
+ ...base.length > 0 ? {
100
+ base: removeTrailingSlash(base)
101
+ } : {}
102
+ },
103
+ dev: {
104
+ lazyCompilation: 'false' !== process.env.RSPRESS_LAZY_COMPILATION,
105
+ cliShortcuts: {
106
+ custom: (shortcuts)=>shortcuts.filter(({ key })=>'r' !== key)
107
+ }
108
+ },
109
+ html: {
110
+ title: config?.title ?? DEFAULT_TITLE,
111
+ favicon: normalizeIcon(config?.icon),
112
+ template: TEMPLATE_PATH,
113
+ tags: [
114
+ config.themeConfig?.darkMode !== false ? {
115
+ tag: "script",
116
+ children: inlineThemeScript,
117
+ append: false
118
+ } : null
119
+ ].filter(Boolean)
120
+ },
121
+ output: {
122
+ assetPrefix,
123
+ distPath: {
124
+ root: outDir
125
+ }
126
+ },
127
+ resolve: {
128
+ alias: {
129
+ '@mdx-js/react': initRsbuild_require.resolve('@mdx-js/react'),
130
+ 'react-lazy-with-preload': initRsbuild_require.resolve('react-lazy-with-preload'),
131
+ '@theme': [
132
+ CUSTOM_THEME_DIR,
133
+ DEFAULT_THEME
134
+ ],
135
+ '@rspress/core/theme': [
136
+ CUSTOM_THEME_DIR,
137
+ DEFAULT_THEME
138
+ ],
139
+ '@theme-original': DEFAULT_THEME,
140
+ '@rspress/core/theme-original': DEFAULT_THEME,
141
+ '@rspress/core/runtime': node_path.join(PACKAGE_ROOT, 'dist/runtime.js'),
142
+ '@rspress/core/shiki-transformers': node_path.join(PACKAGE_ROOT, 'dist/shiki-transformers.js')
143
+ }
144
+ },
145
+ source: {
146
+ preEntry: [
147
+ node_path.join(DEFAULT_THEME, './styles/index.js'),
148
+ 'virtual-global-styles',
149
+ '@theme'
150
+ ],
151
+ include: [
152
+ PACKAGE_ROOT
153
+ ],
154
+ define: {
155
+ 'process.env.TEST': JSON.stringify(process.env.TEST)
156
+ }
157
+ },
158
+ performance: {
159
+ ...'false' !== process.env.RSPRESS_PERSISTENT_CACHE ? {
160
+ buildCache: {
161
+ buildDependencies: [
162
+ new URL(import.meta.url).href,
163
+ pluginDriver.getConfigFilePath()
164
+ ],
165
+ cacheDigest: [
166
+ routeService.generateRoutesCode(),
167
+ JSON.stringify(config.themeConfig?.locales?.map((i)=>({
168
+ nav: i.nav,
169
+ sidebar: i.sidebar
170
+ })) ?? {
171
+ nav: config.themeConfig?.nav,
172
+ sidebar: config.themeConfig?.sidebar
173
+ }),
174
+ package_namespaceObject.rE
175
+ ]
176
+ }
177
+ } : {},
178
+ chunkSplit: {
179
+ override: {
180
+ cacheGroups: {
181
+ styles: {
182
+ name: 'styles',
183
+ minSize: 0,
184
+ chunks: 'all',
185
+ test: /\.(?:css|less|sass|scss)$/,
186
+ priority: 99
187
+ }
188
+ }
189
+ }
190
+ }
191
+ },
192
+ tools: {
193
+ bundlerChain (chain, { CHAIN_ID, environment }) {
194
+ const isSsg = 'node' === environment.name;
195
+ const isSsgMd = 'node_md' === environment.name;
196
+ const jsModuleRule = chain.module.rule(CHAIN_ID.RULE.JS);
197
+ const swcLoaderOptions = jsModuleRule.use(CHAIN_ID.USE.SWC).get('options');
198
+ chain.module.rule('MDX').type("javascript/auto").test(MDX_OR_MD_REGEXP).resolve.merge({
199
+ conditionNames: jsModuleRule.resolve.conditionNames.values(),
200
+ mainFields: jsModuleRule.resolve.mainFields.values()
201
+ }).end().oneOf('MDXCompile').use('builtin:swc-loader').loader('builtin:swc-loader').options(swcLoaderOptions).end().use('mdx-loader').loader(fileURLToPath(new URL('./mdx/loader.js', import.meta.url))).options({
202
+ config,
203
+ docDirectory: userDocRoot,
204
+ routeService,
205
+ pluginDriver,
206
+ isSsgMd
207
+ }).end();
208
+ if (chain.plugins.has(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH)) chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).tap((options)=>{
209
+ options[0] ??= {};
210
+ options[0].test = [
211
+ /\.([cm]js|[jt]sx?|flow)$/i,
212
+ MDX_OR_MD_REGEXP
213
+ ];
214
+ options[0].include = [
215
+ /\.([cm]js|[jt]sx?|flow)$/i,
216
+ MDX_OR_MD_REGEXP
217
+ ];
218
+ return options;
219
+ });
220
+ chain.resolve.extensions.prepend('.md').prepend('.mdx').prepend('.mjs');
221
+ chain.module.rule('rspress-css-virtual-module').test(/\.rspress[\\/]runtime[\\/]virtual-global-styles/).merge({
222
+ sideEffects: true
223
+ });
224
+ if (isSsg || isSsgMd) chain.optimization.splitChunks({});
225
+ if (isSsg) {
226
+ chain.output.filename(`${NODE_SSG_BUNDLE_FOLDER}/${NODE_SSG_BUNDLE_NAME}`);
227
+ chain.output.chunkFilename(`${NODE_SSG_BUNDLE_FOLDER}/[name].cjs`);
228
+ } else if (isSsgMd) {
229
+ chain.output.filename(`${NODE_SSG_MD_BUNDLE_FOLDER}/${NODE_SSG_MD_BUNDLE_NAME}`);
230
+ chain.output.chunkFilename(`${NODE_SSG_MD_BUNDLE_FOLDER}/[name].cjs`);
231
+ }
232
+ }
233
+ },
234
+ environments: {
235
+ web: {
236
+ resolve: {
237
+ alias: {
238
+ ...reactCSRAlias,
239
+ ...reactRouterDomAlias
240
+ }
241
+ },
242
+ source: {
243
+ entry: {
244
+ index: enableSSG && isProduction() ? SSR_CLIENT_ENTRY : CSR_CLIENT_ENTRY
245
+ },
246
+ define: {
247
+ 'process.env.__SSR__': JSON.stringify(false),
248
+ 'process.env.__SSR_MD__': JSON.stringify(false)
249
+ }
250
+ },
251
+ output: {
252
+ target: 'web',
253
+ distPath: {
254
+ root: outDir
255
+ }
256
+ },
257
+ tools: {
258
+ rspack: {
259
+ node: {
260
+ __dirname: 'mock',
261
+ __filename: 'mock'
262
+ }
263
+ }
264
+ }
265
+ },
266
+ ...enableSSG && config.ssg ? {
267
+ node: {
268
+ resolve: {
269
+ alias: {
270
+ ...reactSSRAlias,
271
+ ...reactRouterDomAlias
272
+ }
273
+ },
274
+ source: {
275
+ entry: {
276
+ index: SSR_SERVER_ENTRY
277
+ },
278
+ define: {
279
+ 'process.env.__SSR__': JSON.stringify(true),
280
+ 'process.env.__SSR_MD__': JSON.stringify(false)
281
+ }
282
+ },
283
+ performance: {
284
+ printFileSize: {
285
+ compressed: true
286
+ }
287
+ },
288
+ output: {
289
+ emitAssets: false,
290
+ target: 'node',
291
+ minify: false
292
+ }
293
+ }
294
+ } : {},
295
+ ...enableSSG && config.llms ? {
296
+ node_md: {
297
+ resolve: {
298
+ alias: {
299
+ ...reactSSRAlias,
300
+ ...reactRouterDomAlias
301
+ }
302
+ },
303
+ tools: {
304
+ rspack: {
305
+ optimization: {
306
+ moduleIds: 'named',
307
+ chunkIds: 'named'
308
+ }
309
+ }
310
+ },
311
+ source: {
312
+ entry: {
313
+ index: SSG_MD_SERVER_ENTRY
314
+ },
315
+ define: {
316
+ 'process.env.__SSR__': JSON.stringify(true),
317
+ 'process.env.__SSR_MD__': JSON.stringify(true)
318
+ }
319
+ },
320
+ performance: {
321
+ printFileSize: {
322
+ compressed: true
323
+ }
324
+ },
325
+ output: {
326
+ emitAssets: false,
327
+ target: 'node',
328
+ minify: false
329
+ }
330
+ }
331
+ } : {}
332
+ }
333
+ };
334
+ }
335
+ async function initRsbuild(rootDir, config, pluginDriver, routeService, enableSSG, extraRsbuildConfig) {
336
+ const userDocRoot = node_path.resolve(rootDir || config.root);
337
+ hintBuilderPluginsBreakingChange(config);
338
+ const { createRsbuild, mergeRsbuildConfig } = await import("@rsbuild/core");
339
+ const internalRsbuildConfig = await createInternalBuildConfig(userDocRoot, config, enableSSG, routeService, pluginDriver);
340
+ const rsbuild = await createRsbuild({
341
+ callerName: 'rspress',
342
+ rsbuildConfig: mergeRsbuildConfig(internalRsbuildConfig, ...pluginDriver.getPlugins()?.map((plugin)=>plugin.builderConfig ?? {}) || [], config.builderConfig || {}, extraRsbuildConfig || {})
343
+ });
344
+ return rsbuild;
345
+ }
346
+ export { initRsbuild };
@@ -0,0 +1,28 @@
1
+ import { execa } from "../../0~7675.723d12b2.js";
2
+ function transform(timestamp, lang) {
3
+ return new Date(timestamp).toLocaleString(lang || 'zh');
4
+ }
5
+ async function getGitLastUpdatedTimeStamp(filePath) {
6
+ let lastUpdated;
7
+ try {
8
+ const { stdout } = await execa('git', [
9
+ 'log',
10
+ '-1',
11
+ '--format=%at',
12
+ filePath
13
+ ]);
14
+ lastUpdated = 1000 * Number(stdout);
15
+ } catch (_e) {}
16
+ return lastUpdated;
17
+ }
18
+ function pluginLastUpdated() {
19
+ return {
20
+ name: '@rspress/plugin-last-updated',
21
+ async extendPageData (pageData) {
22
+ const { _filepath, lang } = pageData;
23
+ const lastUpdated = await getGitLastUpdatedTimeStamp(_filepath);
24
+ if (lastUpdated) pageData.lastUpdatedTime = transform(lastUpdated, lang);
25
+ }
26
+ };
27
+ }
28
+ export { pluginLastUpdated };
@@ -1,5 +1,5 @@
1
1
  import type { UserConfig } from '@rspress/shared';
2
- import type { NavJson } from '../auto-nav-sidebar/type';
2
+ import type { NavJson } from '../auto-nav-sidebar/type.js';
3
3
  /**
4
4
  * breaking change hint of theme
5
5
  * @see https://github.com/web-infra-dev/rspress/discussions/1891#discussioncomment-12422737
@@ -0,0 +1,85 @@
1
+ import { picocolors, relative, logger, join, readFile } from "../../6289.c67fe0d5.js";
2
+ import { pathExists } from "../utils/fs.js";
3
+ const THEME_DEFAULT_EXPORT_PATTERN = /export\s+default\s+\{/;
4
+ const THEME_OLD_IMPORT_0 = /from\s+['"]rspress\/theme['"]/;
5
+ const THEME_OLD_IMPORT_1 = /from\s+['"]@rspress\/core\/theme['"]/;
6
+ async function hintThemeBreakingChange(customThemeDir) {
7
+ const fileList = [
8
+ 'index.ts',
9
+ 'index.tsx',
10
+ 'index.js',
11
+ 'index.mjs'
12
+ ];
13
+ let useDefaultExportFilePath = null;
14
+ for (const file of fileList){
15
+ const filePath = join(customThemeDir, file);
16
+ if (await pathExists(filePath)) {
17
+ const content = await readFile(filePath, {
18
+ encoding: 'utf-8'
19
+ });
20
+ if (THEME_DEFAULT_EXPORT_PATTERN.test(content)) {
21
+ useDefaultExportFilePath = filePath;
22
+ break;
23
+ }
24
+ if (THEME_OLD_IMPORT_0.test(content) || THEME_OLD_IMPORT_1.test(content)) {
25
+ useDefaultExportFilePath = filePath;
26
+ break;
27
+ }
28
+ }
29
+ }
30
+ if (useDefaultExportFilePath) logger.warn(`[Rspress v2] Breaking Change: The "theme/index.tsx" is now using named export from '@rspress/core/theme-original' instead of default export from 'rspress/theme', please update ${picocolors.greenBright(useDefaultExportFilePath)} (https://github.com/web-infra-dev/rspress/discussions/1891#discussioncomment-12422737).\n`, picocolors.redBright(`
31
+ - import Theme from 'rspress/theme';
32
+ - export default {
33
+ - ...Theme,
34
+ - Layout,
35
+ - };
36
+ - export * from 'rspress/theme';`) + picocolors.greenBright(`
37
+ + import { Layout } from '@rspress/core/theme-original';
38
+
39
+ + export { Layout };
40
+ + export * from '@rspress/core/theme-original';
41
+ `));
42
+ }
43
+ function hintBuilderPluginsBreakingChange(config) {
44
+ if ('builderPlugins' in config && Array.isArray(config.builderPlugins) && config.builderPlugins.length > 0) {
45
+ logger.error(`[Rspress v2] The "builderPlugins" option has been renamed to "builderConfig.plugins", please update your config accordingly (https://rspress.rs/api/config/config-build#builderconfigplugins).\n`, `
46
+ export default defineConfig({
47
+ ${picocolors.redBright(` builderPlugins: [
48
+ pluginFoo()
49
+ ],`)}
50
+ ${picocolors.greenBright(` builderConfig: {
51
+ plugins: [
52
+ pluginFoo()
53
+ ],
54
+ },`)}
55
+ });`);
56
+ process.exit(1);
57
+ }
58
+ }
59
+ function hintSSGFailed() {
60
+ logger.info(`[Rspress v2] \`ssg: true\` requires the source code to support SSR. If the code is not compatible to SSR, the build process will fail. You can try:
61
+ 1. Fix code to make it SSR-compatible.
62
+ 2. Set \`ssg: false\` if the code in node_modules may be difficult to fix, but the SSG feature will be lost.`);
63
+ }
64
+ function hintSSGFalse() {
65
+ logger.info('`ssg: false` detected, SSG will be disabled.');
66
+ }
67
+ function hintReactVersion() {
68
+ logger.info('[Rspress v2] Rspress support React 18 and 19, please confirm that both react and react-dom are installed in package.json with the same version. ');
69
+ }
70
+ function hintNavJsonChangeThenPanic(metaJson, metaJsonDir, docsDir) {
71
+ if (metaJson.some((i)=>'object' == typeof i && ('activeMatch' in i || 'text' in i || 'link' in i || 'items' in i || 'icon' in i || 'ariaLabel' in i || 'target' in i))) {
72
+ const error = new Error('[Rspress v2] Detected that you are still using top level `_meta.json` to configure the nav, but it has been changed to `_nav.json` in Rspress v2. Please rename the top level `_meta.json` to `_nav.json` accordingly.');
73
+ logger.error(error);
74
+ const dir = relative(docsDir, metaJsonDir);
75
+ logger.info(`Please rename "${picocolors.greenBright(join(dir, '_meta.json'))}" to "${picocolors.greenBright(join(dir, '_nav.json'))}".`);
76
+ process.exit(1);
77
+ }
78
+ }
79
+ let isLogged = false;
80
+ function hintRelativeMarkdownLink() {
81
+ if (isLogged) return;
82
+ isLogged = true;
83
+ logger.info('[Rspress v2] Markdown links without "./" prefix are now relative links, e.g: [](guide/getting-started) is equal to [](./guide/getting-started). You can rewrite it to [](/guide/getting-started) to always use absolute links, or use [](./getting-started.md)');
84
+ }
85
+ export { hintBuilderPluginsBreakingChange, hintNavJsonChangeThenPanic, hintReactVersion, hintRelativeMarkdownLink, hintSSGFailed, hintSSGFalse, hintThemeBreakingChange };
@@ -1,3 +1,3 @@
1
1
  import type { Rspack } from '@rsbuild/core';
2
- import type { MdxLoaderOptions } from './types';
2
+ import type { MdxLoaderOptions } from './types.js';
3
3
  export default function mdxLoader(this: Rspack.LoaderContext<MdxLoaderOptions>, source: string): Promise<void>;
@@ -0,0 +1,13 @@
1
+ import rehype from "@shikijs/rehype";
2
+ import rehype_external_links from "rehype-external-links";
3
+ import rehype_raw from "rehype-raw";
4
+ import remark_gfm from "remark-gfm";
5
+ import remark_mdx from "remark-mdx";
6
+ import remark_stringify from "remark-stringify";
7
+ import { unified } from "unified";
8
+ import github_slugger from "github-slugger";
9
+ import { headingRank } from "hast-util-heading-rank";
10
+ import { transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddWrapCode } from "@rspress/core/shiki-transformers";
11
+ import { createCssVariablesTheme } from "shiki";
12
+ import { visitChildren } from "unist-util-visit-children";
13
+ export { createCssVariablesTheme, github_slugger, headingRank, rehype, rehype_external_links, rehype_raw, remark_gfm, remark_mdx, remark_stringify, transformerAddLang, transformerAddLineNumbers, transformerAddTitle, transformerAddWrapCode, unified, visitChildren };
@@ -1,4 +1,4 @@
1
- import { compile, compileWithCrossCompilerCache } from "./processor.js";
1
+ import { compileWithCrossCompilerCache, compile } from "./processor.js";
2
2
  async function mdxLoader(source) {
3
3
  this.cacheable(true);
4
4
  const callback = this.async();
@@ -14,7 +14,8 @@ async function mdxLoader(source) {
14
14
  docDirectory,
15
15
  config,
16
16
  pluginDriver,
17
- routeService
17
+ routeService,
18
+ addDependency: this.addDependency
18
19
  });
19
20
  callback(null, compileResult);
20
21
  } else {
@@ -49,4 +50,4 @@ async function mdxLoader(source) {
49
50
  }
50
51
  }
51
52
  }
52
- export { mdxLoader as default };
53
+ export default mdxLoader;