@rstest/adapter-rsbuild 0.10.3 → 0.10.4
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.js +16 -8
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { loadConfig, mergeRsbuildConfig } from "@rsbuild/core";
|
|
2
|
-
import { dirname, isAbsolute,
|
|
3
|
-
|
|
2
|
+
import { dirname, isAbsolute, normalize, resolve } from "node:path";
|
|
3
|
+
import "node:module";
|
|
4
|
+
const resolveCacheDependency = ({ dependency, configPath, root })=>{
|
|
4
5
|
if (isAbsolute(dependency)) return normalize(dependency);
|
|
5
|
-
if (configPath) return normalize(
|
|
6
|
-
return root ? normalize(
|
|
6
|
+
if (configPath) return normalize(resolve(dirname(configPath), dependency));
|
|
7
|
+
return root ? normalize(resolve(root, dependency)) : dependency;
|
|
7
8
|
};
|
|
8
|
-
const
|
|
9
|
+
const resolveBuildCache = ({ buildCache, configPath, root })=>{
|
|
9
10
|
if (void 0 === buildCache) return;
|
|
10
11
|
if (false === buildCache) return false;
|
|
11
12
|
if (true === buildCache) return configPath ? {
|
|
@@ -13,7 +14,7 @@ const updateCacheConfig = ({ buildCache, configPath, root })=>{
|
|
|
13
14
|
normalize(configPath)
|
|
14
15
|
]
|
|
15
16
|
} : true;
|
|
16
|
-
const buildDependencies = buildCache.buildDependencies?.map((dependency)=>
|
|
17
|
+
const buildDependencies = buildCache.buildDependencies?.map((dependency)=>resolveCacheDependency({
|
|
17
18
|
dependency,
|
|
18
19
|
configPath,
|
|
19
20
|
root
|
|
@@ -28,6 +29,13 @@ const updateCacheConfig = ({ buildCache, configPath, root })=>{
|
|
|
28
29
|
buildDependencies: nextBuildDependencies
|
|
29
30
|
};
|
|
30
31
|
};
|
|
32
|
+
const isNodeTarget = (target)=>{
|
|
33
|
+
const targets = Array.isArray(target) ? target.filter(Boolean) : 'string' == typeof target ? [
|
|
34
|
+
target
|
|
35
|
+
] : [];
|
|
36
|
+
return targets.some((t)=>'async-node' === t || t.startsWith('node'));
|
|
37
|
+
};
|
|
38
|
+
const resolveTestEnvironmentFromTarget = (target)=>isNodeTarget(target) ? 'node' : 'happy-dom';
|
|
31
39
|
function toRstestConfig({ configPath, environmentName, rsbuildConfig: rawRsbuildConfig, modifyRsbuildConfig }) {
|
|
32
40
|
const { environments, ...rawBuildConfig } = rawRsbuildConfig;
|
|
33
41
|
const environmentConfig = environmentName ? environments?.[environmentName] : void 0;
|
|
@@ -69,7 +77,7 @@ function toRstestConfig({ configPath, environmentName, rsbuildConfig: rawRsbuild
|
|
|
69
77
|
module
|
|
70
78
|
},
|
|
71
79
|
performance: {
|
|
72
|
-
buildCache:
|
|
80
|
+
buildCache: resolveBuildCache({
|
|
73
81
|
buildCache,
|
|
74
82
|
configPath,
|
|
75
83
|
root: finalBuildConfig.root
|
|
@@ -80,7 +88,7 @@ function toRstestConfig({ configPath, environmentName, rsbuildConfig: rawRsbuild
|
|
|
80
88
|
swc,
|
|
81
89
|
bundlerChain
|
|
82
90
|
},
|
|
83
|
-
testEnvironment:
|
|
91
|
+
testEnvironment: resolveTestEnvironmentFromTarget(target)
|
|
84
92
|
};
|
|
85
93
|
return rstestConfig;
|
|
86
94
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstest/adapter-rsbuild",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.4",
|
|
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.
|
|
34
|
-
"@rslib/core": "0.
|
|
35
|
-
"@rstest/core": "0.10.
|
|
33
|
+
"@rsbuild/core": "~2.0.11",
|
|
34
|
+
"@rslib/core": "0.22.0",
|
|
35
|
+
"@rstest/core": "0.10.4",
|
|
36
36
|
"@rstest/tsconfig": "0.0.1"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@rsbuild/core": "*",
|
|
40
|
-
"@rstest/core": "^0.10.
|
|
40
|
+
"@rstest/core": "^0.10.4"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|