Skip to content

Commit 6f692bb

Browse files
authored
docs: clarify config imports in migration skill (#451)
1 parent e35e4a7 commit 6f692bb

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,22 @@ define.test({
7272

7373
### Modules and imports
7474

75-
Keep type-only and Node.js built-in imports at the top level. In async config functions, use a separate `await import(...)` for each tool-specific runtime dependency.
75+
Rstack loads every top-level import when it reads `rstack.config.*`. Prefer static imports when a config is only for an application and its tests, a library and its tests, or a documentation site.
76+
77+
If the same config also includes lint, formatting, or staged-file checks, dynamically import dependencies inside the relevant async config function to avoid loading them during checks. Keep type-only and Node.js built-in imports at the top level.
7678

7779
```ts
7880
define.app(async () => {
7981
const { pluginReact } = await import('@rsbuild/plugin-react');
80-
const { pluginSass } = await import('@rsbuild/plugin-sass');
8182

8283
return {
83-
plugins: [pluginReact(), pluginSass()],
84+
plugins: [pluginReact()],
8485
};
8586
});
86-
```
87-
88-
`define.lint` provides `@rslint/core` APIs to its config factory, so no manual import is needed:
8987

90-
```ts
9188
define.lint(({ js }) => [js.configs.recommended]);
9289
```
9390

91+
`define.lint` provides `@rslint/core` APIs to its config factory, so no manual import is needed.
92+
9493
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/rsbuild.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ Read this reference when the project uses `@rsbuild/core`, `rsbuild.config.*`, `
1818
## Config pattern
1919

2020
```ts
21+
import { pluginReact } from '@rsbuild/plugin-react';
2122
import { define } from 'rstack';
2223

23-
define.app(async () => {
24-
const { pluginReact } = await import('@rsbuild/plugin-react');
25-
return {
26-
plugins: [pluginReact()],
27-
};
24+
define.app({
25+
plugins: [pluginReact()],
2826
});
2927
```
3028

3129
If tests also use Rstest, read [rstest.md](rstest.md). `rs test` derives an Rsbuild test extension from `define.app` unless `define.test` sets `extends`.
3230

31+
Follow [Modules and imports](../SKILL.md#modules-and-imports) when the config imports plugins or themes.
32+
3333
## Validate
3434

3535
Run the migrated app build script. Smoke-test dev or preview when those scripts changed or their behavior is material.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ define.doc({
2222
});
2323
```
2424

25-
Use an async config and dynamic imports when plugins or themes require runtime imports.
25+
Follow [Modules and imports](../SKILL.md#modules-and-imports) when the config imports plugins or themes.
2626

2727
## Validate
2828

0 commit comments

Comments
 (0)