@rstest/adapter-rsbuild 0.2.5 → 0.10.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/README.md CHANGED
@@ -18,7 +18,7 @@ import { withRsbuildConfig } from '@rstest/adapter-rsbuild';
18
18
 
19
19
  export default defineConfig({
20
20
  extends: withRsbuildConfig(),
21
- // other rstest config options
21
+ // other Rstest config options
22
22
  });
23
23
  ```
24
24
 
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 || {};
8
- const { cssModules, target, module } = finalBuildConfig.output || {};
37
+ const { buildCache } = finalBuildConfig.performance || {};
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
  {
@@ -32,8 +65,16 @@ function toRstestConfig({ environmentName, rsbuildConfig: rawRsbuildConfig, modi
32
65
  resolve: finalBuildConfig.resolve,
33
66
  output: {
34
67
  cssModules,
68
+ emitAssets,
35
69
  module
36
70
  },
71
+ performance: {
72
+ buildCache: updateCacheConfig({
73
+ buildCache,
74
+ configPath,
75
+ root: finalBuildConfig.root
76
+ })
77
+ },
37
78
  tools: {
38
79
  rspack,
39
80
  swc,
@@ -41,6 +82,7 @@ function toRstestConfig({ environmentName, rsbuildConfig: rawRsbuildConfig, modi
41
82
  },
42
83
  testEnvironment: 'node' === target ? 'node' : 'happy-dom'
43
84
  };
85
+ return rstestConfig;
44
86
  }
45
87
  function withRsbuildConfig(options = {}) {
46
88
  return async ()=>{
@@ -53,6 +95,7 @@ function withRsbuildConfig(options = {}) {
53
95
  const rstestConfig = toRstestConfig({
54
96
  environmentName,
55
97
  rsbuildConfig,
98
+ configPath: filePath,
56
99
  modifyRsbuildConfig
57
100
  });
58
101
  return rstestConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstest/adapter-rsbuild",
3
- "version": "0.2.5",
3
+ "version": "0.10.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.0-rc.0",
34
- "@rslib/core": "0.20.2",
35
- "@rstest/core": "0.9.6",
33
+ "@rsbuild/core": "^2.0.6",
34
+ "@rslib/core": "0.21.4",
35
+ "@rstest/core": "0.10.0",
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.0"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"