@rstest/adapter-rsbuild 0.10.6 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -14,6 +14,11 @@ import { RsbuildConfig } from '@rsbuild/core';
14
14
  export declare function withRsbuildConfig(options?: WithRsbuildConfigOptions): ExtendConfigFn;
15
15
 
16
16
  export declare interface WithRsbuildConfigOptions {
17
+ /**
18
+ * Rsbuild config object to convert directly.
19
+ * When provided, `configPath` is only used as file metadata.
20
+ * @default undefined
21
+ */ config?: RsbuildConfig;
17
22
  /**
18
23
  * `cwd` passed to loadConfig of Rsbuild
19
24
  * @default process.cwd()
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
+ import { dirname, isAbsolute, join, normalize, resolve } from "node:path";
1
2
  import { loadConfig, mergeRsbuildConfig } from "@rsbuild/core";
2
- import { dirname, isAbsolute, normalize, resolve } from "node:path";
3
3
  import "node:module";
4
4
  const resolveCacheDependency = ({ dependency, configPath, root })=>{
5
5
  if (isAbsolute(dependency)) return normalize(dependency);
@@ -94,12 +94,24 @@ function toRstestConfig({ configPath, environmentName, rsbuildConfig: rawRsbuild
94
94
  }
95
95
  function withRsbuildConfig(options = {}) {
96
96
  return async ()=>{
97
- const { configPath, modifyRsbuildConfig, environmentName, cwd = process.cwd() } = options;
98
- const { content: rsbuildConfig, filePath } = await loadConfig({
99
- cwd,
100
- path: configPath
101
- });
102
- if (!filePath) return {};
97
+ const { config: inlineConfig, configPath, modifyRsbuildConfig, environmentName, cwd = process.cwd() } = options;
98
+ let rsbuildConfig;
99
+ let filePath;
100
+ if (inlineConfig) {
101
+ rsbuildConfig = inlineConfig;
102
+ if (configPath) {
103
+ filePath = configPath;
104
+ if (!isAbsolute(configPath)) filePath = join(cwd, configPath);
105
+ }
106
+ } else {
107
+ const loadedConfig = await loadConfig({
108
+ cwd,
109
+ path: configPath
110
+ });
111
+ rsbuildConfig = loadedConfig.content;
112
+ if (loadedConfig.filePath) filePath = loadedConfig.filePath;
113
+ }
114
+ if (!filePath && !inlineConfig) return {};
103
115
  const rstestConfig = toRstestConfig({
104
116
  environmentName,
105
117
  rsbuildConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstest/adapter-rsbuild",
3
- "version": "0.10.6",
3
+ "version": "0.11.0",
4
4
  "description": "Rstest adapter for rsbuild configuration",
5
5
  "keywords": [
6
6
  "rstest",
@@ -30,14 +30,14 @@
30
30
  "dist"
31
31
  ],
32
32
  "devDependencies": {
33
- "@rsbuild/core": "~2.0.15",
34
- "@rslib/core": "0.23.0",
35
- "@rstest/core": "0.10.6",
33
+ "@rsbuild/core": "~2.1.4",
34
+ "@rslib/core": "0.23.2",
35
+ "@rstest/core": "0.11.0",
36
36
  "@rstest/tsconfig": "0.0.1"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@rsbuild/core": "*",
40
- "@rstest/core": "^0.10.6"
40
+ "@rstest/core": "^0.11.0"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"