@rstest/adapter-rsbuild 0.2.6 → 0.10.1

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
@@ -5,7 +5,8 @@ import { RsbuildConfig } from '@rsbuild/core';
5
5
  /**
6
6
  * Convert rsbuild config to rstest config
7
7
  */
8
- export declare function toRstestConfig({ environmentName, rsbuildConfig: rawRsbuildConfig, modifyRsbuildConfig }: {
8
+ export declare function toRstestConfig({ configPath, environmentName, rsbuildConfig: rawRsbuildConfig, modifyRsbuildConfig, }: {
9
+ configPath?: string;
9
10
  environmentName?: string;
10
11
  rsbuildConfig: RsbuildConfig;
11
12
  modifyRsbuildConfig?: (buildConfig: RsbuildConfig) => RsbuildConfig;
package/dist/index.js CHANGED
@@ -1,15 +1,48 @@
1
1
  import { loadConfig, mergeRsbuildConfig } from "@rsbuild/core";
2
- function toRstestConfig({ environmentName, rsbuildConfig: rawRsbuildConfig, modifyRsbuildConfig }) {
2
+ import { dirname, isAbsolute, join, normalize } from "node:path";
3
+ const getCacheDependency = ({ dependency, configPath, root })=>{
4
+ if (isAbsolute(dependency)) return normalize(dependency);
5
+ if (configPath) return normalize(join(dirname(configPath), dependency));
6
+ return root ? normalize(join(root, dependency)) : dependency;
7
+ };
8
+ const updateCacheConfig = ({ buildCache, configPath, root })=>{
9
+ if (void 0 === buildCache) return;
10
+ if (false === buildCache) return false;
11
+ if (true === buildCache) return configPath ? {
12
+ buildDependencies: [
13
+ normalize(configPath)
14
+ ]
15
+ } : true;
16
+ const buildDependencies = buildCache.buildDependencies?.map((dependency)=>getCacheDependency({
17
+ dependency,
18
+ configPath,
19
+ root
20
+ }));
21
+ const nextBuildDependencies = configPath ? Array.from(new Set([
22
+ ...buildDependencies || [],
23
+ normalize(configPath)
24
+ ])) : buildDependencies;
25
+ return {
26
+ cacheDirectory: buildCache.cacheDirectory,
27
+ cacheDigest: buildCache.cacheDigest,
28
+ buildDependencies: nextBuildDependencies
29
+ };
30
+ };
31
+ function toRstestConfig({ configPath, environmentName, rsbuildConfig: rawRsbuildConfig, modifyRsbuildConfig }) {
3
32
  const { environments, ...rawBuildConfig } = rawRsbuildConfig;
4
33
  const environmentConfig = environmentName ? environments?.[environmentName] : void 0;
5
34
  const rsbuildConfig = environmentConfig ? mergeRsbuildConfig(rawBuildConfig, environmentConfig) : rawBuildConfig;
6
35
  const finalBuildConfig = modifyRsbuildConfig ? modifyRsbuildConfig(rsbuildConfig) : rsbuildConfig;
7
36
  const { rspack, swc, bundlerChain } = finalBuildConfig.tools || {};
37
+ const { buildCache } = finalBuildConfig.performance || {};
8
38
  const { cssModules, emitAssets, target, module } = finalBuildConfig.output || {};
9
39
  const { assetsInclude, decorators, define, include, exclude, tsconfigPath, transformImport } = finalBuildConfig.source || {};
10
- return {
40
+ const rstestConfig = {
11
41
  root: finalBuildConfig.root,
12
42
  name: environmentName,
43
+ forceRerunTriggers: configPath ? [
44
+ normalize(configPath)
45
+ ] : void 0,
13
46
  plugins: [
14
47
  ...finalBuildConfig.plugins || [],
15
48
  {
@@ -35,6 +68,13 @@ function toRstestConfig({ environmentName, rsbuildConfig: rawRsbuildConfig, modi
35
68
  emitAssets,
36
69
  module
37
70
  },
71
+ performance: {
72
+ buildCache: updateCacheConfig({
73
+ buildCache,
74
+ configPath,
75
+ root: finalBuildConfig.root
76
+ })
77
+ },
38
78
  tools: {
39
79
  rspack,
40
80
  swc,
@@ -42,6 +82,7 @@ function toRstestConfig({ environmentName, rsbuildConfig: rawRsbuildConfig, modi
42
82
  },
43
83
  testEnvironment: 'node' === target ? 'node' : 'happy-dom'
44
84
  };
85
+ return rstestConfig;
45
86
  }
46
87
  function withRsbuildConfig(options = {}) {
47
88
  return async ()=>{
@@ -54,6 +95,7 @@ function withRsbuildConfig(options = {}) {
54
95
  const rstestConfig = toRstestConfig({
55
96
  environmentName,
56
97
  rsbuildConfig,
98
+ configPath: filePath,
57
99
  modifyRsbuildConfig
58
100
  });
59
101
  return rstestConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstest/adapter-rsbuild",
3
- "version": "0.2.6",
3
+ "version": "0.10.1",
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.0-rc.1",
34
- "@rslib/core": "0.21.0",
35
- "@rstest/core": "0.9.7",
33
+ "@rsbuild/core": "^2.0.6",
34
+ "@rslib/core": "0.21.5",
35
+ "@rstest/core": "0.10.1",
36
36
  "@rstest/tsconfig": "0.0.1"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@rsbuild/core": "*",
40
- "@rstest/core": ">=0.7.7"
40
+ "@rstest/core": "^0.10.1"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"