@rspack-canary/test-tools 1.6.0-canary-e28e40e9-20251022173516 → 1.6.0-canary-941e2203-20251024173714

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.
@@ -23,7 +23,7 @@ const creator = new creator_1.BasicCaseCreator({
23
23
  return [
24
24
  {
25
25
  config: async (context) => {
26
- const compiler = (0, common_1.getCompiler)(context, name);
26
+ const compiler = context.getCompiler();
27
27
  compiler.setOptions(defaultOptions(context));
28
28
  },
29
29
  compiler: async (context) => {
@@ -19,10 +19,10 @@ function createCacheProcessor(name, src, temp, target) {
19
19
  return {
20
20
  before: async (context) => {
21
21
  await updatePlugin.initialize();
22
- context.setValue(name, "hotUpdateContext", updatePlugin);
22
+ context.setValue("hotUpdateContext", updatePlugin);
23
23
  },
24
24
  config: async (context) => {
25
- const compiler = (0, common_1.getCompiler)(context, name);
25
+ const compiler = context.getCompiler();
26
26
  let options = defaultOptions(context, temp, target);
27
27
  options = await (0, common_1.config)(context, name, ["rspack.config.js", "webpack.config.js"].map(i => node_path_1.default.resolve(temp, i)), options);
28
28
  overrideOptions(options, temp, target, updatePlugin);
@@ -131,7 +131,7 @@ function overrideOptions(options, temp, target, updatePlugin) {
131
131
  function findBundle(name, target, context) {
132
132
  const files = [];
133
133
  const prefiles = [];
134
- const compiler = (0, common_1.getCompiler)(context, name);
134
+ const compiler = context.getCompiler();
135
135
  if (!compiler)
136
136
  throw new Error("Compiler should exists when find bundle");
137
137
  const stats = compiler.getStats();
@@ -158,13 +158,13 @@ function findBundle(name, target, context) {
158
158
  return [...prefiles, ...files];
159
159
  }
160
160
  function createRunner(context, name, file, env) {
161
- const compiler = context.getCompiler(name);
161
+ const compiler = context.getCompiler();
162
162
  const options = compiler.getOptions();
163
163
  let compilerIndex = 0;
164
164
  const testConfig = context.getTestConfig();
165
165
  const source = context.getSource();
166
166
  const dist = context.getDist();
167
- const updatePlugin = context.getValue(name, "hotUpdateContext");
167
+ const updatePlugin = context.getValue("hotUpdateContext");
168
168
  const getWebRunner = () => {
169
169
  return new runner_1.NodeRunner({
170
170
  env,
@@ -1,6 +1,5 @@
1
1
  import type { Compiler, RspackOptions } from "@rspack/core";
2
- import type { ITestCompilerManager, ITestContext, ITestEnv } from "../type";
3
- export declare function getCompiler(context: ITestContext, name: string): ITestCompilerManager;
2
+ import type { ITestContext, ITestEnv } from "../type";
4
3
  export declare function config(context: ITestContext, name: string, configFiles: string[], defaultOptions?: RspackOptions): Promise<RspackOptions>;
5
4
  export declare function compiler(context: ITestContext, name: string): Promise<Compiler>;
6
5
  export declare function build(context: ITestContext, name: string): Promise<Compiler>;
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getCompiler = getCompiler;
7
6
  exports.config = config;
8
7
  exports.compiler = compiler;
9
8
  exports.build = build;
@@ -19,11 +18,9 @@ const webpack_merge_1 = __importDefault(require("webpack-merge"));
19
18
  const helper_1 = require("../helper");
20
19
  const placeholder_1 = require("../helper/expect/placeholder");
21
20
  const checkArrayExpectation_1 = __importDefault(require("../helper/legacy/checkArrayExpectation"));
22
- function getCompiler(context, name) {
23
- return context.getCompiler(name);
24
- }
21
+ const debug_1 = require("../test/debug");
25
22
  async function config(context, name, configFiles, defaultOptions = {}) {
26
- const compiler = getCompiler(context, name);
23
+ const compiler = context.getCompiler();
27
24
  compiler.setOptions(defaultOptions);
28
25
  if (Array.isArray(configFiles)) {
29
26
  const fileOptions = (0, helper_1.readConfigFile)(configFiles.map(i => context.getSource(i)), context, defaultOptions)[0];
@@ -32,12 +29,12 @@ async function config(context, name, configFiles, defaultOptions = {}) {
32
29
  return compiler.getOptions();
33
30
  }
34
31
  async function compiler(context, name) {
35
- const compiler = getCompiler(context, name);
32
+ const compiler = context.getCompiler();
36
33
  compiler.createCompiler();
37
34
  return compiler.getCompiler();
38
35
  }
39
36
  async function build(context, name) {
40
- const compiler = getCompiler(context, name);
37
+ const compiler = context.getCompiler();
41
38
  await compiler.build();
42
39
  return compiler.getCompiler();
43
40
  }
@@ -45,15 +42,12 @@ async function run(env, context, name, findBundle) {
45
42
  const testConfig = context.getTestConfig();
46
43
  if (testConfig.noTests)
47
44
  return;
48
- const compiler = getCompiler(context, name);
45
+ const compiler = context.getCompiler();
49
46
  if (typeof testConfig.beforeExecute === "function") {
50
47
  testConfig.beforeExecute(compiler.getOptions());
51
48
  }
52
49
  let bundles;
53
- if (testConfig.bundlePath) {
54
- bundles = testConfig.bundlePath;
55
- }
56
- else if (typeof findBundle === "function") {
50
+ if (typeof findBundle === "function") {
57
51
  bundles = findBundle(context, compiler.getOptions());
58
52
  }
59
53
  else {
@@ -62,28 +56,39 @@ async function run(env, context, name, findBundle) {
62
56
  if (typeof bundles === "string") {
63
57
  bundles = [bundles];
64
58
  }
59
+ if (__DEBUG__) {
60
+ context.setValue(debug_1.DEBUG_SCOPES.RunFindBundle, bundles);
61
+ }
65
62
  if (!bundles || !bundles.length) {
66
63
  return;
67
64
  }
65
+ if (__DEBUG__) {
66
+ context.setValue(debug_1.DEBUG_SCOPES.RunLogs, []);
67
+ context.setValue(debug_1.DEBUG_SCOPES.RunErrors, []);
68
+ }
68
69
  for (const bundle of bundles) {
69
70
  if (!bundle) {
70
71
  continue;
71
72
  }
72
- const runner = context.getRunner(name, bundle, env);
73
+ const runner = context.getRunner(bundle, env);
74
+ if (__DEBUG__) {
75
+ const runLogs = context.getValue(debug_1.DEBUG_SCOPES.RunLogs);
76
+ runLogs?.push(`Start running entry: ${bundle} in ${runner.constructor.name}(${runner.__key__})`);
77
+ }
73
78
  const mod = runner.run(bundle);
74
- const result = context.getValue(name, "modules") || [];
79
+ const result = context.getValue("modules") || [];
75
80
  result.push(mod);
76
- context.setValue(name, "modules", result);
81
+ context.setValue("modules", result);
77
82
  }
78
- const results = context.getValue(name, "modules") || [];
83
+ const results = context.getValue("modules") || [];
79
84
  await Promise.all(results);
80
85
  }
81
86
  async function check(env, context, name) {
82
87
  const testConfig = context.getTestConfig();
83
88
  if (testConfig.noTests)
84
89
  return;
85
- const compiler = getCompiler(context, name);
86
- const errors = (context.getError(name) || []).map(e => ({
90
+ const compiler = context.getCompiler();
91
+ const errors = (context.getError() || []).map(e => ({
87
92
  message: e.message,
88
93
  stack: e.stack
89
94
  }));
@@ -122,14 +127,14 @@ async function check(env, context, name) {
122
127
  await (0, checkArrayExpectation_1.default)(context.getSource(), { warnings }, "warning", "warnings", "Warning", options);
123
128
  // clear error if checked
124
129
  if (fs_extra_1.default.existsSync(context.getSource("errors.js"))) {
125
- context.clearError(name);
130
+ context.clearError();
126
131
  }
127
132
  }
128
133
  async function checkSnapshot(env, context, name, snapshot, filter) {
129
134
  if (path_1.default.extname(snapshot) === ".snap") {
130
135
  throw new Error("Snapshot with `.snap` will be managed by jest, please use `.snap.txt` instead");
131
136
  }
132
- const compilerManager = getCompiler(context, name);
137
+ const compilerManager = context.getCompiler();
133
138
  const stats = compilerManager.getStats();
134
139
  const compiler = compilerManager.getCompiler();
135
140
  if (!stats || !compiler)
@@ -175,7 +180,7 @@ async function checkSnapshot(env, context, name, snapshot, filter) {
175
180
  }
176
181
  }
177
182
  async function afterExecute(context, name) {
178
- const compiler = getCompiler(context, name);
183
+ const compiler = context.getCompiler();
179
184
  const testConfig = context.getTestConfig();
180
185
  if (typeof testConfig.afterExecute === "function") {
181
186
  let options = compiler.getOptions();
@@ -189,9 +194,10 @@ function findMultiCompilerBundle(context, name, multiFindBundle) {
189
194
  if (typeof multiFindBundle !== "function") {
190
195
  return [];
191
196
  }
192
- const multiCompilerOptions = (context.getValue(name, "multiCompilerOptions") || []);
197
+ const multiCompilerOptions = (context.getValue("multiCompilerOptions") ||
198
+ []);
193
199
  const result = [];
194
- const multiFileIndexMap = context.getValue(name, "multiFileIndexMap") || {};
200
+ const multiFileIndexMap = context.getValue("multiFileIndexMap") || {};
195
201
  for (const [index, compilerOptions] of multiCompilerOptions.entries()) {
196
202
  const curBundles = multiFindBundle(index, context, compilerOptions);
197
203
  const bundles = Array.isArray(curBundles)
@@ -209,7 +215,7 @@ function findMultiCompilerBundle(context, name, multiFindBundle) {
209
215
  }
210
216
  result.push(...bundles);
211
217
  }
212
- context.setValue(name, "multiFileIndexMap", multiFileIndexMap);
218
+ context.setValue("multiFileIndexMap", multiFileIndexMap);
213
219
  return result;
214
220
  }
215
221
  function configMultiCompiler(context, name, configFiles, defaultOptions, overrideOptions) {
@@ -237,7 +243,7 @@ function configMultiCompiler(context, name, configFiles, defaultOptions, overrid
237
243
  }
238
244
  multiCompilerOptions.push(compilerOptions);
239
245
  }
240
- const compiler = getCompiler(context, name);
246
+ const compiler = context.getCompiler();
241
247
  compiler.setOptions(multiCompilerOptions);
242
- context.setValue(name, "multiCompilerOptions", multiCompilerOptions);
248
+ context.setValue("multiCompilerOptions", multiCompilerOptions);
243
249
  }
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createCompilerCase = createCompilerCase;
4
4
  const creator_1 = require("../test/creator");
5
- const common_1 = require("./common");
6
5
  function createCompilerProcessor(name, caseConfig) {
7
6
  const logs = {
8
7
  mkdir: [],
@@ -11,7 +10,7 @@ function createCompilerProcessor(name, caseConfig) {
11
10
  const files = {};
12
11
  return {
13
12
  config: async (context) => {
14
- const compiler = (0, common_1.getCompiler)(context, name);
13
+ const compiler = context.getCompiler();
15
14
  const options = caseConfig.options?.(context) || {};
16
15
  options.mode ??= "production";
17
16
  options.context ??= context.getSource();
@@ -24,7 +23,7 @@ function createCompilerProcessor(name, caseConfig) {
24
23
  compiler.setOptions(options);
25
24
  },
26
25
  compiler: async (context) => {
27
- const compiler = (0, common_1.getCompiler)(context, name);
26
+ const compiler = context.getCompiler();
28
27
  if (caseConfig.compilerCallback) {
29
28
  compiler.createCompilerWithCallback(caseConfig.compilerCallback);
30
29
  }
@@ -65,7 +64,7 @@ function createCompilerProcessor(name, caseConfig) {
65
64
  await caseConfig.compiler?.(context, c);
66
65
  },
67
66
  build: async (context) => {
68
- const compiler = (0, common_1.getCompiler)(context, name);
67
+ const compiler = context.getCompiler();
69
68
  if (typeof caseConfig.build === "function") {
70
69
  await caseConfig.build?.(context, compiler.getCompiler());
71
70
  }
@@ -75,7 +74,7 @@ function createCompilerProcessor(name, caseConfig) {
75
74
  },
76
75
  run: async (env, context) => { },
77
76
  check: async (env, context) => {
78
- const compiler = (0, common_1.getCompiler)(context, name);
77
+ const compiler = context.getCompiler();
79
78
  const c = compiler.getCompiler();
80
79
  const stats = compiler.getStats();
81
80
  if (caseConfig.error) {
@@ -124,7 +123,7 @@ function createCompilerProcessor(name, caseConfig) {
124
123
  }
125
124
  },
126
125
  after: async (context) => {
127
- await context.closeCompiler(name);
126
+ await context.closeCompiler();
128
127
  }
129
128
  };
130
129
  }
@@ -9,18 +9,17 @@ const node_path_1 = __importDefault(require("node:path"));
9
9
  const node_util_1 = require("node:util");
10
10
  const jest_diff_1 = require("jest-diff");
11
11
  const context_1 = require("../test/context");
12
- const common_1 = require("./common");
13
12
  const CURRENT_CWD = process.cwd();
14
13
  function createDefaultsCase(name, src) {
15
14
  const caseConfig = require(src);
16
15
  it(`should generate the correct defaults from ${caseConfig.description}`, async () => {
17
16
  await run(name, {
18
17
  config: async (context) => {
19
- const compiler = (0, common_1.getCompiler)(context, name);
18
+ const compiler = context.getCompiler();
20
19
  compiler.setOptions(options(context, caseConfig.options));
21
20
  },
22
21
  compiler: async (context) => {
23
- const compiler = (0, common_1.getCompiler)(context, name);
22
+ const compiler = context.getCompiler();
24
23
  compiler.createCompiler();
25
24
  },
26
25
  build: async (context) => {
@@ -48,10 +47,6 @@ function getRspackDefaultConfig(cwd, config) {
48
47
  }
49
48
  const srcDir = node_path_1.default.resolve(__dirname, "../../tests/fixtures");
50
49
  const distDir = node_path_1.default.resolve(__dirname, "../../tests/js/defaults");
51
- const context = new context_1.TestContext({
52
- src: srcDir,
53
- dist: distDir
54
- });
55
50
  function options(context, custom) {
56
51
  let res;
57
52
  if (typeof custom === "function") {
@@ -71,7 +66,7 @@ class RspackTestDiff {
71
66
  }
72
67
  }
73
68
  async function check(env, context, name, options) {
74
- const compiler = (0, common_1.getCompiler)(context, name);
69
+ const compiler = context.getCompiler();
75
70
  const config = getRspackDefaultConfig(options.cwd || CURRENT_CWD, compiler.getOptions());
76
71
  const defaultConfig = getRspackDefaultConfig(options.cwd || CURRENT_CWD, {
77
72
  mode: "none"
@@ -80,12 +75,17 @@ async function check(env, context, name, options) {
80
75
  await options.diff(env.expect(new RspackTestDiff(diff)), env.expect(defaultConfig));
81
76
  }
82
77
  async function run(name, processor) {
78
+ const context = new context_1.TestContext({
79
+ name: name,
80
+ src: srcDir,
81
+ dist: distDir
82
+ });
83
83
  try {
84
84
  await processor.before?.(context);
85
85
  await processor.config?.(context);
86
86
  }
87
87
  catch (e) {
88
- context.emitError(name, e);
88
+ context.emitError(e);
89
89
  }
90
90
  finally {
91
91
  await processor.check?.({ expect, it, beforeEach, afterEach, jest: global.jest || global.rstest }, context);
@@ -10,14 +10,13 @@ const webpack_merge_1 = __importDefault(require("webpack-merge"));
10
10
  const helper_1 = require("../helper");
11
11
  const placeholder_1 = require("../helper/expect/placeholder");
12
12
  const creator_1 = require("../test/creator");
13
- const common_1 = require("./common");
14
13
  const creator = new creator_1.BasicCaseCreator({
15
14
  clean: true,
16
15
  describe: false,
17
16
  steps: ({ name }) => [
18
17
  {
19
18
  config: async (context) => {
20
- const compiler = (0, common_1.getCompiler)(context, name);
19
+ const compiler = context.getCompiler();
21
20
  let options = defaultOptions(context);
22
21
  const custom = (0, helper_1.readConfigFile)(["rspack.config.js", "webpack.config.js"].map(i => context.getSource(i)), context, options)[0];
23
22
  if (custom) {
@@ -31,11 +30,11 @@ const creator = new creator_1.BasicCaseCreator({
31
30
  compiler.setOptions(options);
32
31
  },
33
32
  compiler: async (context) => {
34
- const compiler = (0, common_1.getCompiler)(context, name);
33
+ const compiler = context.getCompiler();
35
34
  compiler.createCompiler();
36
35
  },
37
36
  build: async (context) => {
38
- const compiler = (0, common_1.getCompiler)(context, name);
37
+ const compiler = context.getCompiler();
39
38
  await compiler.build();
40
39
  },
41
40
  run: async (env, context) => {
@@ -89,7 +88,7 @@ function defaultOptions(context) {
89
88
  };
90
89
  }
91
90
  async function check(env, context, name, options) {
92
- const compiler = (0, common_1.getCompiler)(context, name);
91
+ const compiler = context.getCompiler();
93
92
  const stats = compiler.getStats();
94
93
  if (!stats) {
95
94
  throw new Error("Stats should exists");
@@ -7,7 +7,6 @@ exports.createErrorCase = createErrorCase;
7
7
  const node_path_1 = __importDefault(require("node:path"));
8
8
  const webpack_merge_1 = __importDefault(require("webpack-merge"));
9
9
  const creator_1 = require("../test/creator");
10
- const common_1 = require("./common");
11
10
  let addedSerializer = false;
12
11
  const creator = new creator_1.BasicCaseCreator({
13
12
  clean: true,
@@ -17,16 +16,16 @@ const creator = new creator_1.BasicCaseCreator({
17
16
  return [
18
17
  {
19
18
  config: async (context) => {
20
- const compiler = (0, common_1.getCompiler)(context, name);
19
+ const compiler = context.getCompiler();
21
20
  compiler.setOptions(options(context, config.options));
22
21
  },
23
22
  compiler: async (context) => {
24
- const compilerManager = (0, common_1.getCompiler)(context, name);
23
+ const compilerManager = context.getCompiler();
25
24
  compilerManager.createCompiler();
26
25
  compiler(context, compilerManager.getCompiler(), config.compiler);
27
26
  },
28
27
  build: async (context) => {
29
- const compiler = (0, common_1.getCompiler)(context, name);
28
+ const compiler = context.getCompiler();
30
29
  if (typeof config.build === "function") {
31
30
  await config.build(context, compiler.getCompiler());
32
31
  }
@@ -130,12 +129,12 @@ class RspackStatsDiagnostics {
130
129
  }
131
130
  }
132
131
  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);
132
+ if (context.getError().length > 0) {
133
+ await check?.(new RspackStatsDiagnostics(context.getError(), []));
134
+ context.clearError();
136
135
  return;
137
136
  }
138
- const compiler = (0, common_1.getCompiler)(context, name);
137
+ const compiler = context.getCompiler();
139
138
  const stats = compiler.getStats();
140
139
  env.expect(typeof stats).toBe("object");
141
140
  const statsResult = stats.toJson({ errorDetails: false });
@@ -33,14 +33,14 @@ function createExampleProcessor(name) {
33
33
  // no need to run, just check the building
34
34
  },
35
35
  check: async (env, context) => {
36
- const compiler = (0, common_1.getCompiler)(context, name);
36
+ const compiler = context.getCompiler();
37
37
  const stats = compiler.getStats();
38
38
  if (stats?.hasErrors()) {
39
39
  console.log(stats.toString({
40
40
  all: false,
41
41
  errors: true,
42
42
  errorDetails: true,
43
- errorStacks: true
43
+ errorStack: true
44
44
  }));
45
45
  }
46
46
  expect(stats?.hasErrors()).toBe(false);
package/dist/case/hash.js CHANGED
@@ -68,7 +68,7 @@ function overrideOptions(index, context, options) {
68
68
  }
69
69
  }
70
70
  async function check(env, context, name) {
71
- const compiler = (0, common_1.getCompiler)(context, name);
71
+ const compiler = context.getCompiler();
72
72
  const stats = compiler.getStats();
73
73
  const testConfig = context.getTestConfig();
74
74
  if (!stats) {
package/dist/case/hook.js CHANGED
@@ -25,7 +25,7 @@ const creator = new creator_1.BasicCaseCreator({
25
25
  return [
26
26
  {
27
27
  config: async (context) => {
28
- const compiler = (0, common_1.getCompiler)(context, name);
28
+ const compiler = context.getCompiler();
29
29
  const options = await (0, common_1.config)(context, name, ["rspack.config.js", "webpack.config.js"], defaultOptions(context, caseConfig.options));
30
30
  if (!global.printLogger) {
31
31
  options.infrastructureLogging = {
@@ -61,7 +61,8 @@ function createHookCase(name, src, dist, source) {
61
61
  description: () => caseConfig.description,
62
62
  createContext: (config) => new HookCasesContext(src, testName, {
63
63
  src: source,
64
- dist: dist
64
+ dist: dist,
65
+ name: name
65
66
  })
66
67
  });
67
68
  }
@@ -9,7 +9,6 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const helper_1 = require("../helper");
10
10
  const placeholder_1 = require("../helper/expect/placeholder");
11
11
  const creator_1 = require("../test/creator");
12
- const common_1 = require("./common");
13
12
  const hot_1 = require("./hot");
14
13
  const NOOP_SET = new Set();
15
14
  const escapeLocalName = (str) => str.split(/[-<>:"/|?*.]/).join("_");
@@ -243,7 +242,7 @@ ${runtime.javascript.disposedModules.map(i => `- ${i}`).join("\n")}
243
242
  }
244
243
  const originRun = processor.run;
245
244
  processor.run = async function (env, context) {
246
- context.setValue(name, "hotUpdateStepChecker", (updateIndex, stats, runtime) => {
245
+ context.setValue("hotUpdateStepChecker", (updateIndex, stats, runtime) => {
247
246
  const statsJson = stats.toJson({
248
247
  assets: true,
249
248
  chunks: true
@@ -260,18 +259,18 @@ ${runtime.javascript.disposedModules.map(i => `- ${i}`).join("\n")}
260
259
  : Array.from(entry.runtime);
261
260
  }
262
261
  }
263
- const compiler = context.getCompiler(name);
262
+ const compiler = context.getCompiler();
264
263
  const compilerOptions = compiler.getOptions();
265
264
  matchStepSnapshot(env, context, updateIndex, compilerOptions, statsJson, runtime);
266
265
  hashes.push(stats.hash);
267
266
  });
268
- context.setValue(name, "hotUpdateStepErrorChecker", (updateIndex, stats, runtime) => {
267
+ context.setValue("hotUpdateStepErrorChecker", (updateIndex, stats, runtime) => {
269
268
  hashes.push(stats.hash);
270
269
  });
271
270
  await originRun(env, context);
272
271
  };
273
272
  processor.check = async function (env, context) {
274
- const compiler = (0, common_1.getCompiler)(context, name);
273
+ const compiler = context.getCompiler();
275
274
  const stats = compiler.getStats();
276
275
  if (!stats || !stats.hash) {
277
276
  env.expect(false);
package/dist/case/hot.js CHANGED
@@ -22,10 +22,10 @@ function createHotProcessor(name, src, temp, target, incremental = false) {
22
22
  const processor = {
23
23
  before: async (context) => {
24
24
  await updatePlugin.initialize();
25
- context.setValue(name, "hotUpdatePlugin", updatePlugin);
25
+ context.setValue("hotUpdatePlugin", updatePlugin);
26
26
  },
27
27
  config: async (context) => {
28
- const compiler = (0, common_1.getCompiler)(context, name);
28
+ const compiler = context.getCompiler();
29
29
  let options = defaultOptions(context, target);
30
30
  options = await (0, common_1.config)(context, name, ["rspack.config.js", "webpack.config.js"], options);
31
31
  overrideOptions(context, options, target, updatePlugin);
@@ -141,7 +141,7 @@ function overrideOptions(context, options, target, updatePlugin) {
141
141
  }
142
142
  }
143
143
  function findBundle(context, name, target, updatePlugin) {
144
- const compiler = context.getCompiler(name);
144
+ const compiler = context.getCompiler();
145
145
  if (!compiler)
146
146
  throw new Error("Compiler should exists when find bundle");
147
147
  const testConfig = context.getTestConfig();
@@ -171,12 +171,12 @@ function findBundle(context, name, target, updatePlugin) {
171
171
  return [...prefiles, ...files];
172
172
  }
173
173
  function createHotRunner(context, name, file, env) {
174
- const compiler = context.getCompiler(name);
174
+ const compiler = context.getCompiler();
175
175
  const compilerOptions = compiler.getOptions();
176
176
  const testConfig = context.getTestConfig();
177
177
  const source = context.getSource();
178
178
  const dist = context.getDist();
179
- const updatePlugin = context.getValue(name, "hotUpdatePlugin");
179
+ const updatePlugin = context.getValue("hotUpdatePlugin");
180
180
  const nextHMR = async (m, options) => {
181
181
  await updatePlugin.goNext();
182
182
  const stats = await compiler.build();
@@ -187,7 +187,7 @@ function createHotRunner(context, name, file, env) {
187
187
  // errorDetails: true
188
188
  });
189
189
  const compilerOptions = compiler.getOptions();
190
- const checker = context.getValue(name, jsonStats.errors?.length
190
+ const checker = context.getValue(jsonStats.errors?.length
191
191
  ? "hotUpdateStepErrorChecker"
192
192
  : "hotUpdateStepChecker");
193
193
  if (checker) {
@@ -7,11 +7,10 @@ exports.createMultiCompilerCase = createMultiCompilerCase;
7
7
  const node_path_1 = __importDefault(require("node:path"));
8
8
  const memfs_1 = require("memfs");
9
9
  const creator_1 = require("../test/creator");
10
- const common_1 = require("./common");
11
10
  function createMultiCompilerProcessor(name, caseConfig) {
12
11
  return {
13
12
  config: async (context) => {
14
- const compiler = (0, common_1.getCompiler)(context, name);
13
+ const compiler = context.getCompiler();
15
14
  const options = Object.assign([
16
15
  {
17
16
  name: "a",
@@ -27,7 +26,7 @@ function createMultiCompilerProcessor(name, caseConfig) {
27
26
  compiler.setOptions(options);
28
27
  },
29
28
  compiler: async (context) => {
30
- const compiler = (0, common_1.getCompiler)(context, name);
29
+ const compiler = context.getCompiler();
31
30
  if (caseConfig.compilerCallback) {
32
31
  compiler.createCompilerWithCallback(caseConfig.compilerCallback);
33
32
  }
@@ -57,7 +56,7 @@ function createMultiCompilerProcessor(name, caseConfig) {
57
56
  await caseConfig.compiler?.(context, c);
58
57
  },
59
58
  build: async (context) => {
60
- const compiler = (0, common_1.getCompiler)(context, name);
59
+ const compiler = context.getCompiler();
61
60
  if (typeof caseConfig.build === "function") {
62
61
  await caseConfig.build?.(context, compiler.getCompiler());
63
62
  }
@@ -21,7 +21,7 @@ const createCaseOptions = (hot, mode) => {
21
21
  steps: ({ name }) => [
22
22
  {
23
23
  config: async (context) => {
24
- const compiler = (0, common_1.getCompiler)(context, name);
24
+ const compiler = context.getCompiler();
25
25
  let options = defaultOptions(context, {
26
26
  plugins: hot ? [new core_1.HotModuleReplacementPlugin()] : []
27
27
  }, mode);
@@ -5,9 +5,9 @@ exports.createRunner = createRunner;
5
5
  exports.getMultiCompilerRunnerKey = getMultiCompilerRunnerKey;
6
6
  exports.createMultiCompilerRunner = createMultiCompilerRunner;
7
7
  const runner_1 = require("../runner");
8
- const common_1 = require("./common");
8
+ const debug_1 = require("../test/debug");
9
9
  function cachedStats(context, name) {
10
- const compiler = context.getCompiler(name);
10
+ const compiler = context.getCompiler();
11
11
  const statsGetter = (() => {
12
12
  let cached = null;
13
13
  return () => {
@@ -23,7 +23,7 @@ function cachedStats(context, name) {
23
23
  return statsGetter;
24
24
  }
25
25
  function createRunner(context, name, file, env) {
26
- const compiler = (0, common_1.getCompiler)(context, name);
26
+ const compiler = context.getCompiler();
27
27
  const testConfig = context.getTestConfig();
28
28
  const compilerOptions = compiler.getOptions();
29
29
  const runnerOptions = {
@@ -48,8 +48,8 @@ function createRunner(context, name, file, env) {
48
48
  return new runner_1.NodeRunner(runnerOptions);
49
49
  }
50
50
  function getFileIndexHandler(context, name, file) {
51
- const multiFileIndexMap = context.getValue(name, "multiFileIndexMap") || {};
52
- const runned = context.getValue(name, "runned") || new Set();
51
+ const multiFileIndexMap = context.getValue("multiFileIndexMap") || {};
52
+ const runned = context.getValue("runned") || new Set();
53
53
  if (typeof multiFileIndexMap[file] === "undefined") {
54
54
  throw new Error("Unexpect file in multiple runner");
55
55
  }
@@ -60,7 +60,7 @@ function getFileIndexHandler(context, name, file) {
60
60
  }
61
61
  const getIndex = () => [indexList[seq], seq];
62
62
  const flagIndex = () => runned.add(`${name}:${file}[${seq}]`);
63
- context.setValue(name, "runned", runned);
63
+ context.setValue("runned", runned);
64
64
  return { getIndex, flagIndex };
65
65
  }
66
66
  function getMultiCompilerRunnerKey(context, name, file) {
@@ -71,9 +71,11 @@ function getMultiCompilerRunnerKey(context, name, file) {
71
71
  function createMultiCompilerRunner(context, name, file, env) {
72
72
  const testConfig = context.getTestConfig();
73
73
  const { getIndex, flagIndex } = getFileIndexHandler(context, name, file);
74
- const multiCompilerOptions = context.getValue(name, "multiCompilerOptions") || [];
74
+ const multiCompilerOptions = context.getValue("multiCompilerOptions") || [];
75
75
  const [index] = getIndex();
76
76
  const compilerOptions = multiCompilerOptions[index];
77
+ const logs = context.getValue(debug_1.DEBUG_SCOPES.RunLogs);
78
+ const errors = context.getValue(debug_1.DEBUG_SCOPES.RunErrors);
77
79
  let runner;
78
80
  const runnerOptions = {
79
81
  runInNewContext: false,
@@ -91,7 +93,9 @@ function createMultiCompilerRunner(context, name, file, env) {
91
93
  testConfig: context.getTestConfig(),
92
94
  source: context.getSource(),
93
95
  dist: context.getDist(),
94
- compilerOptions
96
+ compilerOptions,
97
+ logs,
98
+ errors
95
99
  };
96
100
  if (compilerOptions.target === "web" ||
97
101
  compilerOptions.target === "webworker") {