@rspack/test-tools 2.0.1 → 2.0.3

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.
Files changed (118) hide show
  1. package/dist/case/builtin.js +106 -66
  2. package/dist/case/cache.js +152 -132
  3. package/dist/case/common.d.ts +4 -4
  4. package/dist/case/common.js +162 -157
  5. package/dist/case/compiler.d.ts +4 -4
  6. package/dist/case/compiler.js +75 -64
  7. package/dist/case/config.js +112 -74
  8. package/dist/case/defaults.js +136 -83
  9. package/dist/case/diagnostic.js +112 -84
  10. package/dist/case/error.d.ts +4 -4
  11. package/dist/case/error.js +105 -89
  12. package/dist/case/esm-output.js +118 -87
  13. package/dist/case/example.js +73 -35
  14. package/dist/case/hash.js +74 -59
  15. package/dist/case/hook.js +151 -138
  16. package/dist/case/hot-step.js +130 -161
  17. package/dist/case/hot.js +148 -134
  18. package/dist/case/incremental.js +91 -58
  19. package/dist/case/index.js +134 -51
  20. package/dist/case/multi-compiler.d.ts +4 -4
  21. package/dist/case/multi-compiler.js +81 -56
  22. package/dist/case/native-watcher.js +62 -30
  23. package/dist/case/normal.js +253 -185
  24. package/dist/case/runner.js +80 -51
  25. package/dist/case/serial.js +47 -16
  26. package/dist/case/stats-api.d.ts +4 -4
  27. package/dist/case/stats-api.js +63 -43
  28. package/dist/case/stats-output.d.ts +3 -3
  29. package/dist/case/stats-output.js +147 -152
  30. package/dist/case/treeshaking.js +66 -35
  31. package/dist/case/watch.d.ts +3 -19
  32. package/dist/case/watch.js +204 -224
  33. package/dist/compiler.js +222 -195
  34. package/dist/helper/directory.js +83 -71
  35. package/dist/helper/disable-iconv-lite-warning.js +35 -9
  36. package/dist/helper/expect/diff.js +39 -10
  37. package/dist/helper/expect/error.js +62 -30
  38. package/dist/helper/expect/placeholder.js +47 -21
  39. package/dist/helper/expect/rspack.js +35 -13
  40. package/dist/helper/expect/to-be-typeof.js +39 -7
  41. package/dist/helper/expect/to-end-with.js +40 -8
  42. package/dist/helper/expect/to-match-file-snapshot.js +103 -80
  43. package/dist/helper/hot-update/index.js +35 -4
  44. package/dist/helper/hot-update/loader.d.ts +1 -0
  45. package/dist/helper/hot-update/loader.js +39 -4
  46. package/dist/helper/hot-update/plugin.d.ts +1 -1
  47. package/dist/helper/hot-update/plugin.js +87 -74
  48. package/dist/helper/index.js +138 -24
  49. package/dist/helper/is.js +51 -10
  50. package/dist/helper/legacy/EventSourceForNode.d.ts +11 -3
  51. package/dist/helper/legacy/EventSourceForNode.js +83 -37
  52. package/dist/helper/legacy/LogTestPlugin.d.ts +2 -3
  53. package/dist/helper/legacy/LogTestPlugin.js +39 -6
  54. package/dist/helper/legacy/asModule.d.ts +3 -3
  55. package/dist/helper/legacy/asModule.js +68 -19
  56. package/dist/helper/legacy/captureStdio.d.ts +1 -2
  57. package/dist/helper/legacy/captureStdio.js +69 -29
  58. package/dist/helper/legacy/checkArrayExpectation.d.ts +1 -2
  59. package/dist/helper/legacy/checkArrayExpectation.js +132 -121
  60. package/dist/helper/legacy/copyDiff.d.ts +1 -2
  61. package/dist/helper/legacy/copyDiff.js +86 -42
  62. package/dist/helper/legacy/createFakeWorker.d.ts +2 -3
  63. package/dist/helper/legacy/createFakeWorker.js +90 -47
  64. package/dist/helper/legacy/createLazyTestEnv.d.ts +2 -3
  65. package/dist/helper/legacy/createLazyTestEnv.js +70 -59
  66. package/dist/helper/legacy/currentScript.d.ts +2 -2
  67. package/dist/helper/legacy/currentScript.js +35 -2
  68. package/dist/helper/legacy/deprecationTracking.d.ts +1 -1
  69. package/dist/helper/legacy/deprecationTracking.js +53 -28
  70. package/dist/helper/legacy/expectSource.d.ts +3 -2
  71. package/dist/helper/legacy/expectSource.js +42 -18
  72. package/dist/helper/legacy/fakeSystem.d.ts +12 -9
  73. package/dist/helper/legacy/fakeSystem.js +68 -58
  74. package/dist/helper/legacy/findOutputFiles.d.ts +7 -2
  75. package/dist/helper/legacy/findOutputFiles.js +60 -13
  76. package/dist/helper/legacy/parseResource.d.ts +1 -1
  77. package/dist/helper/legacy/parseResource.js +36 -6
  78. package/dist/helper/legacy/regexEscape.d.ts +1 -2
  79. package/dist/helper/legacy/regexEscape.js +39 -5
  80. package/dist/helper/legacy/supportDefaultAssignment.d.ts +1 -2
  81. package/dist/helper/legacy/supportDefaultAssignment.js +40 -7
  82. package/dist/helper/legacy/supportsTextDecoder.d.ts +1 -2
  83. package/dist/helper/legacy/supportsTextDecoder.js +40 -6
  84. package/dist/helper/legacy/supportsUsing.d.ts +1 -2
  85. package/dist/helper/legacy/supportsUsing.js +40 -7
  86. package/dist/helper/legacy/urlToRelativePath.d.ts +2 -2
  87. package/dist/helper/legacy/urlToRelativePath.js +56 -7
  88. package/dist/helper/parse-modules.js +52 -42
  89. package/dist/helper/read-config-file.js +60 -18
  90. package/dist/helper/serializers.js +62 -33
  91. package/dist/helper/setup-env.js +81 -91
  92. package/dist/helper/setup-expect.js +13 -13
  93. package/dist/helper/setup-wasm.js +18 -9
  94. package/dist/helper/stringify-config.js +44 -26
  95. package/dist/helper/update-snapshot.js +35 -3
  96. package/dist/helper/util/checkSourceMap.js +119 -80
  97. package/dist/helper/util/checkStats.d.ts +1 -1
  98. package/dist/helper/util/checkStats.js +42 -17
  99. package/dist/helper/util/expectWarningFactory.d.ts +1 -2
  100. package/dist/helper/util/expectWarningFactory.js +41 -8
  101. package/dist/helper/util/filterUtil.d.ts +9 -8
  102. package/dist/helper/util/filterUtil.js +63 -23
  103. package/dist/helper/win.js +46 -7
  104. package/dist/index.js +115 -23
  105. package/dist/plugin/index.js +55 -14
  106. package/dist/plugin/lazy-compilation-test-plugin.js +55 -41
  107. package/dist/reporter/index.js +55 -14
  108. package/dist/reporter/streamed-events-reporter.js +51 -77
  109. package/dist/runner/index.js +62 -15
  110. package/dist/runner/node/index.js +365 -431
  111. package/dist/runner/web/index.js +278 -263
  112. package/dist/test/context.js +67 -41
  113. package/dist/test/creator.js +135 -167
  114. package/dist/test/debug.js +89 -58
  115. package/dist/test/tester.js +94 -74
  116. package/dist/type.d.ts +10 -9
  117. package/dist/type.js +43 -9
  118. package/package.json +24 -23
