@rspack-canary/test-tools 1.5.9-canary-b4bf7a8b-20251011023631 → 1.5.9-canary-bddc650e-20251012024608

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.
@@ -98,8 +98,7 @@ function defaultOptions(context, temp, target) {
98
98
  force: false
99
99
  }
100
100
  },
101
- inlineConst: true,
102
- lazyBarrel: true
101
+ inlineConst: true
103
102
  }
104
103
  };
105
104
  options.plugins ??= [];
@@ -77,8 +77,7 @@ function defaultOptions(index, context) {
77
77
  force: false
78
78
  }
79
79
  },
80
- inlineConst: true,
81
- lazyBarrel: true
80
+ inlineConst: true
82
81
  }
83
82
  };
84
83
  }
@@ -84,8 +84,7 @@ function defaultOptions(context) {
84
84
  force: false
85
85
  }
86
86
  },
87
- inlineConst: true,
88
- lazyBarrel: true
87
+ inlineConst: true
89
88
  }
90
89
  };
91
90
  }
@@ -8,6 +8,7 @@ declare class RspackStatsDiagnostics {
8
8
  }
9
9
  export type TErrorCaseConfig = {
10
10
  description: string;
11
+ skip?: boolean;
11
12
  options?: (context: ITestContext) => TCompilerOptions<ECompilerType.Rspack>;
12
13
  compiler?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
13
14
  build?: (context: ITestContext, compiler: TCompiler<ECompilerType.Rspack>) => Promise<void>;
@@ -49,11 +49,25 @@ function createErrorCase(name, src, dist, testConfig) {
49
49
  if (!addedSerializer) {
50
50
  addedSerializer = true;
51
51
  }
52
- const caseConfig = require(testConfig);
53
- creator.create(name, src, dist, undefined, {
54
- caseConfig,
55
- description: () => caseConfig.description
56
- });
52
+ const caseConfigList = require(testConfig);
53
+ function createCase(caseConfig) {
54
+ if (caseConfig.skip) {
55
+ it.skip(name, () => { });
56
+ return;
57
+ }
58
+ creator.create(name, src, dist, undefined, {
59
+ caseConfig,
60
+ description: () => caseConfig.description
61
+ });
62
+ }
63
+ if (Array.isArray(caseConfigList)) {
64
+ for (const caseConfig of caseConfigList) {
65
+ createCase(caseConfig);
66
+ }
67
+ }
68
+ else {
69
+ createCase(caseConfigList);
70
+ }
57
71
  }
58
72
  function options(context, custom) {
59
73
  let options = {
@@ -116,6 +130,11 @@ class RspackStatsDiagnostics {
116
130
  }
117
131
  }
118
132
  async function check(env, context, name, check) {
133
+ if (context.getError(name).length > 0) {
134
+ await check?.(new RspackStatsDiagnostics(context.getError(name), []));
135
+ context.clearError(name);
136
+ return;
137
+ }
119
138
  const compiler = (0, common_1.getCompiler)(context, name);
120
139
  const stats = compiler.getStats();
121
140
  env.expect(typeof stats).toBe("object");
package/dist/case/hash.js CHANGED
@@ -53,8 +53,7 @@ function defaultOptions(index, context) {
53
53
  force: false
54
54
  }
55
55
  },
56
- inlineConst: true,
57
- lazyBarrel: true
56
+ inlineConst: true
58
57
  }
59
58
  };
60
59
  }
package/dist/case/hook.js CHANGED
@@ -213,8 +213,7 @@ function defaultOptions(context, custom) {
213
213
  force: false
214
214
  }
215
215
  },
216
- inlineConst: true,
217
- lazyBarrel: true
216
+ inlineConst: true
218
217
  }
219
218
  };
220
219
  if (custom) {
package/dist/case/hot.js CHANGED
@@ -108,8 +108,7 @@ function defaultOptions(context, target, updateOptions) {
108
108
  force: false
109
109
  }
110
110
  },
111
- inlineConst: true,
112
- lazyBarrel: true
111
+ inlineConst: true
113
112
  }
114
113
  };
115
114
  options.plugins ??= [];
