Skip to content

Commit 7d8ac9b

Browse files
SoonIterclaude
andauthored
refactor!: merge @rspress/runtime into @rspress/core package and remove @rspress/runtime package (#2935)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 170fef8 commit 7d8ac9b

36 files changed

+34
-207
lines changed

packages/core/package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
"default": "./dist/theme/index.js"
3636
},
3737
"./runtime": {
38-
"types": "./dist/runtime.d.ts",
39-
"default": "./dist/runtime.js"
38+
"types": "./dist/runtime/index.d.ts",
39+
"default": "./dist/runtime/index.js"
4040
},
4141
"./shiki-transformers": {
4242
"types": "./dist/shiki-transformers.d.ts",
@@ -61,9 +61,8 @@
6161
"index.html"
6262
],
6363
"scripts": {
64-
"build": "rslib build",
64+
"build": "node ./scripts/generateJsonSchema.mjs && rslib build",
6565
"dev": "rslib build -w",
66-
"prepare": "node ./scripts/generateJsonSchema.mjs",
6766
"reset": "rimraf ./**/node_modules"
6867
},
6968
"dependencies": {
@@ -72,7 +71,6 @@
7271
"@rsbuild/core": "~1.7.1",
7372
"@rsbuild/plugin-react": "~1.4.2",
7473
"@rspress/mdx-rs": "0.6.6",
75-
"@rspress/runtime": "workspace:*",
7674
"@rspress/shared": "workspace:*",
7775
"@shikijs/rehype": "^3.20.0",
7876
"@types/unist": "^3.0.3",

packages/core/rslib.config.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const COMMON_EXTERNALS = [
1414
'virtual-global-components',
1515
'virtual-search-hooks',
1616
'virtual-i18n-text',
17-
'@rspress/runtime',
1817
'@theme',
1918
// To be externalized when bundling d.ts.
2019
'@types/react',
@@ -23,7 +22,6 @@ const COMMON_EXTERNALS = [
2322
'@rspress/core/shiki-transformers',
2423
'@rspress/core/_private/react',
2524
'@rspress/shared',
26-
'@rspress/runtime',
2725
];
2826

2927
export default defineConfig({
@@ -35,7 +33,6 @@ export default defineConfig({
3533
index: './src/index.ts',
3634
'cli/index': './src/cli/index.ts',
3735
'shiki-transformers': './src/shiki-transformers.ts',
38-
runtime: './src/runtime.ts',
3936

4037
// TODO: should add entry by new URL parser in Rspack module graph
4138
'node/mdx/loader': './src/node/mdx/loader.ts',
@@ -50,6 +47,7 @@ export default defineConfig({
5047
buildCache: false,
5148
},
5249
output: {
50+
target: 'node',
5351
externals: COMMON_EXTERNALS,
5452
filenameHash: true,
5553
},
@@ -92,7 +90,7 @@ export default defineConfig({
9290
syntax: 'es2022',
9391
source: {
9492
entry: {
95-
index: './src/runtime/*.{tsx,ts}',
93+
index: './src/runtime/**/*.{tsx,ts}',
9694
},
9795
},
9896
output: {

packages/core/scripts/generateJsonSchema.mjs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
import fs from 'node:fs';
2+
import { fileURLToPath } from 'node:url';
23
import tsj from 'ts-json-schema-generator';
34

45
/** @type {import('ts-json-schema-generator/dist/src/Config').Config} */
56

67
const schemaConfigList = [
78
{
89
config: {
9-
path: new URL('../src/node/auto-nav-sidebar/type.ts', import.meta.url)
10-
.pathname,
11-
tsconfig: new URL('../tsconfig.json', import.meta.url).pathname,
10+
path: fileURLToPath(
11+
new URL('../src/node/auto-nav-sidebar/type.ts', import.meta.url),
12+
),
13+
tsconfig: fileURLToPath(new URL('../tsconfig.json', import.meta.url)),
1214
type: 'MetaJson', // Or <type-name> if you want to generate schema for that one type only
1315
},
14-
outputPath: new URL('../meta-json-schema.json', import.meta.url).pathname,
16+
outputPath: fileURLToPath(
17+
new URL('../meta-json-schema.json', import.meta.url),
18+
),
1519
},
1620
{
1721
config: {
18-
path: new URL('../src/node/auto-nav-sidebar/type.ts', import.meta.url)
19-
.pathname,
20-
tsconfig: new URL('../tsconfig.json', import.meta.url).pathname,
22+
path: fileURLToPath(
23+
new URL('../src/node/auto-nav-sidebar/type.ts', import.meta.url),
24+
),
25+
tsconfig: fileURLToPath(new URL('../tsconfig.json', import.meta.url)),
2126
type: 'NavJson', // Or <type-name> if you want to generate schema for that one type only
2227
},
23-
outputPath: new URL('../nav-json-schema.json', import.meta.url).pathname,
28+
outputPath: fileURLToPath(
29+
new URL('../nav-json-schema.json', import.meta.url),
30+
),
2431
},
2532
];
2633

packages/core/src/node/initRsbuild.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,10 @@ async function createInternalBuildConfig(
245245
'@theme-original': DEFAULT_THEME,
246246
'@rspress/core/theme-original': DEFAULT_THEME,
247247

248-
'@rspress/core/runtime': path.join(PACKAGE_ROOT, 'dist/runtime.js'),
248+
'@rspress/core/runtime': path.join(
249+
PACKAGE_ROOT,
250+
'dist/runtime/index.js',
251+
),
249252
'@rspress/core/shiki-transformers': path.join(
250253
PACKAGE_ROOT,
251254
'dist/shiki-transformers.js',

packages/core/src/runtime.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)