From 2e3f36b58178ad83ec01723784d0fa00bdb7da60 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 11 Jul 2026 18:17:29 +0800 Subject: [PATCH] feat: export Rsbuild APIs from rstack/app --- .agents/skills/rstack-cli-best-practices/SKILL.md | 1 + README.md | 11 ++++++----- packages/rstack/package.json | 4 ++++ packages/rstack/rslib.config.ts | 1 + packages/rstack/src/app.ts | 9 +++++++++ .../rstack/test/exports/app-subpath/index.test.ts | 8 ++++++++ packages/rstack/test/tsconfig.json | 1 + 7 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 packages/rstack/src/app.ts create mode 100644 packages/rstack/test/exports/app-subpath/index.test.ts diff --git a/.agents/skills/rstack-cli-best-practices/SKILL.md b/.agents/skills/rstack-cli-best-practices/SKILL.md index 53ea14d..0551c75 100644 --- a/.agents/skills/rstack-cli-best-practices/SKILL.md +++ b/.agents/skills/rstack-cli-best-practices/SKILL.md @@ -75,6 +75,7 @@ Prefer Rstack-exported paths: | Instead of | Prefer | | ------------------------- | ------------------------ | +| `@rsbuild/core` | `rstack/app` | | `@rslib/core` | `rstack/lib` | | `@rstest/core` | `rstack/test` | | `@rslint/core` | `rstack/lint` | diff --git a/README.md b/README.md index b01bed2..031fea2 100644 --- a/README.md +++ b/README.md @@ -90,11 +90,12 @@ pnpm doc 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` | +| Tool | Import path | +| ------- | ------------- | +| Rsbuild | `rstack/app` | +| Rslib | `rstack/lib` | +| Rslint | `rstack/lint` | +| Rstest | `rstack/test` | For example, import Rstest APIs without adding `@rstest/core` as a direct dependency: diff --git a/packages/rstack/package.json b/packages/rstack/package.json index 5a3604c..16679b0 100644 --- a/packages/rstack/package.json +++ b/packages/rstack/package.json @@ -19,6 +19,10 @@ "types": "./dist/index.d.ts", "default": "./dist/index.js" }, + "./app": { + "types": "./dist/app.d.ts", + "default": "./dist/app.js" + }, "./test": { "types": "./dist/test.d.ts", "default": "./dist/test.js" diff --git a/packages/rstack/rslib.config.ts b/packages/rstack/rslib.config.ts index 88ffe6d..cfa492a 100644 --- a/packages/rstack/rslib.config.ts +++ b/packages/rstack/rslib.config.ts @@ -11,6 +11,7 @@ export default defineConfig({ rslintConfig: './src/rslintConfig.ts', rspressConfig: './src/rspressConfig.ts', rstestConfig: './src/rstestConfig.ts', + app: './src/app.ts', lib: './src/lib.ts', lint: './src/lint.ts', test: './src/test.ts', diff --git a/packages/rstack/src/app.ts b/packages/rstack/src/app.ts new file mode 100644 index 0000000..d0c68b5 --- /dev/null +++ b/packages/rstack/src/app.ts @@ -0,0 +1,9 @@ +/** + * Re-export @rsbuild/core APIs so users can import application APIs from `rstack/app`. + * + * @example + * ```ts + * import { createRsbuild } from 'rstack/app'; + * ``` + */ +export * from '@rsbuild/core'; diff --git a/packages/rstack/test/exports/app-subpath/index.test.ts b/packages/rstack/test/exports/app-subpath/index.test.ts new file mode 100644 index 0000000..835eb72 --- /dev/null +++ b/packages/rstack/test/exports/app-subpath/index.test.ts @@ -0,0 +1,8 @@ +import * as rsbuild from '@rsbuild/core'; +import { expect, test } from 'rstack/test'; + +test('should expose all Rsbuild APIs from `rstack/app`', async () => { + const app = await import('rstack/app'); + + expect(app).toEqual(rsbuild); +}); diff --git a/packages/rstack/test/tsconfig.json b/packages/rstack/test/tsconfig.json index 2cef022..0ac69e0 100644 --- a/packages/rstack/test/tsconfig.json +++ b/packages/rstack/test/tsconfig.json @@ -7,6 +7,7 @@ "types": ["node"], "paths": { "rstack": ["../src/index.ts"], + "rstack/app": ["../src/app.ts"], "rstack/lib": ["../src/lib.ts"], "rstack/lint": ["../src/lint.ts"], "rstack/test": ["../src/test.ts"],