Skip to content

Commit 8f71148

Browse files
chore: refresh stacked plugin SPI
# Conflicts: # packages/rstack/src/rslibConfig.ts # packages/rstack/src/rspressConfig.ts # pnpm-lock.yaml
2 parents adf9ab2 + 96b0de5 commit 8f71148

94 files changed

Lines changed: 540 additions & 446 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/migrate-to-rstack-cli/SKILL.md‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,21 @@ define.test({
5353
});
5454
```
5555

56-
Prefer async config functions and dynamic imports for runtime plugins and presets:
56+
Use dynamic imports in async config functions only for external plugins, presets, and other dependencies:
5757

5858
```ts
59-
define.lint(async () => {
60-
const { js, ts } = await import('rstack/lint');
61-
return [js.configs.recommended, ts.configs.recommended];
59+
define.app(async () => {
60+
const { pluginReact } = await import('@rsbuild/plugin-react');
61+
return {
62+
plugins: [pluginReact()],
63+
};
6264
});
6365
```
6466

67+
`define.lint` provides `@rslint/core` APIs to its config factory, so no manual import is needed:
68+
69+
```ts
70+
define.lint(({ js }) => [js.configs.recommended]);
71+
```
72+
6573
Rstack loads TypeScript configs as native ESM. Preserve runtime-resolvable file extensions, replace CommonJS globals such as `__dirname`.

‎.agents/skills/migrate-to-rstack-cli/references/rslint.md‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,20 @@ Read this reference when the project uses `@rslint/core`, `rslint.config.*`, `rs
55
## Steps
66

77
1. Replace the `rslint` executable prefix with `rs lint`. For example, replace `rslint --fix` with `rs lint --fix`.
8-
2. Move the old config into `define.lint`, replacing Rslint's `defineConfig()` wrapper and import. Dynamically import presets from `rstack/lint` inside an async config function.
9-
3. Replace direct config/API imports from `@rslint/core` with exports from `rstack/lint` where available.
10-
4. Replace custom `--config` paths with the migrated `rstack.config.*` path.
11-
5. Remove `@rslint/core` only when no uncovered direct runtime API remains. Delete `rslint.config.*`.
8+
2. Move the old config into `define.lint`, replacing Rslint's `defineConfig()` wrapper and import. Receive `@rslint/core` exports from the factory parameter.
9+
3. Replace custom `--config` paths with the migrated `rstack.config.*` path.
10+
4. Remove `@rslint/core` only when no uncovered direct runtime API remains. Delete `rslint.config.*`.
1211

1312
## Config Pattern
1413

1514
```ts
1615
import { define } from 'rstack';
1716

18-
define.lint(async () => {
19-
const { js, ts } = await import('rstack/lint');
20-
return [js.configs.recommended, ts.configs.recommended];
21-
});
17+
define.lint(({ js, ts }) => [js.configs.recommended, ts.configs.recommendedTypeChecked]);
2218
```
2319

20+
Preserve existing presets and rules during migration.
21+
2422
## Script Pattern
2523

2624
If a script also runs Prettier, migrate its formatting command as described in [prettier.md](prettier.md).

‎examples/app-react/rstack.config.ts‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ define.test({
1212
setupFiles: ['./tests/rstest.setup.ts'],
1313
});
1414

15-
define.lint(async () => {
16-
const { js, ts, reactPlugin, reactHooksPlugin } = await import('rstack/lint');
17-
return [
18-
js.configs.recommended,
19-
ts.configs.recommended,
20-
reactPlugin.configs.recommended,
21-
reactHooksPlugin.configs.recommended,
22-
];
23-
});
15+
define.lint(({ js, ts, reactPlugin, reactHooksPlugin }) => [
16+
js.configs.recommended,
17+
ts.configs.recommended,
18+
reactPlugin.configs.recommended,
19+
reactHooksPlugin.configs.recommended,
20+
]);

‎examples/app-vanilla/rstack.config.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,4 @@ define.test({
66
setupFiles: ['./tests/rstest.setup.ts'],
77
});
88

9-
define.lint(async () => {
10-
const { js, ts } = await import('rstack/lint');
11-
return [js.configs.recommended, ts.configs.recommended];
12-
});
9+
define.lint(({ js, ts }) => [js.configs.recommended, ts.configs.recommended]);

‎examples/documentation/rstack.config.ts‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ define.doc({
77
title: 'My Site',
88
});
99

10-
define.lint(async () => {
11-
const { js, ts, reactPlugin, reactHooksPlugin } = await import('rstack/lint');
12-
return [
13-
js.configs.recommended,
14-
ts.configs.recommended,
15-
reactPlugin.configs.recommended,
16-
reactHooksPlugin.configs.recommended,
17-
];
18-
});
10+
define.lint(({ js, ts, reactPlugin, reactHooksPlugin }) => [
11+
js.configs.recommended,
12+
ts.configs.recommended,
13+
reactPlugin.configs.recommended,
14+
reactHooksPlugin.configs.recommended,
15+
]);

‎examples/lib-node/rstack.config.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,4 @@ define.lib({
66
syntax: ['node 22'],
77
});
88

9-
define.lint(async () => {
10-
const { js, ts } = await import('rstack/lint');
11-
return [js.configs.recommended, ts.configs.recommended];
12-
});
9+
define.lint(({ js, ts }) => [js.configs.recommended, ts.configs.recommended]);

‎examples/lib-react/rstack.config.ts‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@ define.test({
2222
setupFiles: ['./tests/rstest.setup.ts'],
2323
});
2424

25-
define.lint(async () => {
26-
const { js, ts, reactPlugin, reactHooksPlugin } = await import('rstack/lint');
27-
return [
28-
js.configs.recommended,
29-
ts.configs.recommended,
30-
reactPlugin.configs.recommended,
31-
reactHooksPlugin.configs.recommended,
32-
];
33-
});
25+
define.lint(({ js, ts, reactPlugin, reactHooksPlugin }) => [
26+
js.configs.recommended,
27+
ts.configs.recommended,
28+
reactPlugin.configs.recommended,
29+
reactHooksPlugin.configs.recommended,
30+
]);

‎examples/rstest-inline-projects/rstack.config.ts‎

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

examples/rstest-inline-projects/package.json renamed to examples/test-inline-projects/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@examples/rstest-inline-projects",
2+
"name": "@examples/test-inline-projects",
33
"private": true,
44
"type": "module",
55
"scripts": {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Rstack configuration guide: https://rstack.rs/config
2+
import { define } from 'rstack';
3+
4+
define.app(async () => {
5+
const { pluginReact } = await import('@rsbuild/plugin-react');
6+
return {
7+
plugins: [pluginReact()],
8+
};
9+
});
10+
11+
define.test(async () => {
12+
const { defineInlineProject } = await import('rstack/test');
13+
return {
14+
projects: [
15+
defineInlineProject({
16+
name: 'ssr',
17+
include: ['./tests/ssr.test.tsx'],
18+
testEnvironment: 'node',
19+
}),
20+
defineInlineProject({
21+
name: 'dom',
22+
include: ['./tests/dom.test.tsx'],
23+
testEnvironment: 'happy-dom',
24+
}),
25+
],
26+
};
27+
});

0 commit comments

Comments
 (0)