@@ -23,7 +23,7 @@ export { createHotIncrementalCase, createWatchIncrementalCase } from "./incremen
23
23
  export type { TMultiCompilerCaseConfig } from "./multi-compiler";
24
24
  export { createMultiCompilerCase } from "./multi-compiler";
25
25
  export { createNativeWatcher } from "./native-watcher";
26
- export { createHotNormalCase, createNormalCase } from "./normal";
26
+ export { createDevNormalCase, createHotNormalCase, createNormalCase, createProdNormalCase } from "./normal";
27
27
  export { createSerialCase } from "./serial";
28
28
  export type { TStatsAPICaseConfig } from "./stats-api";
29
29
  export { createStatsAPICase } from "./stats-api";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createWatchCase = exports.createTreeShakingCase = exports.createStatsOutputCase = exports.createStatsAPICase = exports.createSerialCase = exports.createNormalCase = exports.createHotNormalCase = exports.createNativeWatcher = exports.createMultiCompilerCase = exports.createWatchIncrementalCase = exports.createHotIncrementalCase = exports.createHotStepCase = exports.createHotCase = exports.createHookCase = exports.createHashCase = exports.createExampleCase = exports.createEsmOutputCase = exports.createErrorCase = exports.createDiffCase = exports.createDiagnosticCase = exports.getRspackDefaultConfig = exports.createDefaultsCase = exports.createConfigCase = exports.createCompilerCase = exports.createCacheCase = exports.createBuiltinCase = void 0;
3
+ exports.createWatchCase = exports.createTreeShakingCase = exports.createStatsOutputCase = exports.createStatsAPICase = exports.createSerialCase = exports.createProdNormalCase = exports.createNormalCase = exports.createHotNormalCase = exports.createDevNormalCase = exports.createNativeWatcher = exports.createMultiCompilerCase = exports.createWatchIncrementalCase = exports.createHotIncrementalCase = exports.createHotStepCase = exports.createHotCase = exports.createHookCase = exports.createHashCase = exports.createExampleCase = exports.createEsmOutputCase = exports.createErrorCase = exports.createDiffCase = exports.createDiagnosticCase = exports.getRspackDefaultConfig = exports.createDefaultsCase = exports.createConfigCase = exports.createCompilerCase = exports.createCacheCase = exports.createBuiltinCase = void 0;
4
4
  var builtin_1 = require("./builtin");
5
5
  Object.defineProperty(exports, "createBuiltinCase", { enumerable: true, get: function () { return builtin_1.createBuiltinCase; } });
6
6
  var cache_1 = require("./cache");
