Skip to content

Commit 08e65ab

Browse files
authored
feat: export Rsbuild APIs from rstack/app (#29)
1 parent ce35db9 commit 08e65ab

7 files changed

Lines changed: 30 additions & 5 deletions

File tree

.agents/skills/rstack-cli-best-practices/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Prefer Rstack-exported paths:
7575

7676
| Instead of | Prefer |
7777
| ------------------------- | ------------------------ |
78+
| `@rsbuild/core` | `rstack/app` |
7879
| `@rslib/core` | `rstack/lib` |
7980
| `@rstest/core` | `rstack/test` |
8081
| `@rslint/core` | `rstack/lint` |

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ pnpm doc
9090

9191
Rstack re-exports the APIs of its underlying tools through dedicated entry points:
9292

93-
| Tool | Import path |
94-
| ------ | ------------- |
95-
| Rslib | `rstack/lib` |
96-
| Rslint | `rstack/lint` |
97-
| Rstest | `rstack/test` |
93+
| Tool | Import path |
94+
| ------- | ------------- |
95+
| Rsbuild | `rstack/app` |
96+
| Rslib | `rstack/lib` |
97+
| Rslint | `rstack/lint` |
98+
| Rstest | `rstack/test` |
9899

99100
For example, import Rstest APIs without adding `@rstest/core` as a direct dependency:
100101

packages/rstack/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
"types": "./dist/index.d.ts",
2020
"default": "./dist/index.js"
2121
},
22+
"./app": {
23+
"types": "./dist/app.d.ts",
24+
"default": "./dist/app.js"
25+
},
2226
"./test": {
2327
"types": "./dist/test.d.ts",
2428
"default": "./dist/test.js"

packages/rstack/rslib.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default defineConfig({
1111
rslintConfig: './src/rslintConfig.ts',
1212
rspressConfig: './src/rspressConfig.ts',
1313
rstestConfig: './src/rstestConfig.ts',
14+
app: './src/app.ts',
1415
lib: './src/lib.ts',
1516
lint: './src/lint.ts',
1617
test: './src/test.ts',

packages/rstack/src/app.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Re-export @rsbuild/core APIs so users can import application APIs from `rstack/app`.
3+
*
4+
* @example
5+
* ```ts
6+
* import { createRsbuild } from 'rstack/app';
7+
* ```
8+
*/
9+
export * from '@rsbuild/core';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import * as rsbuild from '@rsbuild/core';
2+
import { expect, test } from 'rstack/test';
3+
4+
test('should expose all Rsbuild APIs from `rstack/app`', async () => {
5+
const app = await import('rstack/app');
6+
7+
expect(app).toEqual(rsbuild);
8+
});

packages/rstack/test/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"types": ["node"],
88
"paths": {
99
"rstack": ["../src/index.ts"],
10+
"rstack/app": ["../src/app.ts"],
1011
"rstack/lib": ["../src/lib.ts"],
1112
"rstack/lint": ["../src/lint.ts"],
1213
"rstack/test": ["../src/test.ts"],

0 commit comments

Comments
 (0)