@rstest/adapter-rsbuild 0.10.3 → 0.10.5
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 +5 -10
- package/dist/index.js +16 -8
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,7 @@ import { RsbuildConfig } from '@rsbuild/core';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Convert rsbuild config to rstest config
|
|
7
|
-
*/
|
|
8
|
-
export declare function toRstestConfig({ configPath, environmentName, rsbuildConfig: rawRsbuildConfig, modifyRsbuildConfig, }: {
|
|
7
|
+
*/ export declare function toRstestConfig({ configPath, environmentName, rsbuildConfig: rawRsbuildConfig, modifyRsbuildConfig }: {
|
|
9
8
|
configPath?: string;
|
|
10
9
|
environmentName?: string;
|
|
11
10
|
rsbuildConfig: RsbuildConfig;
|
|
@@ -18,23 +17,19 @@ export declare interface WithRsbuildConfigOptions {
|
|
|
18
17
|
/**
|
|
19
18
|
* `cwd` passed to loadConfig of Rsbuild
|
|
20
19
|
* @default process.cwd()
|
|
21
|
-
*/
|
|
22
|
-
cwd?: string;
|
|
20
|
+
*/ cwd?: string;
|
|
23
21
|
/**
|
|
24
22
|
* Path to rsbuild config file
|
|
25
23
|
* @default './rsbuild.config.ts'
|
|
26
|
-
*/
|
|
27
|
-
configPath?: string;
|
|
24
|
+
*/ configPath?: string;
|
|
28
25
|
/**
|
|
29
26
|
* The environment name in `environments` field to use, will be merged with the common config.
|
|
30
27
|
* Set to a string to use the environment config with matching name.
|
|
31
28
|
* @default undefined
|
|
32
|
-
*/
|
|
33
|
-
environmentName?: string;
|
|
29
|
+
*/ environmentName?: string;
|
|
34
30
|
/**
|
|
35
31
|
* Modify rsbuild config before converting to rstest config
|
|
36
|
-
*/
|
|
37
|
-
modifyRsbuildConfig?: (buildConfig: RsbuildConfig) => RsbuildConfig;
|
|
32
|
+
*/ modifyRsbuildConfig?: (buildConfig: RsbuildConfig) => RsbuildConfig;
|
|
38
33
|
}
|
|
39
34
|
|
|
40
35
|
export { }
|
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.5",
|
|
4
4
|
"description": "Rstest adapter for rsbuild configuration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rstest",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/web-infra-dev/rstest",
|
|
16
|
+
"url": "git+https://github.com/web-infra-dev/rstest.git",
|
|
17
17
|
"directory": "packages/adapter-rsbuild"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
@@ -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.14",
|
|
34
|
+
"@rslib/core": "0.22.1",
|
|
35
|
+
"@rstest/core": "0.10.5",
|
|
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.5"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|