Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .agents/skills/rstack-cli-best-practices/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ Prefer Rstack-exported paths:

| Instead of | Prefer |
| ------------------------- | ------------------------ |
| `@rslib/core` | `rstack/lib` |
| `@rstest/core` | `rstack/test` |
| `@rslint/core` | `rstack/lint` |
| `@rsbuild/core/types` | `rstack/types` |
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ pnpm lib
pnpm doc
```

## API imports

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

| Tool | Import path |
| ------ | ------------- |
| Rslib | `rstack/lib` |
| Rslint | `rstack/lint` |
| Rstest | `rstack/test` |

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

```ts
import { expect, test } from 'rstack/test';
```

## Credits

Rstack CLI is inspired by:
Expand Down
4 changes: 4 additions & 0 deletions packages/rstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"types": "./dist/test.d.ts",
"default": "./dist/test.js"
},
"./lib": {
"types": "./dist/lib.d.ts",
"default": "./dist/lib.js"
},
"./lint": {
"types": "./dist/lint.d.ts",
"default": "./dist/lint.js"
Expand Down
1 change: 1 addition & 0 deletions packages/rstack/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default defineConfig({
rslintConfig: './src/rslintConfig.ts',
rspressConfig: './src/rspressConfig.ts',
rstestConfig: './src/rstestConfig.ts',
lib: './src/lib.ts',
lint: './src/lint.ts',
test: './src/test.ts',
},
Expand Down
9 changes: 9 additions & 0 deletions packages/rstack/src/lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Re-export @rslib/core APIs so users can import library APIs from `rstack/lib`.
*
* @example
* ```ts
* import { defineConfig } from 'rstack/lib';
* ```
*/
export * from '@rslib/core';
8 changes: 8 additions & 0 deletions packages/rstack/test/exports/lib-subpath/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as rslib from '@rslib/core';
import { expect, test } from 'rstack/test';

test('should expose all Rslib APIs from `rstack/lib`', async () => {
const lib = await import('rstack/lib');

expect(lib).toEqual(rslib);
});
1 change: 1 addition & 0 deletions packages/rstack/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"types": ["node"],
"paths": {
"rstack": ["../src/index.ts"],
"rstack/lib": ["../src/lib.ts"],
"rstack/lint": ["../src/lint.ts"],
"rstack/test": ["../src/test.ts"],
"#test-helpers": ["./helpers/index.ts"]
Expand Down