@rspress/core 2.1.3 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/{p~0.js → 8~0.js} +1 -0
  2. package/dist/cli/index.js +1 -1
  3. package/dist/config/loadConfigFile.js +1 -1
  4. package/dist/eject-theme/components/Callout/index.test.tsx +52 -0
  5. package/dist/eject-theme/components/Callout/index.tsx +11 -0
  6. package/dist/eject-theme/components/CodeBlock/index.tsx +1 -1
  7. package/dist/eject-theme/components/HomeHero/index.scss +4 -1
  8. package/dist/eject-theme/components/PageTabs/index.test.tsx +45 -0
  9. package/dist/eject-theme/components/PageTabs/index.tsx +17 -0
  10. package/dist/eject-theme/components/Prompt/index.tsx +2 -1
  11. package/dist/eject-theme/components/Tabs/index.test.tsx +26 -4
  12. package/dist/eject-theme/components/Tabs/index.tsx +8 -5
  13. package/dist/node/PluginDriver.js +1 -1
  14. package/dist/node/auto-nav-sidebar/index.js +1 -1
  15. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  16. package/dist/node/auto-nav-sidebar/normalize.js +1 -1
  17. package/dist/node/auto-nav-sidebar/utils.js +1 -1
  18. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  19. package/dist/node/eject.js +1 -1
  20. package/dist/node/initRsbuild.js +6 -1
  21. package/dist/node/route/RoutePage.js +1 -1
  22. package/dist/node/route/RouteService.js +1 -1
  23. package/dist/node/route/extractPageData.js +19 -3
  24. package/dist/node/route/normalizeRoutePath.js +1 -1
  25. package/dist/node/route/routeChunkAssets.d.ts +2 -0
  26. package/dist/node/route/routeChunkAssets.js +6 -0
  27. package/dist/node/runtimeModule/i18n/getI18nData.js +1 -1
  28. package/dist/node/runtimeModule/i18n/rsbuildPlugin.js +1 -1
  29. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  30. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  31. package/dist/node/runtimeModule/searchHooks.js +1 -1
  32. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  33. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  34. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  35. package/dist/node/serve.js +1 -1
  36. package/dist/node/sitemap.js +1 -1
  37. package/dist/node/ssg/alternateLinks.js +1 -1
  38. package/dist/node/ssg/renderHtmlTemplate.js +5 -1
  39. package/dist/node/ssg/renderPageWorker.js +1 -1
  40. package/dist/node/ssg/renderPages.js +1 -1
  41. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  42. package/dist/node/ssg/ssgEnv.js +1 -1
  43. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  44. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  45. package/dist/node/ssg-md/renderPage.js +1 -1
  46. package/dist/node/ssg-md/renderPages.js +1 -1
  47. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  48. package/dist/node/utils/checkLanguageParity.js +1 -1
  49. package/dist/node/utils/createHash.js +1 -1
  50. package/dist/node/utils/flattenMdxContent.js +1 -1
  51. package/dist/node/utils/getPageKey.js +1 -1
  52. package/dist/node/utils/reactAlias.js +3 -1
  53. package/dist/n~0.js +1 -1
  54. package/dist/theme/components/Callout/index.js +10 -0
  55. package/dist/theme/components/CodeBlock/index.d.ts +1 -1
  56. package/dist/theme/components/HomeHero/index.css +5 -1
  57. package/dist/theme/components/PageTabs/index.js +12 -0
  58. package/dist/theme/components/Prompt/index.js +1 -1
  59. package/dist/theme/components/Tabs/index.js +8 -5
  60. package/dist/tinypool~0.js +2 -2
  61. package/dist/y~0.js +1 -1
  62. package/package.json +6 -6
@@ -3021,6 +3021,7 @@ export { createHash } from "node:crypto";
3021
3021
  export { chunk, groupBy } from "@rspress/shared/lodash-es";
3022
3022
  export { extractTextAndId, getIconUrlPath, loadFrontMatter } from "@rspress/shared/node-utils";
3023
3023
  export { default as remark_gfm } from "remark-gfm";
3024
+ export { default as remark_mdx } from "remark-mdx";
3024
3025
  export { default as remark_parse } from "remark-parse";
3025
3026
  export { unified } from "unified";
3026
3027
  export { default as node_fs } from "node:fs";
package/dist/cli/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { logger, cac } from "../p~0.js";
1
+ import { logger, cac } from "../8~0.js";
2
2
  import { package_namespaceObject } from "../y~0.js";
3
3
  import { loadConfigFile, resolveDocRoot } from "../config/loadConfigFile.js";
4
4
  import { dev } from "../node/dev.js";
