Skip to content

Commit 0a8ec2a

Browse files
authored
feat!: migrate to rspress v2 (#28)
1 parent 94ecf6f commit 0a8ec2a

22 files changed

+1150
-3024
lines changed

.changeset/pre.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"mode": "pre",
3+
"tag": "next",
4+
"initialVersions": {
5+
"@alauda/doom": "0.23.5"
6+
},
7+
"changesets": []
8+
}

.changeset/rotten-cows-cough.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@alauda/doom": major
3+
---
4+
5+
feat!: migrate to rspress v2

package.json

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,26 @@
5656
"version": "changeset version && yarn --no-immutable"
5757
},
5858
"dependencies": {
59-
"@cspell/eslint-plugin": "^9.0.1",
59+
"@cspell/eslint-plugin": "^9.0.2",
6060
"@eslint-react/eslint-plugin": "^1.49.0",
6161
"@inquirer/prompts": "^7.5.1",
6262
"@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
6363
"@playwright/browser-chromium": "^1.52.0",
64+
"@rsbuild/plugin-sass": "^1.3.1",
6465
"@rsbuild/plugin-yaml": "^1.0.2",
65-
"@rspress/core": "1.44.0",
66+
"@rspress/core": "2.0.0-beta.6",
6667
"@shikijs/transformers": "^3.4.2",
6768
"chokidar": "^4.0.3",
6869
"cli-progress": "^3.12.0",
6970
"clsx": "^2.1.1",
70-
"commander": "^13.1.0",
71+
"commander": "^14.0.0",
7172
"ejs": "^3.1.10",
72-
"es-toolkit": "^1.37.2",
73-
"eslint": "^9.26.0",
73+
"es-toolkit": "^1.38.0",
74+
"eslint": "^9.27.0",
7475
"eslint-plugin-mdx": "^3.4.2",
7576
"html-tag-names": "^2.1.0",
76-
"mdast-util-mdx": "^2.0.1",
77-
"mdast-util-mdx-jsx": "^2.1.4",
77+
"mdast-util-mdx": "^3.0.0",
78+
"mdast-util-mdx-jsx": "^3.2.0",
7879
"mermaid": "^11.6.0",
7980
"openai": "^5.0.0-beta.0",
8081
"openapi-types": "^12.1.3",
@@ -83,13 +84,13 @@
8384
"pdf-merger-js": "^5.1.2",
8485
"picomatch": "^4.0.2",
8586
"playwright": "^1.52.0",
86-
"react-markdown": "^8.0.7",
87-
"rehype-raw": "^6.1.1",
88-
"remark-directive": "^2.0.1",
89-
"remark-frontmatter": "^4.0.1",
90-
"remark-gfm": "^3.0.1",
91-
"remark-mdx": "^2.3.0",
92-
"remark-stringify": "^10.0.3",
87+
"react-markdown": "^10.1.0",
88+
"rehype-raw": "^7.0.0",
89+
"remark-directive": "^4.0.0",
90+
"remark-frontmatter": "^5.0.0",
91+
"remark-gfm": "^4.0.1",
92+
"remark-mdx": "^3.1.0",
93+
"remark-stringify": "^11.0.0",
9394
"shiki": "^3.4.2",
9495
"simple-git": "^3.27.0",
9596
"swagger2openapi": "^7.0.8",
@@ -103,23 +104,23 @@
103104
"devDependencies": {
104105
"@changesets/changelog-github": "^0.5.1",
105106
"@changesets/cli": "^2.29.4",
106-
"@eslint/js": "^9.26.0",
107+
"@eslint/js": "^9.27.0",
107108
"@swc-node/register": "^1.10.10",
108109
"@swc/core": "1.11.24",
109110
"@total-typescript/ts-reset": "^0.6.1",
110111
"@types/cli-progress": "^3.11.6",
111112
"@types/ejs": "^3.1.5",
112-
"@types/node": "^18.19.100",
113+
"@types/node": "^22.15.21",
113114
"@types/picomatch": "^4.0.0",
114-
"@types/react": "^18.3.21",
115-
"@types/react-dom": "^18.3.7",
115+
"@types/react": "^19.1.4",
116+
"@types/react-dom": "^19.1.5",
116117
"@types/swagger2openapi": "^7.0.4",
117118
"@unts/patch-package": "^8.1.1",
118119
"clean-pkg-json": "^1.3.0",
119-
"eslint-import-resolver-typescript": "^4.3.4",
120-
"eslint-plugin-import-x": "^4.11.1",
120+
"eslint-import-resolver-typescript": "^4.3.5",
121+
"eslint-plugin-import-x": "^4.12.2",
121122
"nano-staged": "^0.8.0",
122-
"npm-run-all2": "^7.0.2",
123+
"npm-run-all2": "^8.0.3",
123124
"prettier": "^3.5.3",
124125
"prettier-plugin-pkg": "^0.19.1",
125126
"prettier-plugin-properties": "^0.3.0",

patches/unist-util-visit-parents+5.1.3.patch

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/cli/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ program
220220
const runBuild = () =>
221221
build({
222222
config,
223-
appDirectory: CWD,
224223
docDirectory,
225224
})
226225

src/cli/load-config.ts

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from 'node:fs/promises'
22
import path from 'node:path'
33

44
import { nodeTypes } from '@mdx-js/mdx'
5+
import { pluginSass } from '@rsbuild/plugin-sass'
56
import { pluginYaml } from '@rsbuild/plugin-yaml'
67
import {
78
addLeadingSlash,
@@ -36,7 +37,6 @@ import {
3637
mermaidPlugin,
3738
permissionPlugin,
3839
replacePlugin,
39-
shikiPlugin,
4040
} from '../plugins/index.js'
4141
import {
4242
isExplicitlyUnversioned,
@@ -225,12 +225,23 @@ const getCommonConfig = async ({
225225
},
226226
markdown: {
227227
checkDeadLinks: true,
228-
highlightLanguages: [['jsonc', 'json']],
229-
mdxRs: false,
230228
rehypePlugins: [[rehypeRaw, { passThrough: nodeTypes }]],
231-
},
232-
ssg: {
233-
strict: true,
229+
shiki: {
230+
transformers: [
231+
// builtin transformers
232+
transformerMetaHighlight(),
233+
transformerMetaWordHighlight(),
234+
transformerNotationDiff(),
235+
transformerNotationErrorLevel(),
236+
transformerNotationFocus(),
237+
transformerNotationHighlight(),
238+
transformerNotationWordHighlight(),
239+
transformerRemoveNotationEscape(),
240+
241+
// custom transformers
242+
createTransformerCallouts(),
243+
],
244+
},
234245
},
235246
themeConfig: {
236247
enableScrollToTop: true,
@@ -263,43 +274,12 @@ const getCommonConfig = async ({
263274
localBasePath,
264275
force,
265276
}),
266-
shikiPlugin({
267-
theme: config.shiki?.theme,
268-
langs: [
269-
'dockerfile',
270-
'dotenv',
271-
'html',
272-
'go',
273-
'jsonc',
274-
'mermaid',
275-
'java',
276-
'python',
277-
'toml',
278-
...(config.shiki?.langs ?? []),
279-
],
280-
transformers: [
281-
// builtin transformers
282-
transformerMetaHighlight(),
283-
transformerMetaWordHighlight(),
284-
transformerNotationDiff(),
285-
transformerNotationErrorLevel(),
286-
transformerNotationFocus(),
287-
transformerNotationHighlight(),
288-
transformerNotationWordHighlight(),
289-
transformerRemoveNotationEscape(),
290-
291-
// custom transformers
292-
createTransformerCallouts(),
293-
294-
...(config.shiki?.transformers ?? []),
295-
],
296-
}),
297277
],
298278
builderConfig: {
299279
dev: {
300280
lazyCompilation: lazy,
301281
},
302-
plugins: [pluginYaml()],
282+
plugins: [pluginSass(), pluginYaml()],
303283
server: {
304284
open,
305285
},

src/plugins/auto-toc/remark-auto-toc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const remarkAutoToc: Plugin<[], Root> = function () {
3232
{
3333
type: 'mdxJsxAttribute',
3434
name: 'className',
35-
value: 'doom-auto-toc',
35+
value: 'doom-auto-toc rspress-toc-exclude',
3636
},
3737
],
3838
children: [

src/plugins/replace/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ export * from './normalize-img-src.js'
1717
export type * from './types.js'
1818
export * from './utils.js'
1919

20+
declare module 'unified' {
21+
interface Data {
22+
pageMeta: Record<string, unknown>
23+
}
24+
}
25+
26+
declare module 'mdast' {
27+
interface Data {
28+
_mdxExplicitJsx?: boolean
29+
}
30+
}
31+
2032
export const replacePlugin = ({
2133
lang,
2234
localBasePath,

src/plugins/replace/normalize-img-src.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from 'node:path'
33

44
import { isExternalUrl, removeLeadingSlash } from '@rspress/core'
55
import { cloneDeep } from 'es-toolkit'
6-
import type { Content } from 'mdast'
6+
import type { RootContent } from 'mdast'
77
import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx'
88
import { visit } from 'unist-util-visit'
99

@@ -25,7 +25,7 @@ export interface NormalizeImgSrcOptions {
2525
}
2626

2727
export const normalizeImgSrc = (
28-
content: Content,
28+
content: RootContent,
2929
{
3030
refSource,
3131
localPublicBase,

src/plugins/replace/rehype-normalize-link.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const rehypeNormalizeLink: Plugin<[], Root> = () => {
4848
return
4949
}
5050

51-
const { alt, src } = node.properties || {}
51+
const { alt, src } = node.properties
5252

5353
if (typeof src !== 'string') {
5454
return

0 commit comments

Comments
 (0)