You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 437a9d4
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: website/docs/en/guide/configuration.mdx
+19-19Lines changed: 19 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -158,7 +158,7 @@ When `extends` is omitted, Rstack CLI automatically connects the test configurat
158
158
159
159
If the root test configuration does not define `extends` and contains `projects`, Rstack CLI applies automatic inheritance to each inline project that omits its own `extends`. A function-based application or library configuration is resolved once and shared by those projects. String project entries are passed to Rstest unchanged; they load their external configurations independently and do not inherit the current application or library configuration.
160
160
161
-
These rules also apply to [shared configurations](#shared-configurations): Rstack first merges the test settings, then uses the merged App or Lib configuration for automatic inheritance.
161
+
These rules also apply to [shared configurations](#shared-configurations): Rstack first merges the test settings, then determines whether to inherit the merged App or Lib configuration.
162
162
163
163
> For more guidance on testing, see [Testing](./testing).
164
164
@@ -203,11 +203,11 @@ define.staged({
203
203
});
204
204
```
205
205
206
-
`rs staged` requires a staged configuration, provided by `define.staged()` or a shared configuration, and reports an error when it is missing.
206
+
Provide a staged configuration through `define.staged()` or a [shared configuration](#shared-configurations). `rs staged`reports an error if neither provides one.
207
207
208
208
## Shared configurations
209
209
210
-
Use `define.extends()` to share build, test, lint, and formatting settings across projects. Define a shared configuration as a plain object with the `RstackConfig` type. Its fields accept the same values as the corresponding `define.*()` APIs:
210
+
Use `define.extends()` to share build, test, lint, and formatting settings across projects. A shared configuration is a plain object whose fields accept the same values as the corresponding `define.*()` APIs. In TypeScript, use `RstackConfig` to check its types:
211
211
212
212
```ts title="shared.ts"
213
213
importtype { RstackConfig } from'rstack';
@@ -248,7 +248,7 @@ Configurations are applied in this order:
248
248
1. Shared configurations in the `define.extends()` array, from left to right.
249
249
2. The project's own `define.*()` configurations, even if they appear before `define.extends()` in the file.
250
250
251
-
Later configurations take precedence according to each tool's [merge rules](#merge-rules).
251
+
Each tool's [merge rules](#merge-rules) determine which values are combined and which are replaced.
252
252
253
253
Shared configurations can also extend other shared configurations:
Inherited configurations are applied before the object that extends them. Here, the order is `sharedConfig → teamConfig → project configuration`.
267
+
Inherited configurations are applied first. With `define.extends([teamConfig])`, the order is `sharedConfig → teamConfig → project configuration`.
268
268
269
-
Shared configurations are applied each time they appear. If both `a` and `b` extend `base`, for example, `define.extends([a, b])` applies `base → a → base → b → project configuration`. Array entries may therefore be added more than once; each tool determines how to handle duplicate plugins. Circular inheritance throws an error with the location of the circular reference.
269
+
Repeated references are not deduplicated. If both `a` and `b` extend `base`, `define.extends([a, b])` applies `base → a → base → b → project configuration`. Each tool handles duplicate plugins according to its own rules. Circular inheritance throws an error that identifies the circular reference.
270
270
271
271
### Merge rules
272
272
273
273
Rstack merges configurations separately for each tool:
|`test`| Uses Rstest's `mergeRstestConfig`, then determines whether to inherit the merged App or Lib configuration. See [Test configuration inheritance](./testing#configuration-inheritance).|
280
-
|`lint`| Concatenates configuration arrays in order; Rslint applies their rules. |
281
-
|`fmt`| Shallow merge: later values replace earlier values for the same option. Arrays and objects, including `overrides`, are replaced as a whole. |
282
-
|`doc`| Uses Rspress's `mergeDocConfig`: recursively merges objects, appends arrays, and replaces ordinary functions with later functions. |
283
-
|`staged`| Shallow merge by glob pattern: later tasks replace earlier tasks for the same pattern, including command arrays and task functions. |
|`lint`| Concatenates configuration arrays in order; Rslint applies their rules. |
281
+
|`fmt`| Shallow merge: later values replace earlier values for the same option. Arrays and objects, including `overrides`, are replaced as a whole. |
282
+
|`doc`| Uses Rspress's `mergeDocConfig`: recursively merges objects, appends arrays, and replaces ordinary functions with later functions. |
283
+
|`staged`| Shallow merge by glob pattern: later tasks replace earlier tasks for the same pattern, including command arrays and task functions. |
284
284
285
-
For`doc`, Rspress also handles a mix of array and non-array values: if both are defined, it wraps the non-array value in an array before concatenating them. `builderConfig` follows these same Rspress rules. For example, a later `builderConfig.tools.rspack` callback replaces an earlier one, while callback arrays are concatenated.
285
+
The`doc` rules also apply to `builderConfig`: a later `builderConfig.tools.rspack` callback replaces an earlier one, while callback arrays are concatenated. When an array is merged with a defined non-array value, Rspress treats that value as a single array item.
286
286
287
-
For `staged`, a top-level task-generator function replaces all earlier settings. A later configuration also replaces that function in full. Any subsequent glob mappings then merge as usual. For example, with `glob mappings → function → new glob mappings`, only the new mappings remain. Task functions run when lint-staged passes them the list of staged files.
287
+
For `staged`, if either configuration is a top-level task-generator function, the later configuration replaces the earlier one entirely. For example, `glob mappings → function → new glob mappings` leaves only the new mappings. Task functions run when lint-staged supplies the staged file list.
288
288
289
289
### Dependencies and paths
290
290
291
291
Shared configurations can also [import dependencies dynamically](#loading-dependencies-on-demand) inside tool configuration functions, so each command loads only what it needs.
292
292
293
-
Relative paths follow each tool's existing rules. Use an absolute path to reference a file shipped with a shared configuration:
293
+
Relative paths follow each tool's existing rules; they are not automatically resolved from the shared module's directory. Use an absolute path for files shipped with the shared configuration:
0 commit comments