@@ -1,20 +1,53 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createHotStepCase = createHotStepCase;
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const helper_1 = require("../helper");
10
- const placeholder_1 = require("../helper/expect/placeholder");
11
- const creator_1 = require("../test/creator");
12
- const hot_1 = require("./hot");
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ createHotStepCase: ()=>createHotStepCase
37
+ });
38
+ const external_node_path_namespaceObject = require("node:path");
39
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
40
+ const external_fs_extra_namespaceObject = require("fs-extra");
41
+ var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_extra_namespaceObject);
42
+ const index_js_namespaceObject = require("../helper/index.js");
43
+ const placeholder_js_namespaceObject = require("../helper/expect/placeholder.js");
44
+ const creator_js_namespaceObject = require("../test/creator.js");
45
+ const external_hot_js_namespaceObject = require("./hot.js");
13
46
  const NOOP_SET = new Set();
14
- const escapeLocalName = (str) => str.split(/[-<>:"/|?*.]/).join('_');
15
- const SELF_HANDLER = (file, options) => {
47
+ const escapeLocalName = (str)=>str.split(/[-<>:"/|?*.]/).join('_');
48
+ const SELF_HANDLER = (file, options)=>{
16
49
  let res = [];
17
- const hotUpdateGlobal = (_, modules) => {
50
+ const hotUpdateGlobal = (_, modules)=>{
18
51
  res = Object.keys(modules);
19
52
  };
20
53
  const hotUpdateGlobalKey = escapeLocalName(`${options.output?.hotUpdateGlobal || 'rspackHotUpdate'}${options.output?.uniqueName || ''}`);
@@ -24,18 +57,16 @@ const SELF_HANDLER = (file, options) => {
24
57
  delete global.self[hotUpdateGlobalKey];
25
58
  return res;
26
59
  };
27
- const NODE_HANDLER = (file) => {
28
- return Object.keys(require(file).modules) || [];
29
- };
60
+ const NODE_HANDLER = (file)=>Object.keys(require(file).modules) || [];
30
61
  const GET_MODULE_HANDLER = {
31
62
  web: SELF_HANDLER,
32
63
  webworker: SELF_HANDLER,
33
64
  'async-node': NODE_HANDLER,
34
- node: NODE_HANDLER,
65
+ node: NODE_HANDLER
35
66
  };
36
67
  const creators = new Map();
37
68
  function createHotStepProcessor(name, src, temp, target) {
38
- const processor = (0, hot_1.createHotProcessor)(name, src, temp, target);
69
+ const processor = (0, external_hot_js_namespaceObject.createHotProcessor)(name, src, temp, target);
39
70
  const entries = {};
40
71
  const hashes = [];
41
72
  function matchStepSnapshot(env, context, step, options, stats, runtime) {
@@ -43,78 +74,47 @@ function createHotStepProcessor(name, src, temp, target) {
43
74
  env.expect(typeof getModuleHandler).toBe('function');
44
75
  const lastHash = hashes[hashes.length - 1];
45
76
  const snapshotPath = context.getSource(`__snapshots__/${options.target}/${step}.snap.txt`);
46
- const title = `Case ${node_path_1.default.basename(name)}: Step ${step}`;
77
+ const title = `Case ${external_node_path_default().basename(name)}: Step ${step}`;
47
78
  const hotUpdateFile = [];
48
79
  const hotUpdateManifest = [];
49
- const changedFiles = step === 0
50
- ? []
51
- : processor.updatePlugin
52
- .getModifiedFiles()
53
- .map((i) => (0, helper_1.escapeSep)(node_path_1.default.relative(temp, i)));
80
+ const changedFiles = 0 === step ? [] : processor.updatePlugin.getModifiedFiles().map((i)=>(0, index_js_namespaceObject.escapeSep)(external_node_path_default().relative(temp, i)));
54
81
  changedFiles.sort();
55
82
  const resultHashes = {
56
83
  [lastHash || 'LAST_HASH']: 'LAST_HASH',
57
- [stats.hash]: 'CURRENT_HASH',
84
+ [stats.hash]: 'CURRENT_HASH'
58
85
  };
59
- // TODO: find a better way
60
- // replace [runtime] to [runtime of id] to prevent worker hash
61
86
  const runtimes = {};
62
- for (const [id, runtime] of Object.entries(entries)) {
63
- if (typeof runtime === 'string') {
64
- if (runtime !== id) {
65
- runtimes[runtime] = `[runtime of ${id}]`;
66
- }
67
- }
68
- else if (Array.isArray(runtime)) {
69
- for (const r of runtime) {
70
- if (r !== id) {
71
- runtimes[r] = `[runtime of ${id}]`;
72
- }
73
- }
74
- }
87
+ for (const [id, runtime] of Object.entries(entries))if ('string' == typeof runtime) {
88
+ if (runtime !== id) runtimes[runtime] = `[runtime of ${id}]`;
89
+ } else if (Array.isArray(runtime)) {
90
+ for (const r of runtime)if (r !== id) runtimes[r] = `[runtime of ${id}]`;
75
91
  }
76
- const replaceContent = (rawStr) => {
92
+ const replaceContent = (rawStr)=>{
77
93
  let str = rawStr;
78
94
  const replaceContentConfig = context.getTestConfig().snapshotContent;
79
- if (replaceContentConfig) {
80
- str = replaceContentConfig(str);
81
- }
82
- return (0, placeholder_1.normalizePlaceholder)(Object.entries(resultHashes)
83
- .reduce((str, [raw, replacement]) => {
84
- return str.split(raw).join(replacement);
85
- }, str)
86
- .replace(/\/\/ (\d+)\s+(?=var cssReload)/, '')
87
- .replaceAll(/var data = "(?:.*)"/g, (match) => {
88
- return decodeURIComponent(match).replaceAll(/\\/g, '/');
89
- }));
95
+ if (replaceContentConfig) str = replaceContentConfig(str);
96
+ return (0, placeholder_js_namespaceObject.normalizePlaceholder)(Object.entries(resultHashes).reduce((str, [raw, replacement])=>str.split(raw).join(replacement), str).replace(/\/\/ (\d+)\s+(?=var cssReload)/, '').replaceAll(/var data = "(?:.*)"/g, (match)=>decodeURIComponent(match).replaceAll(/\\/g, '/')));
90
97
  };
91
- const replaceFileName = (str) => {
92
- return Object.entries({
98
+ const replaceFileName = (str)=>Object.entries({
93
99
  ...resultHashes,
94
- ...runtimes,
95
- }).reduce((str, [raw, replacement]) => {
96
- return str.split(raw).join(replacement);
97
- }, str);
98
- };
99
- const assets = stats.assets.sort((a, b) => a.name.localeCompare(b.name));
100
- const fileList = assets
101
- .map((i) => {
100
+ ...runtimes
101
+ }).reduce((str, [raw, replacement])=>str.split(raw).join(replacement), str);
102
+ const assets = stats.assets.sort((a, b)=>a.name.localeCompare(b.name));
103
+ const fileList = assets.map((i)=>{
102
104
  const fileName = i.name;
103
105
  const renderName = replaceFileName(fileName);
104
- const content = replaceContent(fs_extra_1.default.readFileSync(context.getDist(fileName), 'utf-8'));
106
+ const content = replaceContent(external_fs_extra_default().readFileSync(context.getDist(fileName), 'utf-8'));
105
107
  if (fileName.endsWith('hot-update.js')) {
106
108
  const modules = getModuleHandler(context.getDist(fileName), options);
107
109
  const runtime = [];
108
- for (const i of content.matchAll(/\/\/ (webpack\/runtime\/[\w_-]+)\s*\n/g)) {
109
- runtime.push(i[1]);
110
- }
110
+ for (const i of content.matchAll(/\/\/ (webpack\/runtime\/[\w_-]+)\s*\n/g))runtime.push(i[1]);
111
111
  modules.sort();
112
112
  runtime.sort();
113
113
  hotUpdateFile.push({
114
114
  name: renderName,
115
115
  content,
116
116
  modules,
117
- runtime,
117
+ runtime
118
118
  });
119
119
  return `- Update: ${renderName}, size: ${content.length}`;
120
120
  }
@@ -125,70 +125,60 @@ function createHotStepProcessor(name, src, temp, target) {
125
125
  manifest.m?.sort();
126
126
  hotUpdateManifest.push({
127
127
  name: renderName,
128
- content: JSON.stringify(manifest),
128
+ content: JSON.stringify(manifest)
129
129
  });
130
130
  return `- Manifest: ${renderName}, size: ${i.size}`;
131
131
  }
132
- if (fileName.endsWith('.js')) {
133
- return `- Bundle: ${renderName}`;
134
- }
135
- })
136
- .filter(Boolean);
132
+ if (fileName.endsWith('.js')) return `- Bundle: ${renderName}`;
133
+ }).filter(Boolean);
137
134
  fileList.sort();
138
- hotUpdateManifest.sort((a, b) => (a.name > b.name ? 1 : -1));
139
- hotUpdateFile.sort((a, b) => (a.name > b.name ? 1 : -1));
135
+ hotUpdateManifest.sort((a, b)=>a.name > b.name ? 1 : -1);
136
+ hotUpdateFile.sort((a, b)=>a.name > b.name ? 1 : -1);
140
137
  if (runtime?.javascript) {
141
138
  runtime.javascript.outdatedModules.sort();
142
139
  runtime.javascript.updatedModules.sort();
143
140
  runtime.javascript.updatedRuntime.sort();
144
141
  runtime.javascript.acceptedModules.sort();
145
142
  runtime.javascript.disposedModules.sort();
146
- for (const value of Object.values(runtime.javascript.outdatedDependencies)) {
147
- value.sort();
148
- }
143
+ for (const value of Object.values(runtime.javascript.outdatedDependencies))value.sort();
149
144
  }
150
145
  const content = `
151
146
  # ${title}
152
147
 
153
148
  ## Changed Files
154
- ${changedFiles.map((i) => `- ${i}`).join('\n')}
149
+ ${changedFiles.map((i)=>`- ${i}`).join('\n')}
155
150
 
156
151
  ## Asset Files
157
152
  ${fileList.join('\n')}
158
153
 
159
154
  ## Manifest
160
- ${hotUpdateManifest
161
- .map((i) => `
155
+ ${hotUpdateManifest.map((i)=>`
162
156
  ### ${i.name}
163
157
 
164
158
  \`\`\`json
165
159
  ${i.content}
166
160
  \`\`\`
167
- `)
168
- .join('\n\n')}
161
+ `).join('\n\n')}
169
162
 
170
163
  ## Update
171
164
 
172
- ${hotUpdateFile
173
- .map((i) => `
165
+ ${hotUpdateFile.map((i)=>`
174
166
  ### ${i.name}
175
167
 
176
168
  #### Changed Modules
177
- ${i.modules.map((i) => `- ${i}`).join('\n')}
169
+ ${i.modules.map((i)=>`- ${i}`).join('\n')}
178
170
 
179
171
  #### Changed Runtime Modules
180
- ${i.runtime.map((i) => `- ${i}`).join('\n')}
172
+ ${i.runtime.map((i)=>`- ${i}`).join('\n')}
181
173
 
182
174
  #### Changed Content
183
175
  \`\`\`js
184
176
  ${i.content}
185
177
  \`\`\`
186
- `)
187
- .join('\n\n')}
178
+ `).join('\n\n')}
188
179
 
189
180
 
190
- ${runtime
191
- ? `
181
+ ${runtime ? `
192
182
  ## Runtime
193
183
  ### Status
194
184
 
@@ -196,15 +186,14 @@ ${runtime
196
186
  ${runtime.statusPath.join(' => ')}
197
187
  \`\`\`
198
188
 
199
- ${runtime.javascript
200
- ? `
189
+ ${runtime.javascript ? `
201
190
 
202
191
  ### JavaScript
203
192
 
204
193
  #### Outdated
205
194
 
206
195
  Outdated Modules:
207
- ${runtime.javascript.outdatedModules.map((i) => `- ${i}`).join('\n')}
196
+ ${runtime.javascript.outdatedModules.map((i)=>`- ${i}`).join('\n')}
208
197
 
209
198
 
210
199
  Outdated Dependencies:
@@ -215,114 +204,94 @@ ${JSON.stringify(runtime.javascript.outdatedDependencies || {}, null, 2)}
215
204
  #### Updated
216
205
 
217
206
  Updated Modules:
218
- ${runtime.javascript.updatedModules.map((i) => `- ${i}`).join('\n')}
207
+ ${runtime.javascript.updatedModules.map((i)=>`- ${i}`).join('\n')}
219
208
 
220
209
  Updated Runtime:
221
- ${runtime.javascript.updatedRuntime.map((i) => `- \`${i}\``).join('\n')}
210
+ ${runtime.javascript.updatedRuntime.map((i)=>`- \`${i}\``).join('\n')}
222
211
 
223
212
 
224
213
  #### Callback
225
214
 
226
215
  Accepted Callback:
227
- ${runtime.javascript.acceptedModules.map((i) => `- ${i}`).join('\n')}
216
+ ${runtime.javascript.acceptedModules.map((i)=>`- ${i}`).join('\n')}
228
217
 
229
218
  Disposed Callback:
230
- ${runtime.javascript.disposedModules.map((i) => `- ${i}`).join('\n')}
231
- `
232
- : ''}
219
+ ${runtime.javascript.disposedModules.map((i)=>`- ${i}`).join('\n')}
220
+ ` : ''}
233
221
 
234
- `
235
- : ''}
222
+ ` : ''}
236
223
 
237
- `
238
- .replaceAll(/%3A(\d+)%2F/g, (match, capture) => {
239
- return match.replace(capture, 'PORT');
240
- })
241
- .trim();
224
+ `.replaceAll(/%3A(\d+)%2F/g, (match, capture)=>match.replace(capture, 'PORT')).trim();
242
225
  env.expect(content).toMatchFileSnapshotSync(snapshotPath);
243
226
  }
244
227
  const originRun = processor.run;
245
- processor.run = async function (env, context) {
246
- context.setValue('hotUpdateStepChecker', (updateIndex, stats, runtime) => {
228
+ processor.run = async function(env, context) {
229
+ context.setValue('hotUpdateStepChecker', (updateIndex, stats, runtime)=>{
247
230
  const statsJson = stats.toJson({
248
231
  assets: true,
249
- chunks: true,
232
+ chunks: true
250
233
  });
251
- const chunks = Array.from(
252
- // Some chunk fields are missing from rspack
253
- stats?.compilation.chunks || NOOP_SET);
254
- for (const entry of chunks.filter((i) => i.hasRuntime())) {
255
- if (!entries[entry.id] && entry.runtime) {
256
- entries[entry.id] =
257
- // Webpack uses `string | SortableSet<string>` for `entry.runtime`
258
- typeof entry.runtime === 'string'
259
- ? [entry.runtime]
260
- : Array.from(entry.runtime);
261
- }
262
- }
234
+ const chunks = Array.from(stats?.compilation.chunks || NOOP_SET);
235
+ for (const entry of chunks.filter((i)=>i.hasRuntime()))if (!entries[entry.id] && entry.runtime) entries[entry.id] = 'string' == typeof entry.runtime ? [
236
+ entry.runtime
237
+ ] : Array.from(entry.runtime);
263
238
  const compiler = context.getCompiler();
264
239
  const compilerOptions = compiler.getOptions();
265
240
  matchStepSnapshot(env, context, updateIndex, compilerOptions, statsJson, runtime);
266
241
  hashes.push(stats.hash);
267
242
  });
268
- context.setValue('hotUpdateStepErrorChecker', (updateIndex, stats, runtime) => {
243
+ context.setValue('hotUpdateStepErrorChecker', (updateIndex, stats, runtime)=>{
269
244
  hashes.push(stats.hash);
270
245
  });
271
246
  await originRun(env, context);
272
247
  };
273
- processor.check = async function (env, context) {
248
+ processor.check = function(env, context) {
274
249
  const compiler = context.getCompiler();
275
250
  const stats = compiler.getStats();
276
- if (!stats || !stats.hash) {
277
- env.expect(false);
278
- return;
279
- }
280
- const statsJson = stats.toJson({ assets: true, chunks: true });
281
- const chunks = Array.from(
282
- // Some chunk fields are missing from rspack
283
- stats?.compilation.chunks || NOOP_SET);
284
- for (const entry of chunks.filter((i) => i.hasRuntime())) {
285
- if (entry.runtime) {
286
- entries[entry.id] =
287
- // Webpack uses `string | SortableSet<string>` for `entry.runtime`
288
- typeof entry.runtime === 'string'
289
- ? [entry.runtime]
290
- : Array.from(entry.runtime);
291
- }
292
- }
251
+ if (!stats || !stats.hash) return void env.expect(false);
252
+ const statsJson = stats.toJson({
253
+ assets: true,
254
+ chunks: true
255
+ });
256
+ const chunks = Array.from(stats?.compilation.chunks || NOOP_SET);
257
+ for (const entry of chunks.filter((i)=>i.hasRuntime()))if (entry.runtime) entries[entry.id] = 'string' == typeof entry.runtime ? [
258
+ entry.runtime
259
+ ] : Array.from(entry.runtime);
293
260
  let matchFailed = null;
294
261
  try {
295
262
  matchStepSnapshot(env, context, 0, compiler.getOptions(), statsJson);
296
- }
297
- catch (e) {
263
+ } catch (e) {
298
264
  matchFailed = e;
299
265
  }
300
266
  hashes.push(stats.hash);
301
- if (matchFailed) {
302
- throw matchFailed;
303
- }
267
+ if (matchFailed) throw matchFailed;
304
268
  };
305
269
  return processor;
306
270
  }
307
271
  function getCreator(target) {
308
- if (!creators.has(target)) {
309
- creators.set(target, new creator_1.BasicCaseCreator({
310
- clean: true,
311
- describe: false,
312
- target,
313
- steps: ({ name, target, src, temp, dist }) => [
314
- createHotStepProcessor(name, src, temp || node_path_1.default.resolve(dist, 'temp'), target),
272
+ if (!creators.has(target)) creators.set(target, new creator_js_namespaceObject.BasicCaseCreator({
273
+ clean: true,
274
+ describe: false,
275
+ target,
276
+ steps: ({ name, target, src, temp, dist })=>[
277
+ createHotStepProcessor(name, src, temp || external_node_path_default().resolve(dist, 'temp'), target)
315
278
  ],
316
- runner: {
317
- key: (context, name, file) => name,
318
- runner: hot_1.createHotRunner,
319
- },
320
- concurrent: true,
321
- }));
322
- }
279
+ runner: {
280
+ key: (context, name, file)=>name,
281
+ runner: external_hot_js_namespaceObject.createHotRunner
282
+ },
283
+ concurrent: true
284
+ }));
323
285
  return creators.get(target);
324
286
  }
325
287
  function createHotStepCase(name, src, dist, temp, target) {
326
288
  const creator = getCreator(target);
327
289
  creator.create(name, src, dist, temp);
328
290
  }
291
+ exports.createHotStepCase = __webpack_exports__.createHotStepCase;
292
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
293
+ "createHotStepCase"
294
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
295
+ Object.defineProperty(exports, '__esModule', {
296
+ value: true
297
+ });