@@ -1,4 +1,4 @@
1
- import { node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../p~0.js";
1
+ import { node_path, logger, DEFAULT_CONFIG_NAME, DEFAULT_CONFIG_EXTENSIONS } from "../8~0.js";
2
2
  async function loadConfigFile(customConfigFile) {
3
3
  const { loadConfig } = await import("@rsbuild/core");
4
4
  const result = await loadConfig({
@@ -0,0 +1,52 @@
1
+ import { afterEach, describe, expect, it } from '@rstest/core';
2
+ import { renderToMarkdownString } from 'react-render-to-markdown';
3
+ import { Callout } from './index';
4
+
5
+ const originalSsgMd = import.meta.env.SSG_MD;
6
+ afterEach(() => {
7
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD =
8
+ originalSsgMd;
9
+ });
10
+
11
+ describe('Callout Markdown rendering', () => {
12
+ it('keeps the title and multiple paragraphs inside a quote', async () => {
13
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = true;
14
+ const markdown = await renderToMarkdownString(
15
+ <Callout type="warning" title="Before you begin">
16
+ <p>Install dependencies.</p>
17
+ <p>
18
+ Then run <code>pnpm dev</code>.
19
+ </p>
20
+ </Callout>,
21
+ );
22
+ expect(markdown).toMatchInlineSnapshot(`
23
+ "> **Before you begin**
24
+ >
25
+ > Install dependencies.
26
+ >
27
+ > Then run \`pnpm dev\`.
28
+ >
29
+ >
30
+
31
+ "
32
+ `);
33
+ });
34
+
35
+ it('exports all details content with the default title', async () => {
36
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = true;
37
+ const markdown = await renderToMarkdownString(
38
+ <Callout type="details">
39
+ <p>Hidden in the browser.</p>
40
+ </Callout>,
41
+ );
42
+ expect(markdown).toMatchInlineSnapshot(`
43
+ "> **Details**
44
+ >
45
+ > Hidden in the browser.
46
+ >
47
+ >
48
+
49
+ "
50
+ `);
51
+ });
52
+ });
@@ -37,6 +37,17 @@ function capitalize(type: string) {
37
37
  * </div>
38
38
  */
39
39
  export function Callout({ type, title, children }: CalloutProps): ReactNode {
40
+ if (import.meta.env.SSG_MD) {
41
+ return (
42
+ <blockquote>
43
+ <p>
44
+ <strong>{title ?? capitalize(type)}</strong>
45
+ </p>
46
+ {children}
47
+ </blockquote>
48
+ );
49
+ }
50
+
40
51
  const isDetails = type === 'details';
41
52
 
42
53
  if (isDetails) {
@@ -30,7 +30,7 @@ export type CodeBlockProps = {
30
30
  containerElementClassName?: string;
31
31
  codeButtonGroupProps?: Omit<
32
32
  CodeButtonGroupProps,
33
- 'preElementRef' | 'wrapCode' | 'toggleWrapCode'
33
+ 'copyElementRef' | 'wrapCode' | 'toggleWrapCode'
34
34
  >;
35
35
  children?: React.ReactNode;
36
36
  };
@@ -19,7 +19,10 @@
19
19
  }
20
20
 
21
21
  @media (max-width: 600px) {
22
- padding: 10px;
22
+ padding: 10px 20px;
23
+ .rp-home-hero__container {
24
+ gap: 18px;
25
+ }
23
26
  .rp-home-hero__title {
24
27
  font-size: 2.5rem;
25
28
  }
@@ -0,0 +1,45 @@
1
+ import { afterEach, expect, it, rs } from '@rstest/core';
2
+ import { renderToMarkdownString } from 'react-render-to-markdown';
3
+ import { PageTab, PageTabs } from './index';
4
+
5
+ rs.mock('@rspress/core/runtime', () => ({
6
+ useSearchParams: () => [new URLSearchParams(), () => {}],
7
+ useLocation: () => ({ search: '' }),
8
+ }));
9
+
10
+ const originalSsgMd = import.meta.env.SSG_MD;
11
+ afterEach(() => {
12
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD =
13
+ originalSsgMd;
14
+ });
15
+
16
+ it('places each page label next to its content in Markdown', async () => {
17
+ (import.meta.env as unknown as Record<string, unknown>).SSG_MD = true;
18
+ const markdown = await renderToMarkdownString(
19
+ <PageTabs>
20
+ <PageTab
21
+ label={
22
+ <span>
23
+ API <code>v2</code>
24
+ </span>
25
+ }
26
+ >
27
+ <p>API content</p>
28
+ </PageTab>
29
+ <PageTab label="How it works">
30
+ <p>Implementation content</p>
31
+ </PageTab>
32
+ </PageTabs>,
33
+ );
34
+ expect(markdown).toMatchInlineSnapshot(`
35
+ "**API \`v2\`**
36
+
37
+ API content
38
+
39
+ **How it works**
40
+
41
+ Implementation content
42
+
43
+ "
44
+ `);
45
+ });
@@ -111,6 +111,23 @@ export const PageTabs = forwardRef(
111
111
  children,
112
112
  );
113
113
 
114
+ if (import.meta.env.SSG_MD) {
115
+ return (
116
+ <>
117
+ {tabValues.map(({ label, content }, index) => (
118
+ <div key={index}>
119
+ {label != null && (
120
+ <p>
121
+ <strong>{label}</strong>
122
+ </p>
123
+ )}
124
+ {content}
125
+ </div>
126
+ ))}
127
+ </>
128
+ );
129
+ }
130
+
114
131
  return (
115
132
  <>
116
133
  {/* First screen during SSR */}
@@ -218,7 +218,8 @@ function CopyablePrompt({
218
218
  <div
219
219
  {...props}
220
220
  ref={cardRef}
221
- className={clsx('rp-prompt', className)}
221
+ // Copyable prompt chrome owns its typography; custom MDX keeps doc styles.
222
+ className={clsx('rp-prompt', 'rp-not-doc', className)}
222
223
  style={
223
224
  {
224
225
  '--rp-prompt-accent': AGENT_ICONS[iconIndex].color,
@@ -60,15 +60,37 @@ describe('Tabs', () => {
60
60
  await setImmediate();
61
61
  expect(errors).toEqual([]);
62
62
  expect(markdown).toMatchInlineSnapshot(`
63
- "
64
- **npm**
63
+ "**npm**
65
64
 
66
65
  npm install
67
66
 
68
67
  **pnpm**
69
68
 
70
- pnpm install
71
- "
69
+ pnpm install"
70
+ `);
71
+ });
72
+ it('renders React labels and omits missing labels', async () => {
73
+ setSsgMd(true);
74
+ const markdown = await renderToMarkdownString(
75
+ <Tabs>
76
+ <Tab
77
+ label={
78
+ <span>
79
+ GitHub <code>repo</code>
80
+ </span>
81
+ }
82
+ >
83
+ Repository settings
84
+ </Tab>
85
+ <Tab>Unlabelled content</Tab>
86
+ </Tabs>,
87
+ );
88
+ expect(markdown).toMatchInlineSnapshot(`
89
+ "**GitHub \`repo\`**
90
+
91
+ Repository settings
92
+
93
+ Unlabelled content"
72
94
  `);
73
95
  });
74
96
  });
@@ -133,13 +133,16 @@ export const Tabs = forwardRef(
133
133
  if (import.meta.env.SSG_MD) {
134
134
  return (
135
135
  <>
136
- {tabValues.map(({ label, content }) => {
136
+ {tabValues.map(({ label, content }, index) => {
137
137
  return (
138
- <>
139
- {`\n**${label}**\n\n`}
138
+ <div key={index}>
139
+ {label != null && (
140
+ <p>
141
+ <strong>{label}</strong>
142
+ </p>
143
+ )}
140
144
  {content}
141
- {`\n`}
142
- </>
145
+ </div>
143
146
  );
144
147
  })}
145
148
  </>
@@ -1,4 +1,4 @@
1
- import { addTrailingSlash, node_path, addLeadingSlash } from "../p~0.js";
1
+ import { addTrailingSlash, node_path, addLeadingSlash } from "../8~0.js";
2
2
  import { createI18nDataLoader } from "./runtimeModule/i18n/getI18nData.js";
3
3
  import { createError } from "./utils/error.js";
4
4
  import { haveNavSidebarConfig as auto_nav_sidebar_haveNavSidebarConfig } from "./auto-nav-sidebar/index.js";
@@ -1,4 +1,4 @@
1
- import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../p~0.js";
1
+ import { DEFAULT_PAGE_EXTENSIONS, node_path } from "../../8~0.js";
2
2
  import { processLocales, combineWalkResult } from "./locales.js";
3
3
  import { walk } from "./walk.js";
4
4
  async function runAutoNavSide(config, metaFileSet, mdFileSet) {
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../p~0.js";
1
+ import { node_path } from "../../8~0.js";
2
2
  import { walk } from "./walk.js";
3
3
  function combineWalkResult(walks, versions) {
4
4
  return walks.reduce((acc, cur, curIndex)=>({
@@ -1,6 +1,6 @@
1
1
  import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
2
2
  import "../../t~0.js";
3
- import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../p~0.js";
3
+ import { extname, logger, promises_readdir, external_node_path_relative, isExternalUrl, slash, promises_stat, join } from "../../8~0.js";
4
4
  import { createError } from "../utils/error.js";
5
5
  import { pathExists, extractInfoFromFrontmatterWithAbsolutePath, readJson } from "./utils.js";
6
6
  import { absolutePathToRoutePath, addRoutePrefix } from "../route/RoutePage.js";
@@ -1,4 +1,4 @@
1
- import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../p~0.js";
1
+ import { node_path, extractTextAndId, promises, loadFrontMatter } from "../../8~0.js";
2
2
  import { createError } from "../utils/error.js";
3
3
  async function pathExists(path) {
4
4
  try {
@@ -1,4 +1,4 @@
1
- import { isExternalUrl, node_path, promises } from "../../p~0.js";
1
+ import { isExternalUrl, node_path, promises } from "../../8~0.js";
2
2
  import { pathExists } from "../utils/fs.js";
3
3
  import { readJson } from "./utils.js";
4
4
  import { addRoutePrefix } from "../route/RoutePage.js";
@@ -1,6 +1,6 @@
1
1
  import { rspackRequire, compatGetDefaultExport } from "../rslib-runtime~0.js";
2
2
  import "../t~0.js";
3
- import { node_path, logger, promises } from "../p~0.js";
3
+ import { node_path, logger, promises } from "../8~0.js";
4
4
  import { EJECTED_THEME } from "./constants.js";
5
5
  const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
6
  var picocolors_default = /*#__PURE__*/ compatGetDefaultExport(picocolors);
@@ -1,4 +1,4 @@
1
- import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../p~0.js";
1
+ import { external_node_process_cwd, node_path, fileURLToPath, addTrailingSlash, PLUGIN_REACT_NAME, removeTrailingSlash, normalizeDarkMode, pluginVirtualModule, pluginReact, createRequire, MDX_OR_MD_REGEXP } from "../8~0.js";
2
2
  import { createError } from "./utils/error.js";
3
3
  import { CSR_CLIENT_ENTRY, SSR_CLIENT_ENTRY, OUTPUT_DIR, SSG_MD_SERVER_ENTRY, NODE_SSG_BUNDLE_FOLDER, getInlineLocaleRedirectScript, isProduction, PACKAGE_ROOT, SSR_SERVER_ENTRY, TEMPLATE_PATH, NODE_SSG_MD_BUNDLE_FOLDER, DEFAULT_THEME, NODE_SSG_MD_BUNDLE_NAME, getInlineThemeScript, DEFAULT_TITLE, NODE_SSG_BUNDLE_NAME } from "./constants.js";
4
4
  import { isLlmsUIEnabled, isLlmsHintEnabled } from "./llms.js";
@@ -236,6 +236,11 @@ async function createInternalBuildConfig(userDocRoot, config, enableSSG, routeSe
236
236
  }
237
237
  },
238
238
  tools: {
239
+ rspack: {
240
+ experiments: {
241
+ runtimeMode: 'rspack'
242
+ }
243
+ },
239
244
  swc: {
240
245
  jsc: {
241
246
  transform: {
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../p~0.js";
1
+ import { node_path } from "../../8~0.js";
2
2
  import { RouteService } from "./RouteService.js";
3
3
  import { getPageKey } from "../utils/getPageKey.js";
4
4
  import { slash } from "../utils/slash.js";
@@ -1,4 +1,4 @@
1
- import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../p~0.js";
1
+ import { RSPRESS_TEMP_DIR, node_path, removeTrailingSlash, promises, addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, glob } from "../../8~0.js";
2
2
  import { RoutePage, absolutePathToRoutePath, absolutePathToRelativePath } from "./RoutePage.js";
3
3
  import { createError } from "../utils/error.js";
4
4
  import { getRouteChunkName } from "./routeChunkAssets.js";
@@ -1,4 +1,4 @@
1
- import { unified, node_path, promises, loadFrontMatter, extractTextAndId, remark_gfm, remark_parse, MDX_OR_MD_REGEXP } from "../../p~0.js";
1
+ import { unified, node_path, promises, loadFrontMatter, extractTextAndId, remark_gfm, remark_mdx, MDX_OR_MD_REGEXP, remark_parse } from "../../8~0.js";
2
2
  import { applyReplaceRules } from "../utils/applyReplaceRules.js";
3
3
  import { flattenMdxContent } from "../utils/flattenMdxContent.js";
4
4
  import { importStatementRegex } from "../constants.js";
@@ -9,6 +9,7 @@ function applyReplaceRulesToNestedObject(obj, replaceRules) {
9
9
  return obj;
10
10
  }
11
11
  const processor = unified().use(remark_parse).use(remark_gfm);
12
+ const mdxProcessor = unified().use(remark_parse).use(remark_gfm).use(remark_mdx);
12
13
  function extractTextFromNode(node) {
13
14
  if ('value' in node && 'string' == typeof node.value) return node.value;
14
15
  if ('children' in node && Array.isArray(node.children)) return node.children.map(extractTextFromNode).join('');
@@ -99,6 +100,9 @@ const SKIP_NODE_TYPES = new Set([
99
100
  'html',
100
101
  'mdxjsEsm',
101
102
  'mdxFlowExpression',
103
+ 'mdxJsxFlowElement',
104
+ 'mdxJsxTextElement',
105
+ 'mdxTextExpression',
102
106
  'thematicBreak',
103
107
  'image',
104
108
  'table'
@@ -138,7 +142,7 @@ function extractDescription(tree) {
138
142
  if ('heading' === node.type && 2 === node.depth) break;
139
143
  if (!SKIP_NODE_TYPES.has(node.type)) {
140
144
  if (foundH1) {
141
- const text = extractTextFromNode(node).trim();
145
+ const text = extractDescriptionText(node).trim();
142
146
  if (text) textParts.push(text);
143
147
  }
144
148
  }
@@ -146,6 +150,18 @@ function extractDescription(tree) {
146
150
  const joined = textParts.join('\n');
147
151
  return stripContainerDirectives(joined).split('\n').map((l)=>l.trim()).filter(Boolean).join(' ');
148
152
  }
153
+ function extractDescriptionText(node) {
154
+ if (SKIP_NODE_TYPES.has(node.type)) return '';
155
+ if ('children' in node && Array.isArray(node.children)) return node.children.map(extractDescriptionText).join('');
156
+ return extractTextFromNode(node);
157
+ }
158
+ function parsePageTree(content) {
159
+ try {
160
+ return mdxProcessor.parse(content);
161
+ } catch {
162
+ return processor.parse(content);
163
+ }
164
+ }
149
165
  async function getPageIndexInfoByRoute(route, options) {
150
166
  const { alias, replaceRules, root, searchCodeBlocks, extractDescription: extractDescriptionConfig = true, searchEnabled = true } = options;
151
167
  const defaultIndexInfo = {
@@ -167,7 +183,7 @@ async function getPageIndexInfoByRoute(route, options) {
167
183
  const { flattenContent } = await flattenMdxContent(applyReplaceRules(contentWithoutFrontMatter, replaceRules), route.absolutePath, alias);
168
184
  content = flattenContent.replace(importStatementRegex, '');
169
185
  content = content.replace(/\r\n/g, '\n');
170
- const tree = processor.parse(content);
186
+ const tree = parsePageTree(content);
171
187
  const { title, toc: rawToc } = parseToc(tree);
172
188
  const extractedDescription = frontmatter.description || !extractDescriptionConfig ? '' : extractDescription(tree);
173
189
  if (!searchEnabled) return {
@@ -1,4 +1,4 @@
1
- import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../p~0.js";
1
+ import { addTrailingSlash, DEFAULT_PAGE_EXTENSIONS, addLeadingSlash } from "../../8~0.js";
2
2
  const getRoutePathParts = (relativePath, lang, version, langs, versions)=>{
3
3
  const [versionPart, langPart, purePath] = splitRoutePathParts(relativePath, lang, version, langs, versions);
4
4
  return [
@@ -3,6 +3,8 @@ import type { RouteMeta } from '@rspress/shared';
3
3
  import type { RouteService } from './RouteService.js';
4
4
  export interface RouteChunkAssetsManifest {
5
5
  assetPrefix: string;
6
+ isModule: boolean;
7
+ crossOriginLoading: false | 'anonymous' | 'use-credentials';
6
8
  assets: Record<string, string[]>;
7
9
  }
8
10
  export declare function getRouteChunkName(route: RouteMeta): string;
@@ -8,12 +8,16 @@ function getRouteChunkName(route) {
8
8
  class RouteChunkAssetsPlugin {
9
9
  routeService;
10
10
  #assetPrefix = '/';
11
+ #isModule = false;
12
+ #crossOriginLoading = false;
11
13
  #chunks = new Map();
12
14
  constructor(routeService){
13
15
  this.routeService = routeService;
14
16
  }
15
17
  apply(compiler) {
16
18
  compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation)=>{
19
+ this.#isModule = Boolean(compilation.outputOptions.module);
20
+ this.#crossOriginLoading = compilation.outputOptions.crossOriginLoading ?? false;
17
21
  this.#assetPrefix = 'string' == typeof compilation.outputOptions.publicPath ? compilation.outputOptions.publicPath : '/';
18
22
  this.#chunks.clear();
19
23
  const routePathsByChunkName = new Map();
@@ -38,6 +42,8 @@ class RouteChunkAssetsPlugin {
38
42
  getManifest() {
39
43
  return {
40
44
  assetPrefix: this.#assetPrefix,
45
+ isModule: this.#isModule,
46
+ crossOriginLoading: this.#crossOriginLoading,
41
47
  assets: Object.fromEntries([
42
48
  ...this.#chunks
43
49
  ].map(([routePath, chunks])=>{
@@ -1,6 +1,6 @@
1
1
  import { rspackRequire, compatGetDefaultExport } from "../../../rslib-runtime~0.js";
2
2
  import "../../../t~0.js";
3
- import { logger, join, readFile } from "../../../p~0.js";
3
+ import { logger, join, readFile } from "../../../8~0.js";
4
4
  import { pathExists } from "../../utils/fs.js";
5
5
  import { DEFAULT_I18N_TEXT } from "./DEFAULT_I18N_TEXT.js";
6
6
  import { createError } from "../../utils/error.js";
@@ -1,4 +1,4 @@
1
- import { pluginVirtualModule } from "../../../p~0.js";
1
+ import { pluginVirtualModule } from "../../../8~0.js";
2
2
  const rsbuildPluginI18n = ({ pluginDriver })=>[
3
3
  {
4
4
  name: 'rspress:i18n',
@@ -1,4 +1,4 @@
1
- import { SEARCH_INDEX_NAME, groupBy } from "../../../p~0.js";
1
+ import { SEARCH_INDEX_NAME, groupBy } from "../../../8~0.js";
2
2
  import { extractPageData } from "../../route/extractPageData.js";
3
3
  import { createHash } from "../../utils/createHash.js";
4
4
  function deletePrivateField(obj) {
@@ -1,4 +1,4 @@
1
- import { logger, pluginVirtualModule } from "../../../p~0.js";
1
+ import { logger, pluginVirtualModule } from "../../../8~0.js";
2
2
  import { createPageData } from "./createPageData.js";
3
3
  const rsbuildPluginDocVM = async ({ config, userDocRoot, routeService, pluginDriver })=>{
4
4
  const ref = {
@@ -1,4 +1,4 @@
1
- import { node_path } from "../../p~0.js";
1
+ import { node_path } from "../../8~0.js";
2
2
  const searchHookVMPlugin = (context)=>({
3
3
  ["virtual-search-hooks"]: ()=>{
4
4
  const { config } = context;
@@ -1,4 +1,4 @@
1
- import { getIconUrlPath } from "../../../p~0.js";
1
+ import { getIconUrlPath } from "../../../8~0.js";
2
2
  import { normalizeThemeConfig } from "./normalizeThemeConfig.js";
3
3
  async function createSiteData(userConfig, pluginDriver) {
4
4
  const tempSearchObj = Object.assign({}, userConfig.search);
@@ -1,4 +1,4 @@
1
- import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../p~0.js";
1
+ import { isExternalUrl, slash, addLeadingSlash, normalizeHref } from "../../../8~0.js";
2
2
  import { applyReplaceRules } from "../../utils/applyReplaceRules.js";
3
3
  async function normalizeThemeConfig(docConfig, pluginDriver) {
4
4
  const { locales: siteLocales, lang, replaceRules = [], multiVersion } = docConfig;
@@ -1,4 +1,4 @@
1
- import { isProduction, logger } from "../../../p~0.js";
1
+ import { isProduction, logger } from "../../../8~0.js";
2
2
  import { modifyConfigWithAutoNavSide } from "../../auto-nav-sidebar/index.js";
3
3
  import { createSiteData } from "./createSiteData.js";
4
4
  const siteDataVMPlugin = (context)=>{
@@ -1,4 +1,4 @@
1
- import { mergeRsbuildConfig } from "../p~0.js";
1
+ import { mergeRsbuildConfig } from "../8~0.js";
2
2
  import { normalizeConfigResult } from "../config/loadConfigFile.js";
3
3
  import { PluginDriver } from "./PluginDriver.js";
4
4
  import { initRsbuild } from "./initRsbuild.js";
@@ -1,4 +1,4 @@
1
- import { withSiteOrigin, logger, glob, promises_stat, withBase } from "../p~0.js";
1
+ import { withSiteOrigin, logger, glob, promises_stat, withBase } from "../8~0.js";
2
2
  import { routePath2HtmlFileName } from "./ssg/htmlFile.js";
3
3
  function ensureTrailingSlash(url) {
4
4
  return url.endsWith('/') ? url : `${url}/`;
@@ -1,4 +1,4 @@
1
- import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../p~0.js";
1
+ import { normalizeHref, removeTrailingSlash, addLeadingSlash, normalizePosixPath, withSiteOrigin } from "../../8~0.js";
2
2
  function createAlternateLinksByRoute(routes, config) {
3
3
  const routeGroups = new Map();
4
4
  for (const route of routes){
@@ -37,7 +37,11 @@ function renderRoutePreloadLinks(route, manifest) {
37
37
  if (!assets) return '';
38
38
  return assets.map((asset)=>{
39
39
  const href = 'auto' === manifest.assetPrefix ? posix.relative(posix.dirname(routePath2HtmlFileName(route.routePath)), asset) : `${manifest.assetPrefix}${asset}`;
40
- return `<link rel="preload" href="${escapeHtmlAttribute(href)}" as="script">`;
40
+ const rel = manifest.isModule ? 'modulepreload' : 'preload';
41
+ const as = manifest.isModule ? '' : ' as="script"';
42
+ const crossOrigin = manifest.crossOriginLoading;
43
+ const crossorigin = crossOrigin && (manifest.isModule || 'use-credentials' === crossOrigin || /^(?:[a-z][a-z\d+.-]*:)?\/\//i.test(href)) ? ` crossorigin="${crossOrigin}"` : '';
44
+ return `<link rel="${rel}" href="${escapeHtmlAttribute(href)}"${as}${crossorigin}>`;
41
45
  }).join('');
42
46
  }
43
47
  function escapeHtmlAttribute(value) {
@@ -5,7 +5,7 @@ import { pMap } from "../../y~0.js";
5
5
  import { renderPage } from "./renderPage.js";
6
6
  const params = workerData?.[1]?.params;
7
7
  if (!params) throw createError('SSG Worker Thread workerData params missing');
8
- const { htmlTemplate: htmlTemplate, head: head, ssrBundlePath: ssrBundlePath, alternateLinksByRoute: alternateLinksByRoute, distPath: distPath, routeChunkAssets: routeChunkAssets } = params;
8
+ const { htmlTemplate, head, ssrBundlePath, alternateLinksByRoute, distPath, routeChunkAssets } = params;
9
9
  async function writeHtmlFile(routePath, html) {
10
10
  if (!distPath) return;
11
11
  const fileAbsolutePath = resolveHtmlFilePath(distPath, routePath);
@@ -1,7 +1,7 @@
1
1
  /*! LICENSE: renderPages.js.LICENSE.txt */
2
2
  import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
3
3
  import "../../t~0.js";
4
- import { node_path, fileURLToPath, logger, chunk } from "../../p~0.js";
4
+ import { node_path, fileURLToPath, logger, chunk } from "../../8~0.js";
5
5
  import { createAlternateLinksByRoute } from "./alternateLinks.js";
6
6
  import { SSGWorkerThreadTaskSize, getNumberOfThreads, SSGWorkerThreadRecyclerMaxMemory, SSGConcurrency } from "./ssgEnv.js";
7
7
  import { routePath2HtmlFileName } from "./htmlFile.js";
@@ -1,4 +1,4 @@
1
- import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../p~0.js";
1
+ import { logger, writeFile, mkdir, rm, join, isDebugMode } from "../../8~0.js";
2
2
  import { NODE_SSG_BUNDLE_FOLDER, NODE_SSG_BUNDLE_NAME } from "../constants.js";
3
3
  import { renderPages } from "./renderPages.js";
4
4
  const rsbuildPluginSSG = ({ routeService, config, routeChunkAssets })=>({
@@ -1,5 +1,5 @@
1
1
  /*! LICENSE: ssgEnv.js.LICENSE.txt */
2
- import { node_os } from "../../p~0.js";
2
+ import { node_os } from "../../8~0.js";
3
3
  /**
4
4
  * these codes are copied from
5
5
  * @link https://github.com/facebook/docusaurus/blob/45065e8d2b5831117b8d69fec1be28f5520cf105/packages/docusaurus/src/ssg/ssgEnv.ts#L11
@@ -1,4 +1,4 @@
1
- import { matchPath, getSidebarDataGroup } from "../../../p~0.js";
1
+ import { matchPath, getSidebarDataGroup } from "../../../8~0.js";
2
2
  import { generateLlmsTxt, generateLlmsFullTxt } from "./llmsTxt.js";
3
3
  async function emitLlmsTxt(config, routeService, emitAsset, mdContents) {
4
4
  const base = config.base ?? '/';
@@ -1,4 +1,4 @@
1
- import { normalizeHref, withSiteOrigin, logger, withBase } from "../../../p~0.js";
1
+ import { normalizeHref, withSiteOrigin, logger, withBase } from "../../../8~0.js";
2
2
  import { extractInfoFromFrontmatterWithAbsolutePath } from "../../auto-nav-sidebar/utils.js";
3
3
  function routePathToMdPath(routePath, base, siteOrigin) {
4
4
  let url = routePath;
@@ -1,6 +1,6 @@
1
1
  import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
2
2
  import "../../t~0.js";
3
- import { createHead, pathToFileURL, logger } from "../../p~0.js";
3
+ import { createHead, pathToFileURL, logger } from "../../8~0.js";
4
4
  import { hintSSGMDFailed } from "../logger/hint.js";
5
5
  const picocolors = rspackRequire("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6
6
  var picocolors_default = /*#__PURE__*/ compatGetDefaultExport(picocolors);
@@ -1,6 +1,6 @@
1
1
  import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
2
2
  import "../../t~0.js";
3
- import { logger } from "../../p~0.js";
3
+ import { logger } from "../../8~0.js";
4
4
  import { pMap } from "../../y~0.js";
5
5
  import { renderPage } from "./renderPage.js";
6
6
  import { SSGConcurrency } from "../ssg/ssgEnv.js";
@@ -1,4 +1,4 @@
1
- import { writeFile, mkdir, rm, join, isDebugMode } from "../../p~0.js";
1
+ import { writeFile, mkdir, rm, join, isDebugMode } from "../../8~0.js";
2
2
  import { NODE_SSG_MD_BUNDLE_FOLDER, NODE_SSG_MD_BUNDLE_NAME } from "../constants.js";
3
3
  import { renderPages } from "./renderPages.js";
4
4
  import { emitLlmsTxt } from "./llms/emitLlmsTxt.js";
@@ -1,4 +1,4 @@
1
- import { node_path, logger, promises } from "../../p~0.js";
1
+ import { node_path, logger, promises } from "../../8~0.js";
2
2
  import { slash } from "./slash.js";
3
3
  import { createError } from "./error.js";
4
4
  async function getAllMarkdownFilesFrom(dirPath) {
@@ -1,4 +1,4 @@
1
- import { createHash as external_node_crypto_createHash } from "../../p~0.js";
1
+ import { createHash as external_node_crypto_createHash } from "../../8~0.js";
2
2
  function createHash(str, length = 8) {
3
3
  return external_node_crypto_createHash('sha256').update(str).digest('hex').slice(0, length);
4
4
  }
@@ -1,4 +1,4 @@
1
- import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../p~0.js";
1
+ import { node_fs, node_path, core_rspack, logger, createProcessor, MDX_OR_MD_REGEXP } from "../../8~0.js";
2
2
  import { createError } from "./error.js";
3
3
  import { importStatementRegex } from "../constants.js";
4
4
  const RspackResolveFactory = core_rspack.experiments.resolver.ResolverFactory;
@@ -1,4 +1,4 @@
1
- import { removeLeadingSlash } from "../../p~0.js";
1
+ import { removeLeadingSlash } from "../../8~0.js";
2
2
  function getPageKey(route) {
3
3
  const cleanRoute = removeLeadingSlash(route);
4
4
  return cleanRoute.replace(/\//g, '_').replace(/\.[^.]+$/, '') || 'index';
@@ -1,6 +1,6 @@
1
1
  import { rspackRequire, compatGetDefaultExport } from "../../rslib-runtime~0.js";
2
2
  import "../../t~0.js";
3
- import { node_path, core_rspack, logger } from "../../p~0.js";
3
+ import { node_path, core_rspack, logger } from "../../8~0.js";
4
4
  import { pathExists, readJson } from "./fs.js";
5
5
  import { PACKAGE_ROOT } from "../constants.js";
6
6
  import { hintReactVersion } from "../logger/hint.js";
@@ -54,6 +54,7 @@ async function resolveReactAlias(isSSR) {
54
54
  'react',
55
55
  'react/jsx-runtime',
56
56
  'react/jsx-dev-runtime',
57
+ 'react/compiler-runtime',
57
58
  'react/package.json',
58
59
  'react-dom',
59
60
  'react-dom/client',
@@ -83,6 +84,7 @@ async function resolveReactAlias(isSSR) {
83
84
  if (resolved.error || !resolved.path) throw Error(resolved.error);
84
85
  alias[lib] = resolved.path;
85
86
  } catch (e) {
87
+ if ('react/compiler-runtime' === lib) return;
86
88
  if (e instanceof Error) {
87
89
  logger.warn(`${lib} not found: \n ${picocolors_default().gray(e.toString())}`);
88
90
  hintReactVersion();
package/dist/n~0.js CHANGED
@@ -1117,7 +1117,7 @@ class SignalExit extends SignalExitBase {
1117
1117
  }
1118
1118
  }
1119
1119
  const mjs_process = globalThis.process;
1120
- const { onExit: onExit, load: mjs_load, unload: unload } = signalExitWrap(processOk(mjs_process) ? new SignalExit(mjs_process) : new SignalExitFallback());
1120
+ const { onExit, load: mjs_load, unload } = signalExitWrap(processOk(mjs_process) ? new SignalExit(mjs_process) : new SignalExitFallback());
1121
1121
  const DEFAULT_FORCE_KILL_TIMEOUT = 5000;
1122
1122
  const spawnedKill = (kill, signal = 'SIGTERM', options = {})=>{
1123
1123
  const killResult = kill(signal);
@@ -4,6 +4,16 @@ function capitalize(type) {
4
4
  return type.charAt(0).toUpperCase() + type.slice(1);
5
5
  }
6
6
  function Callout({ type, title, children }) {
7
+ if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsxs("blockquote", {
8
+ children: [
9
+ /*#__PURE__*/ jsx("p", {
10
+ children: /*#__PURE__*/ jsx("strong", {
11
+ children: title ?? capitalize(type)
12
+ })
13
+ }),
14
+ children
15
+ ]
16
+ });
7
17
  const isDetails = 'details' === type;
8
18
  if (isDetails) return /*#__PURE__*/ jsxs("details", {
9
19
  className: `rp-callout rp-callout--${type}`,
@@ -17,7 +17,7 @@ export type CodeBlockProps = {
17
17
  fold?: boolean;
18
18
  height?: number;
19
19
  containerElementClassName?: string;
20
- codeButtonGroupProps?: Omit<CodeButtonGroupProps, 'preElementRef' | 'wrapCode' | 'toggleWrapCode'>;
20
+ codeButtonGroupProps?: Omit<CodeButtonGroupProps, 'copyElementRef' | 'wrapCode' | 'toggleWrapCode'>;
21
21
  children?: React.ReactNode;
22
22
  };
23
23
  /**
@@ -23,7 +23,11 @@
23
23
 
24
24
  @media (width <= 600px) {
25
25
  .rp-home-hero {
26
- padding: 10px;
26
+ padding: 10px 20px;
27
+ }
28
+
29
+ .rp-home-hero .rp-home-hero__container {
30
+ gap: 18px;
27
31
  }
28
32
 
29
33
  .rp-home-hero .rp-home-hero__title {
@@ -51,6 +51,18 @@ const PageTabs = /*#__PURE__*/ forwardRef((props, ref)=>{
51
51
  const { children: rawChildren, tabPosition = 'left', className, id = 'page' } = props;
52
52
  const children = Children.toArray(rawChildren).filter((child)=>!('string' == typeof child && '' === child.trim()) && /*#__PURE__*/ isValidElement(child));
53
53
  const { tabValues, navigateToTab, injectScript } = usePageTabs(id, children);
54
+ if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(Fragment, {
55
+ children: tabValues.map(({ label, content }, index)=>/*#__PURE__*/ jsxs("div", {
56
+ children: [
57
+ null != label && /*#__PURE__*/ jsx("p", {
58
+ children: /*#__PURE__*/ jsx("strong", {
59
+ children: label
60
+ })
61
+ }),
62
+ content
63
+ ]
64
+ }, index))
65
+ });
54
66
  return /*#__PURE__*/ jsxs(Fragment, {
55
67
  children: [
56
68
  /*#__PURE__*/ jsx("script", {
@@ -133,7 +133,7 @@ function CopyablePrompt({ className, defaultCollapsed = true, description, eyebr
133
133
  return /*#__PURE__*/ jsxs("div", {
134
134
  ...props,
135
135
  ref: cardRef,
136
- className: clsx('rp-prompt', className),
136
+ className: clsx('rp-prompt', 'rp-not-doc', className),
137
137
  style: {
138
138
  '--rp-prompt-accent': AGENT_ICONS[iconIndex].color,
139
139
  ...style
@@ -37,13 +37,16 @@ const Tabs = /*#__PURE__*/ forwardRef((props, ref)=>{
37
37
  const [activeIndex, setActiveIndex] = useState(initialActiveIndex);
38
38
  const [storageIndex, setStorageIndex] = useStorageValue(`${groupIdPrefix}${groupId}`, initialActiveIndex.toString());
39
39
  if (import.meta.env.SSG_MD) return /*#__PURE__*/ jsx(Fragment, {
40
- children: tabValues.map(({ label, content })=>/*#__PURE__*/ jsxs(Fragment, {
40
+ children: tabValues.map(({ label, content }, index)=>/*#__PURE__*/ jsxs("div", {
41
41
  children: [
42
- `\n**${label}**\n\n`,
43
- content,
44
- `\n`
42
+ null != label && /*#__PURE__*/ jsx("p", {
43
+ children: /*#__PURE__*/ jsx("strong", {
44
+ children: label
45
+ })
46
+ }),
47
+ content
45
48
  ]
46
- }))
49
+ }, index))
47
50
  });
48
51
  const currentIndex = groupId ? Number(storageIndex) : activeIndex;
49
52
  return /*#__PURE__*/ jsxs("div", {
@@ -124,12 +124,12 @@ var ProcessWorker = class {
124
124
  if (this.port) this.port.on("message", (message$1)=>this.send({
125
125
  ...message$1,
126
126
  source: "port",
127
- __tinypool_worker_message__: __tinypool_worker_message__
127
+ __tinypool_worker_message__
128
128
  }));
129
129
  return this.send({
130
130
  ...message,
131
131
  source: "pool",
132
- __tinypool_worker_message__: __tinypool_worker_message__
132
+ __tinypool_worker_message__
133
133
  });
134
134
  }
135
135
  on(event, callback) {
package/dist/y~0.js CHANGED
@@ -1,5 +1,5 @@
1
1
  var package_namespaceObject = {
2
- rE: "2.1.3"
2
+ rE: "2.1.4"
3
3
  };
4
4
  function pMap(iterable, mapper, options) {
5
5
  return mapConcurrently(iterable, mapper, options, false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/core",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "The Rspress Documentation Framework",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -60,9 +60,9 @@
60
60
  "dependencies": {
61
61
  "@mdx-js/mdx": "^3.1.1",
62
62
  "@mdx-js/react": "^3.1.1",
63
- "@rsbuild/core": "^2.2.14",
63
+ "@rsbuild/core": "^2.3.3",
64
64
  "@rsbuild/plugin-react": "~2.1.1",
65
- "@rspress/shared": "2.1.3",
65
+ "@rspress/shared": "2.1.4",
66
66
  "@shikijs/rehype": "^4.2.0",
67
67
  "@shikijs/transformers": "^4.2.0",
68
68
  "@types/mdast": "^4.0.4",
@@ -108,15 +108,15 @@
108
108
  "@types/node": "^22.8.1",
109
109
  "@types/nprogress": "^0.2.3",
110
110
  "@types/react-dom": "^19.3.0",
111
- "@types/web": "^0.0.362",
111
+ "@types/web": "^0.0.367",
112
112
  "cac": "^7.1.0",
113
113
  "execa": "8.0.1",
114
114
  "mdast-util-directive": "^3.1.1",
115
115
  "mdast-util-mdx-expression": "^2.0.1",
116
- "memfs": "^4.80.0",
116
+ "memfs": "^4.80.1",
117
117
  "p-map": "^7.1.1",
118
118
  "picocolors": "^1.1.1",
119
- "postcss": "8.5.32",
119
+ "postcss": "8.5.33",
120
120
  "remark-directive": "^4.0.0",
121
121
  "rsbuild-plugin-publint": "^1.0.0",
122
122
  "rsbuild-plugin-virtual-module": "0.4.5",