@@ -38,8 +38,10 @@ Object.defineProperty(exports, "createMultiCompilerCase", { enumerable: true, ge
38
38
  var native_watcher_1 = require("./native-watcher");
39
39
  Object.defineProperty(exports, "createNativeWatcher", { enumerable: true, get: function () { return native_watcher_1.createNativeWatcher; } });
40
40
  var normal_1 = require("./normal");
41
+ Object.defineProperty(exports, "createDevNormalCase", { enumerable: true, get: function () { return normal_1.createDevNormalCase; } });
41
42
  Object.defineProperty(exports, "createHotNormalCase", { enumerable: true, get: function () { return normal_1.createHotNormalCase; } });
42
43
  Object.defineProperty(exports, "createNormalCase", { enumerable: true, get: function () { return normal_1.createNormalCase; } });
44
+ Object.defineProperty(exports, "createProdNormalCase", { enumerable: true, get: function () { return normal_1.createProdNormalCase; } });
43
45
  var serial_1 = require("./serial");
44
46
  Object.defineProperty(exports, "createSerialCase", { enumerable: true, get: function () { return serial_1.createSerialCase; } });
45
47
  var stats_api_1 = require("./stats-api");
@@ -1,2 +1,4 @@
1
1
  export declare function createNormalCase(name: string, src: string, dist: string): void;
2
2
  export declare function createHotNormalCase(name: string, src: string, dist: string): void;
3
+ export declare function createDevNormalCase(name: string, src: string, dist: string): void;
4
+ export declare function createProdNormalCase(name: string, src: string, dist: string): void;
@@ -5,6 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createNormalCase = createNormalCase;
7
7
  exports.createHotNormalCase = createHotNormalCase;
8
+ exports.createDevNormalCase = createDevNormalCase;
9
+ exports.createProdNormalCase = createProdNormalCase;
8
10
  const node_fs_1 = __importDefault(require("node:fs"));
9
11
  const node_path_1 = __importDefault(require("node:path"));
10
12
  const core_1 = require("@rspack/core");
@@ -12,7 +14,7 @@ const creator_1 = require("../test/creator");
12
14
  const common_1 = require("./common");
13
15
  const runner_1 = require("./runner");
14
16
  const NORMAL_CASES_ROOT = node_path_1.default.resolve(__dirname, "../../../../tests/rspack-test/normalCases");
15
- const createCaseOptions = (hot) => {
17
+ const createCaseOptions = (hot, mode) => {
16
18
  return {
17
19
  clean: true,
18
20
  describe: false,
@@ -22,7 +24,7 @@ const createCaseOptions = (hot) => {
22
24
  const compiler = (0, common_1.getCompiler)(context, name);
23
25
  let options = defaultOptions(context, {
24
26
  plugins: hot ? [new core_1.HotModuleReplacementPlugin()] : []
25
- });
27
+ }, mode);
26
28
  options = await (0, common_1.config)(context, name, ["rspack.config.js", "webpack.config.js"], options);
27
29
  overrideOptions(context, options);
28
30
  compiler.setOptions(options);
@@ -56,6 +58,14 @@ const hotCreator = new creator_1.BasicCaseCreator(createCaseOptions(true));
56
58
  function createHotNormalCase(name, src, dist) {
57
59
  hotCreator.create(name, src, dist);
58
60
  }
61
+ const devCreator = new creator_1.BasicCaseCreator(createCaseOptions(false, "development"));
62
+ function createDevNormalCase(name, src, dist) {
63
+ devCreator.create(name, src, dist);
64
+ }
65
+ const prodCreator = new creator_1.BasicCaseCreator(createCaseOptions(false, "production"));
66
+ function createProdNormalCase(name, src, dist) {
67
+ prodCreator.create(name, src, dist);
68
+ }
59
69
  function findBundle(context, options) {
60
70
  const testConfig = context.getTestConfig();
61
71
  if (typeof testConfig.findBundle === "function") {
@@ -64,7 +74,7 @@ function findBundle(context, options) {
64
74
  const filename = options.output?.filename;
65
75
  return typeof filename === "string" ? filename : undefined;
66
76
  }
67
- function defaultOptions(context, compilerOptions) {
77
+ function defaultOptions(context, compilerOptions, mode) {
68
78
  let testConfig = {};
69
79
  const testConfigPath = node_path_1.default.join(context.getSource(), "test.config.js");
70
80
  if (node_fs_1.default.existsSync(testConfigPath)) {
@@ -80,11 +90,12 @@ function defaultOptions(context, compilerOptions) {
80
90
  entry: `./${node_path_1.default.relative(NORMAL_CASES_ROOT, context.getSource())}/`,
81
91
  target: compilerOptions?.target || "async-node",
82
92
  devtool: compilerOptions?.devtool,
83
- mode: compilerOptions?.mode || "none",
93
+ mode: compilerOptions?.mode || mode || "none",
84
94
  optimization: compilerOptions?.mode
85
95
  ? {
86
- // emitOnErrors: true,
96
+ emitOnErrors: true,
87
97
  minimizer: [terserForTesting],
98
+ minimize: false,
88
99
  ...testConfig.optimization
89
100
  }
90
101
  : {
@@ -98,7 +109,7 @@ function defaultOptions(context, compilerOptions) {
98
109
  usedExports: true,
99
110
  mangleExports: true,
100
111
  // CHANGE: rspack does not support `emitOnErrors` yet.
101
- // emitOnErrors: true,
112
+ emitOnErrors: true,
102
113
  concatenateModules: !!testConfig?.optimization?.concatenateModules,
103
114
  innerGraph: true,
104
115
  // CHANGE: size is not supported yet
@@ -106,6 +117,7 @@ function defaultOptions(context, compilerOptions) {
106
117
  // chunkIds: "size",
107
118
  moduleIds: "named",
108
119
  chunkIds: "named",
120
+ minimize: false,
109
121
  minimizer: [terserForTesting],
110
122
  ...compilerOptions?.optimization
111
123
  },
@@ -181,7 +193,6 @@ function defaultOptions(context, compilerOptions) {
181
193
  asyncWebAssembly: true,
182
194
  topLevelAwait: true,
183
195
  inlineConst: true,
184
- lazyBarrel: true,
185
196
  // CHANGE: rspack does not support `backCompat` yet.
186
197
  // backCompat: false,
187
198
  // CHANGE: Rspack enables `css` by default.
@@ -84,8 +84,7 @@ function defaultOptions(index, context) {
84
84
  force: false
85
85
  }
86
86
  },
87
- inlineConst: true,
88
- lazyBarrel: true
87
+ inlineConst: true
89
88
  }
90
89
  };
91
90
  }
@@ -31,7 +31,7 @@ function describeByWalk(testFile, createCase, options = {}) {
31
31
  .filter(folder => {
32
32
  if (options.exclude) {
33
33
  if (options.exclude.some(exclude => {
34
- return exclude.test(folder);
34
+ return exclude.test(node_path_1.default.join(dirname, folder).replace(/\\/g, "/"));
35
35
  })) {
36
36
  return false;
37
37
  }
@@ -19,7 +19,7 @@ const prettyFormatOptions = {
19
19
  return `"${val
20
20
  .replace(/\\/gm, "/")
21
21
  .replace(/"/gm, '\\"')
22
- .replace(/\r?\n/gm, "\\n")}"`;
22
+ .replace(/\r?\n/gm, "")}"`;
23
23
  }
24
24
  }
25
25
  ]
@@ -71,7 +71,12 @@ class HotUpdatePlugin {
71
71
  return;
72
72
  }
73
73
  this.initialized = true;
74
- await promises_1.default.rmdir(this.tempDir, { recursive: true });
74
+ try {
75
+ await promises_1.default.rmdir(this.tempDir, { recursive: true });
76
+ }
77
+ catch (_e) {
78
+ // empty
79
+ }
75
80
  await promises_1.default.cp(this.projectDir, this.tempDir, { recursive: true });
76
81
  await loopFile(this.tempDir, (filePath, content) => {
77
82
  const contents = content.split(/---+\r?\n/g);
@@ -255,7 +255,6 @@ class BasicCaseCreator {
255
255
  clean(folders) {
256
256
  for (const f of folders) {
257
257
  (0, rimraf_1.rimrafSync)(f);
258
- node_fs_1.default.mkdirSync(f, { recursive: true });
259
258
  }
260
259
  }
261
260
  skip(name, reason) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack-canary/test-tools",
3
- "version": "1.5.9-canary-b4bf7a8b-20251011023631",
3
+ "version": "1.5.9-canary-bddc650e-20251012024608",
4
4
  "license": "MIT",
5
5
  "description": "Test tools for rspack",
6
6
  "main": "dist/index.js",
@@ -100,10 +100,10 @@
100
100
  "wast-loader": "^1.14.1",
101
101
  "worker-rspack-loader": "^3.1.2",
102
102
  "exports-loader": "^5.0.0",
103
- "@rspack/cli": "npm:@rspack-canary/cli@1.5.9-canary-b4bf7a8b-20251011023631",
104
- "@rspack/core": "npm:@rspack-canary/core@1.5.9-canary-b4bf7a8b-20251011023631",
105
- "@rspack/test-tools": "npm:@rspack-canary/test-tools@1.5.9-canary-b4bf7a8b-20251011023631",
106
- "@rspack/binding-testing": "1.4.1"
103
+ "@rspack/cli": "npm:@rspack-canary/cli@1.5.9-canary-bddc650e-20251012024608",
104
+ "@rspack/binding-testing": "1.4.1",
105
+ "@rspack/core": "npm:@rspack-canary/core@1.5.9-canary-bddc650e-20251012024608",
106
+ "@rspack/test-tools": "npm:@rspack-canary/test-tools@1.5.9-canary-bddc650e-20251012024608"
107
107
  },
108
108
  "peerDependencies": {
109
109
  "@rspack/core": ">=1.0.0"