@rspack/core 1.0.0-alpha.5 → 1.0.0-beta.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.
Files changed (89) hide show
  1. package/compiled/zod/index.d.ts +138 -52
  2. package/compiled/zod/index.js +300 -103
  3. package/compiled/zod/package.json +1 -1
  4. package/compiled/zod-validation-error/index.js +6 -6
  5. package/dist/Compilation.d.ts +21 -3
  6. package/dist/Compilation.js +64 -49
  7. package/dist/Compiler.js +28 -28
  8. package/dist/ErrorHelpers.js +2 -4
  9. package/dist/Module.js +2 -6
  10. package/dist/ModuleTypeConstants.d.ts +45 -69
  11. package/dist/ModuleTypeConstants.js +24 -77
  12. package/dist/Stats.js +4 -6
  13. package/dist/Template.d.ts +31 -147
  14. package/dist/Template.js +40 -236
  15. package/dist/builtin-loader/lightningcss/index.d.ts +89 -0
  16. package/dist/builtin-loader/lightningcss/index.js +175 -0
  17. package/dist/builtin-plugin/BannerPlugin.d.ts +24 -48
  18. package/dist/builtin-plugin/DefinePlugin.js +9 -13
  19. package/dist/builtin-plugin/EntryPlugin.d.ts +2 -2
  20. package/dist/builtin-plugin/ExternalsPlugin.d.ts +24 -0
  21. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +8 -8
  22. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +2 -2
  23. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +10 -3
  24. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +4 -1
  25. package/dist/builtin-plugin/SplitChunksPlugin.js +5 -15
  26. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +15 -23
  27. package/dist/builtin-plugin/base.js +1 -3
  28. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts +3 -3
  29. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +17 -66
  30. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +2 -0
  31. package/dist/builtin-plugin/css-extract/hmr/{normalize-url.js → normalizeUrl.js} +15 -24
  32. package/dist/builtin-plugin/css-extract/loader.js +5 -5
  33. package/dist/config/adapter.d.ts +1 -1
  34. package/dist/config/adapter.js +24 -23
  35. package/dist/config/adapterRuleUse.d.ts +5 -5
  36. package/dist/config/adapterRuleUse.js +23 -1
  37. package/dist/config/browserslistTargetHandler.d.ts +17 -15
  38. package/dist/config/browserslistTargetHandler.js +27 -33
  39. package/dist/config/defaults.js +20 -21
  40. package/dist/config/normalization.d.ts +2 -0
  41. package/dist/config/normalization.js +5 -5
  42. package/dist/config/target.d.ts +48 -109
  43. package/dist/config/target.js +50 -86
  44. package/dist/config/zod.d.ts +2391 -2205
  45. package/dist/config/zod.js +28 -18
  46. package/dist/container/ContainerPlugin.d.ts +7 -7
  47. package/dist/container/options.js +1 -1
  48. package/dist/exports.d.ts +4 -4
  49. package/dist/exports.js +2 -2
  50. package/dist/lib/CacheFacade.js +1 -0
  51. package/dist/lib/ModuleFilenameHelpers.js +1 -3
  52. package/dist/lib/cache/mergeEtags.js +5 -11
  53. package/dist/lib/formatLocation.js +3 -5
  54. package/dist/loader-runner/LoaderLoadingError.d.ts +11 -1
  55. package/dist/loader-runner/LoaderLoadingError.js +3 -5
  56. package/dist/loader-runner/index.js +7 -9
  57. package/dist/loader-runner/loadLoader.d.ts +11 -2
  58. package/dist/loader-runner/loadLoader.js +17 -19
  59. package/dist/logging/createConsoleLogger.js +2 -6
  60. package/dist/logging/truncateArgs.js +5 -9
  61. package/dist/node/nodeConsole.js +1 -3
  62. package/dist/stats/DefaultStatsFactoryPlugin.js +17 -7
  63. package/dist/stats/DefaultStatsPresetPlugin.js +4 -4
  64. package/dist/stats/DefaultStatsPrinterPlugin.js +11 -16
  65. package/dist/stats/StatsFactory.js +13 -17
  66. package/dist/stats/StatsPrinter.js +7 -9
  67. package/dist/util/AssetInfo.js +11 -7
  68. package/dist/util/SplitChunkSize.js +1 -1
  69. package/dist/util/cleverMerge.d.ts +33 -57
  70. package/dist/util/cleverMerge.js +89 -145
  71. package/dist/util/comparators.js +3 -5
  72. package/dist/util/createHash.d.ts +4 -3
  73. package/dist/util/createHash.js +31 -45
  74. package/dist/util/fs.js +9 -13
  75. package/dist/util/hash/BatchedHash.d.ts +24 -9
  76. package/dist/util/hash/BatchedHash.js +16 -13
  77. package/dist/util/hash/index.d.ts +9 -9
  78. package/dist/util/hash/index.js +14 -11
  79. package/dist/util/hash/md4.d.ts +29 -2
  80. package/dist/util/hash/md4.js +7 -3
  81. package/dist/util/hash/wasm-hash.d.ts +52 -5
  82. package/dist/util/hash/wasm-hash.js +19 -22
  83. package/dist/util/hash/xxhash64.d.ts +29 -2
  84. package/dist/util/hash/xxhash64.js +7 -3
  85. package/dist/util/identifier.js +9 -15
  86. package/dist/util/index.js +1 -1
  87. package/dist/util/memoize.js +7 -9
  88. package/package.json +9 -8
  89. package/dist/builtin-plugin/css-extract/hmr/normalize-url.d.ts +0 -2
@@ -1,23 +1,12 @@
1
- /**
2
- * The following code is modified based on
3
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib/util/cleverMerge.js
4
- *
5
- * MIT Licensed
6
- * Author Tobias Koppers @sokra
7
- * Copyright (c) JS Foundation and other contributors
8
- * https://github.com/webpack/webpack/blob/main/LICENSE
9
- */
10
1
  "use strict";
11
- /** @type {WeakMap<object, WeakMap<object, object>>} */
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveByProperty = exports.removeOperations = exports.cleverMerge = exports.cachedSetProperty = exports.cachedCleverMerge = exports.DELETE = void 0;
12
4
  const mergeCache = new WeakMap();
13
- /** @type {WeakMap<object, Map<string, Map<string|number|boolean, object>>>} */
14
5
  const setPropertyCache = new WeakMap();
15
- const DELETE = Symbol("DELETE");
6
+ exports.DELETE = Symbol("DELETE");
16
7
  const DYNAMIC_INFO = Symbol("cleverMerge dynamic info");
17
8
  /**
18
9
  * Merges two given objects and caches the result to avoid computation if same objects passed as arguments again.
19
- * @template T
20
- * @template O
21
10
  * @example
22
11
  * // performs cleverMerge(first, second), stores the result in WeakMap and returns result
23
12
  * cachedCleverMerge({a: 1}, {a: 2})
@@ -25,9 +14,9 @@ const DYNAMIC_INFO = Symbol("cleverMerge dynamic info");
25
14
  * // when same arguments passed, gets the result from WeakMap and returns it.
26
15
  * cachedCleverMerge({a: 1}, {a: 2})
27
16
  * {a: 2}
28
- * @param {T} first first object
29
- * @param {O} second second object
30
- * @returns {T & O | T | O} merged object of first and second object
17
+ * @param first first object
18
+ * @param second second object
19
+ * @returns merged object of first and second object
31
20
  */
32
21
  const cachedCleverMerge = (first, second) => {
33
22
  if (second === undefined)
@@ -44,20 +33,18 @@ const cachedCleverMerge = (first, second) => {
44
33
  mergeCache.set(first, innerCache);
45
34
  }
46
35
  const prevMerge = innerCache.get(second);
47
- // @ts-expect-error
48
36
  if (prevMerge !== undefined)
49
37
  return prevMerge;
50
38
  const newMerge = _cleverMerge(first, second, true);
51
39
  innerCache.set(second, newMerge);
52
- // @ts-expect-error
53
40
  return newMerge;
54
41
  };
42
+ exports.cachedCleverMerge = cachedCleverMerge;
55
43
  /**
56
- * @template T
57
- * @param {Partial<T>} obj object
58
- * @param {string} property property
59
- * @param {string|number|boolean} value assignment value
60
- * @returns {T} new object
44
+ * @param obj object
45
+ * @param property property
46
+ * @param value assignment value
47
+ * @returns new object
61
48
  */
62
49
  const cachedSetProperty = (obj, property, value) => {
63
50
  let mapByProperty = setPropertyCache.get(obj);
@@ -71,7 +58,6 @@ const cachedSetProperty = (obj, property, value) => {
71
58
  mapByProperty.set(property, mapByValue);
72
59
  }
73
60
  let result = mapByValue.get(value);
74
- // @ts-expect-error
75
61
  if (result)
76
62
  return result;
77
63
  result = {
@@ -79,27 +65,15 @@ const cachedSetProperty = (obj, property, value) => {
79
65
  [property]: value
80
66
  };
81
67
  mapByValue.set(value, result);
82
- // @ts-expect-error
83
68
  return result;
84
69
  };
85
- /**
86
- * @typedef {Object} ObjectParsedPropertyEntry
87
- * @property {any | undefined} base base value
88
- * @property {string | undefined} byProperty the name of the selector property
89
- * @property {Map<string, any>} byValues value depending on selector property, merged with base
90
- */
91
- /**
92
- * @typedef {Object} ParsedObject
93
- * @property {Map<string, ObjectParsedPropertyEntry>} static static properties (key is property name)
94
- * @property {{ byProperty: string, fn: Function } | undefined} dynamic dynamic part
95
- */
96
- /** @type {WeakMap<object, ParsedObject>} */
70
+ exports.cachedSetProperty = cachedSetProperty;
97
71
  const parseCache = new WeakMap();
98
72
  /**
99
- * @param {object} obj the object
100
- * @returns {ParsedObject} parsed object
73
+ * @param obj the object
74
+ * @returns parsed object
101
75
  */
102
- const cachedParseObject = obj => {
76
+ const cachedParseObject = (obj) => {
103
77
  const entry = parseCache.get(obj);
104
78
  if (entry !== undefined)
105
79
  return entry;
@@ -111,18 +85,17 @@ const cachedParseObject = obj => {
111
85
  * @param {object} obj the object
112
86
  * @returns {ParsedObject} parsed object
113
87
  */
114
- const parseObject = obj => {
88
+ const parseObject = (obj) => {
115
89
  const info = new Map();
116
90
  let dynamicInfo;
117
- // @ts-expect-error
118
- const getInfo = p => {
91
+ const getInfo = (p) => {
119
92
  const entry = info.get(p);
120
93
  if (entry !== undefined)
121
94
  return entry;
122
95
  const newEntry = {
123
96
  base: undefined,
124
97
  byProperty: undefined,
125
- byValues: undefined
98
+ byValues: new Map()
126
99
  };
127
100
  info.set(p, newEntry);
128
101
  return newEntry;
@@ -130,7 +103,6 @@ const parseObject = obj => {
130
103
  for (const key of Object.keys(obj)) {
131
104
  if (key.startsWith("by")) {
132
105
  const byProperty = key;
133
- // @ts-expect-error
134
106
  const byObj = obj[byProperty];
135
107
  if (typeof byObj === "object") {
136
108
  for (const byValue of Object.keys(byObj)) {
@@ -139,7 +111,6 @@ const parseObject = obj => {
139
111
  const entry = getInfo(key);
140
112
  if (entry.byProperty === undefined) {
141
113
  entry.byProperty = byProperty;
142
- entry.byValues = new Map();
143
114
  }
144
115
  else if (entry.byProperty !== byProperty) {
145
116
  throw new Error(`${byProperty} and ${entry.byProperty} for a single property is not supported`);
@@ -167,13 +138,11 @@ const parseObject = obj => {
167
138
  }
168
139
  else {
169
140
  const entry = getInfo(key);
170
- // @ts-expect-error
171
141
  entry.base = obj[key];
172
142
  }
173
143
  }
174
144
  else {
175
145
  const entry = getInfo(key);
176
- // @ts-expect-error
177
146
  entry.base = obj[key];
178
147
  }
179
148
  }
@@ -183,16 +152,15 @@ const parseObject = obj => {
183
152
  };
184
153
  };
185
154
  /**
186
- * @param {Map<string, ObjectParsedPropertyEntry>} info static properties (key is property name)
187
- * @param {{ byProperty: string, fn: Function } | undefined} dynamicInfo dynamic part
188
- * @returns {object} the object
155
+ * @param info static properties (key is property name)
156
+ * @param dynamicInfo dynamic part
157
+ * @returns the object
189
158
  */
190
159
  const serializeObject = (info, dynamicInfo) => {
191
160
  const obj = {};
192
161
  // Setup byProperty structure
193
162
  for (const entry of info.values()) {
194
163
  if (entry.byProperty !== undefined) {
195
- // @ts-expect-error
196
164
  const byObj = (obj[entry.byProperty] = obj[entry.byProperty] || {});
197
165
  for (const byValue of entry.byValues.keys()) {
198
166
  byObj[byValue] = byObj[byValue] || {};
@@ -201,12 +169,10 @@ const serializeObject = (info, dynamicInfo) => {
201
169
  }
202
170
  for (const [key, entry] of info) {
203
171
  if (entry.base !== undefined) {
204
- // @ts-expect-error
205
172
  obj[key] = entry.base;
206
173
  }
207
174
  // Fill byProperty structure
208
175
  if (entry.byProperty !== undefined) {
209
- // @ts-expect-error
210
176
  const byObj = (obj[entry.byProperty] = obj[entry.byProperty] || {});
211
177
  for (const byValue of Object.keys(byObj)) {
212
178
  const value = getFromByValues(entry.byValues, byValue);
@@ -216,7 +182,6 @@ const serializeObject = (info, dynamicInfo) => {
216
182
  }
217
183
  }
218
184
  if (dynamicInfo !== undefined) {
219
- // @ts-expect-error
220
185
  obj[dynamicInfo.byProperty] = dynamicInfo.fn;
221
186
  }
222
187
  return obj;
@@ -227,22 +192,22 @@ const VALUE_TYPE_ARRAY_EXTEND = 2;
227
192
  const VALUE_TYPE_OBJECT = 3;
228
193
  const VALUE_TYPE_DELETE = 4;
229
194
  /**
230
- * @param {any} value a single value
195
+ * @param value a single value
231
196
  * @returns {VALUE_TYPE_UNDEFINED | VALUE_TYPE_ATOM | VALUE_TYPE_ARRAY_EXTEND | VALUE_TYPE_OBJECT | VALUE_TYPE_DELETE} value type
232
197
  */
233
- const getValueType = value => {
198
+ const getValueType = (value) => {
234
199
  if (value === undefined) {
235
200
  return VALUE_TYPE_UNDEFINED;
236
201
  }
237
- else if (value === DELETE) {
202
+ if (value === exports.DELETE) {
238
203
  return VALUE_TYPE_DELETE;
239
204
  }
240
- else if (Array.isArray(value)) {
205
+ if (Array.isArray(value)) {
241
206
  if (value.lastIndexOf("...") !== -1)
242
207
  return VALUE_TYPE_ARRAY_EXTEND;
243
208
  return VALUE_TYPE_ATOM;
244
209
  }
245
- else if (typeof value === "object" &&
210
+ if (typeof value === "object" &&
246
211
  value !== null &&
247
212
  (!value.constructor || value.constructor === Object)) {
248
213
  return VALUE_TYPE_OBJECT;
@@ -253,11 +218,9 @@ const getValueType = value => {
253
218
  * Merges two objects. Objects are deeply clever merged.
254
219
  * Arrays might reference the old value with "...".
255
220
  * Non-object values take preference over object values.
256
- * @template T
257
- * @template O
258
- * @param {T} first first object
259
- * @param {O} second second object
260
- * @returns {T & O | T | O} merged object of first and second object
221
+ * @param first first object
222
+ * @param second second object
223
+ * @returns merged object of first and second object
261
224
  */
262
225
  const cleverMerge = (first, second) => {
263
226
  if (second === undefined)
@@ -268,15 +231,15 @@ const cleverMerge = (first, second) => {
268
231
  return second;
269
232
  if (typeof first !== "object" || first === null)
270
233
  return first;
271
- // @ts-expect-error
272
234
  return _cleverMerge(first, second, false);
273
235
  };
236
+ exports.cleverMerge = cleverMerge;
274
237
  /**
275
238
  * Merges two objects. Objects are deeply clever merged.
276
- * @param {object} first first object
277
- * @param {object} second second object
278
- * @param {boolean} internalCaching should parsing of objects and nested merges be cached
279
- * @returns {object} merged object of first and second object
239
+ * @param first first object
240
+ * @param second second object
241
+ * @param internalCaching should parsing of objects and nested merges be cached
242
+ * @returns merged object of first and second object
280
243
  */
281
244
  const _cleverMerge = (first, second, internalCaching = false) => {
282
245
  const firstObject = internalCaching
@@ -286,22 +249,19 @@ const _cleverMerge = (first, second, internalCaching = false) => {
286
249
  // If the first argument has a dynamic part we modify the dynamic part to merge the second argument
287
250
  if (firstDynamicInfo !== undefined) {
288
251
  let { byProperty, fn } = firstDynamicInfo;
289
- // @ts-expect-error
290
252
  const fnInfo = fn[DYNAMIC_INFO];
291
253
  if (fnInfo) {
292
254
  second = internalCaching
293
- ? cachedCleverMerge(fnInfo[1], second)
294
- : cleverMerge(fnInfo[1], second);
255
+ ? (0, exports.cachedCleverMerge)(fnInfo[1], second)
256
+ : (0, exports.cleverMerge)(fnInfo[1], second);
295
257
  fn = fnInfo[0];
296
258
  }
297
- // @ts-expect-error
298
259
  const newFn = (...args) => {
299
260
  const fnResult = fn(...args);
300
261
  return internalCaching
301
- ? cachedCleverMerge(fnResult, second)
302
- : cleverMerge(fnResult, second);
262
+ ? (0, exports.cachedCleverMerge)(fnResult, second)
263
+ : (0, exports.cleverMerge)(fnResult, second);
303
264
  };
304
- // @ts-expect-error
305
265
  newFn[DYNAMIC_INFO] = [fn, second];
306
266
  return serializeObject(firstObject.static, { byProperty, fn: newFn });
307
267
  }
@@ -310,7 +270,6 @@ const _cleverMerge = (first, second, internalCaching = false) => {
310
270
  ? cachedParseObject(second)
311
271
  : parseObject(second);
312
272
  const { static: secondInfo, dynamic: secondDynamicInfo } = secondObject;
313
- /** @type {Map<string, ObjectParsedPropertyEntry>} */
314
273
  const resultInfo = new Map();
315
274
  for (const [key, firstEntry] of firstInfo) {
316
275
  const secondEntry = secondInfo.get(key);
@@ -327,10 +286,10 @@ const _cleverMerge = (first, second, internalCaching = false) => {
327
286
  return serializeObject(resultInfo, secondDynamicInfo);
328
287
  };
329
288
  /**
330
- * @param {ObjectParsedPropertyEntry} firstEntry a
331
- * @param {ObjectParsedPropertyEntry} secondEntry b
332
- * @param {boolean} internalCaching should parsing of objects and nested merges be cached
333
- * @returns {ObjectParsedPropertyEntry} new entry
289
+ * @param firstEntry a
290
+ * @param secondEntry b
291
+ * @param internalCaching should parsing of objects and nested merges be cached
292
+ * @returns new entry
334
293
  */
335
294
  const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
336
295
  switch (getValueType(secondEntry.base)) {
@@ -349,23 +308,21 @@ const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
349
308
  byValues: secondEntry.byValues
350
309
  };
351
310
  }
352
- else if (firstEntry.byProperty !== secondEntry.byProperty) {
311
+ if (firstEntry.byProperty !== secondEntry.byProperty) {
353
312
  throw new Error(`${firstEntry.byProperty} and ${secondEntry.byProperty} for a single property is not supported`);
354
313
  }
355
- else {
356
- // = first.base + (first.byProperty + second.byProperty)
357
- // need to merge first and second byValues
358
- const newByValues = new Map(firstEntry.byValues);
359
- for (const [key, value] of secondEntry.byValues) {
360
- const firstValue = getFromByValues(firstEntry.byValues, key);
361
- newByValues.set(key, mergeSingleValue(firstValue, value, internalCaching));
362
- }
363
- return {
364
- base: firstEntry.base,
365
- byProperty: firstEntry.byProperty,
366
- byValues: newByValues
367
- };
314
+ // = first.base + (first.byProperty + second.byProperty)
315
+ // need to merge first and second byValues
316
+ const newByValues = new Map(firstEntry.byValues);
317
+ for (const [key, value] of secondEntry.byValues) {
318
+ const firstValue = getFromByValues(firstEntry.byValues, key);
319
+ newByValues.set(key, mergeSingleValue(firstValue, value, internalCaching));
368
320
  }
321
+ return {
322
+ base: firstEntry.base,
323
+ byProperty: firstEntry.byProperty,
324
+ byValues: newByValues
325
+ };
369
326
  default: {
370
327
  if (!firstEntry.byProperty) {
371
328
  // The simple case
@@ -402,7 +359,7 @@ const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
402
359
  byValues: intermediateByValues
403
360
  };
404
361
  }
405
- else if (firstEntry.byProperty !== secondEntry.byProperty) {
362
+ if (firstEntry.byProperty !== secondEntry.byProperty) {
406
363
  throw new Error(`${firstEntry.byProperty} and ${secondEntry.byProperty} for a single property is not supported`);
407
364
  }
408
365
  const newByValues = new Map(intermediateByValues);
@@ -419,9 +376,9 @@ const mergeEntries = (firstEntry, secondEntry, internalCaching) => {
419
376
  }
420
377
  };
421
378
  /**
422
- * @param {Map<string, any>} byValues all values
423
- * @param {string} key value of the selector
424
- * @returns {any | undefined} value
379
+ * @param byValues all values
380
+ * @param key value of the selector
381
+ * @returns value
425
382
  */
426
383
  const getFromByValues = (byValues, key) => {
427
384
  if (key !== "default" && byValues.has(key)) {
@@ -430,10 +387,10 @@ const getFromByValues = (byValues, key) => {
430
387
  return byValues.get("default");
431
388
  };
432
389
  /**
433
- * @param {any} a value
434
- * @param {any} b value
435
- * @param {boolean} internalCaching should parsing of objects and nested merges be cached
436
- * @returns {any} value
390
+ * @param a value
391
+ * @param b value
392
+ * @param internalCaching should parsing of objects and nested merges be cached
393
+ * @returns value
437
394
  */
438
395
  const mergeSingleValue = (a, b, internalCaching) => {
439
396
  const bType = getValueType(b);
@@ -446,8 +403,8 @@ const mergeSingleValue = (a, b, internalCaching) => {
446
403
  return aType !== VALUE_TYPE_OBJECT
447
404
  ? b
448
405
  : internalCaching
449
- ? cachedCleverMerge(a, b)
450
- : cleverMerge(a, b);
406
+ ? (0, exports.cachedCleverMerge)(a, b)
407
+ : (0, exports.cleverMerge)(a, b);
451
408
  }
452
409
  case VALUE_TYPE_UNDEFINED:
453
410
  return a;
@@ -460,8 +417,7 @@ const mergeSingleValue = (a, b, internalCaching) => {
460
417
  case VALUE_TYPE_UNDEFINED:
461
418
  return b;
462
419
  case VALUE_TYPE_DELETE:
463
- // @ts-expect-error
464
- return b.filter(item => item !== "...");
420
+ return b.filter((item) => item !== "...");
465
421
  case VALUE_TYPE_ARRAY_EXTEND: {
466
422
  const newArray = [];
467
423
  for (const item of b) {
@@ -477,8 +433,7 @@ const mergeSingleValue = (a, b, internalCaching) => {
477
433
  return newArray;
478
434
  }
479
435
  case VALUE_TYPE_OBJECT:
480
- // @ts-expect-error
481
- return b.map(item => (item === "..." ? a : item));
436
+ return b.map((item) => (item === "..." ? a : item));
482
437
  default:
483
438
  throw new Error("Not implemented");
484
439
  }
@@ -487,15 +442,12 @@ const mergeSingleValue = (a, b, internalCaching) => {
487
442
  }
488
443
  };
489
444
  /**
490
- * @template T
491
- * @param {T} obj the object
492
- * @returns {T} the object without operations like "..." or DELETE
445
+ * @param obj the object
446
+ * @returns the object without operations like "..." or DELETE
493
447
  */
494
- const removeOperations = obj => {
495
- const newObj = /** @type {T} */ ({});
496
- // @ts-expect-error
448
+ const removeOperations = (obj) => {
449
+ const newObj = {};
497
450
  for (const key of Object.keys(obj)) {
498
- // @ts-expect-error
499
451
  const value = obj[key];
500
452
  const type = getValueType(value);
501
453
  switch (type) {
@@ -503,56 +455,48 @@ const removeOperations = obj => {
503
455
  case VALUE_TYPE_DELETE:
504
456
  break;
505
457
  case VALUE_TYPE_OBJECT:
506
- // @ts-expect-error
507
- newObj[key] = removeOperations(value);
458
+ newObj[key] = (0, exports.removeOperations)(value);
508
459
  break;
509
460
  case VALUE_TYPE_ARRAY_EXTEND:
510
- // @ts-expect-error
511
461
  newObj[key] = value.filter(i => i !== "...");
512
462
  break;
513
463
  default:
514
- // @ts-expect-error
515
464
  newObj[key] = value;
516
465
  break;
517
466
  }
518
467
  }
519
468
  return newObj;
520
469
  };
470
+ exports.removeOperations = removeOperations;
521
471
  /**
522
- * @template T
523
- * @template {string} P
524
- * @param {T} obj the object
525
- * @param {P} byProperty the by description
526
- * @param {...any} values values
527
- * @returns {Omit<T, P>|undefined} object with merged byProperty
472
+ * @param obj the object
473
+ * @param byProperty the by description
474
+ * @param values values
475
+ * @returns object with merged byProperty
528
476
  */
529
477
  const resolveByProperty = (obj, byProperty, ...values) => {
530
- if (typeof obj !== "object" || obj === null || !(byProperty in obj)) {
478
+ if (!isPropertyInObject(obj, byProperty)) {
531
479
  return obj;
532
480
  }
533
- const { [byProperty]: _byValue, ..._remaining } = /** @type {object} */ (obj);
534
- const remaining = /** @type {T} */ (_remaining);
535
- const byValue = /** @type {Record<string, T> | function(...any[]): T} */ (_byValue);
481
+ const { [byProperty]: _byValue, ..._remaining } = obj;
482
+ const remaining = _remaining;
483
+ const byValue = _byValue;
536
484
  if (typeof byValue === "object") {
537
485
  const key = values[0];
538
486
  if (key in byValue) {
539
- return cachedCleverMerge(remaining, byValue[key]);
540
- }
541
- else if ("default" in byValue) {
542
- return cachedCleverMerge(remaining, byValue.default);
487
+ return (0, exports.cachedCleverMerge)(remaining, byValue[key]);
543
488
  }
544
- else {
545
- return /** @type {T} */ (remaining);
489
+ if ("default" in byValue) {
490
+ return (0, exports.cachedCleverMerge)(remaining, byValue.default);
546
491
  }
492
+ return remaining;
547
493
  }
548
- else if (typeof byValue === "function") {
494
+ if (typeof byValue === "function") {
549
495
  const result = byValue.apply(null, values);
550
- return cachedCleverMerge(remaining, resolveByProperty(result, byProperty, ...values));
496
+ return (0, exports.cachedCleverMerge)(remaining, (0, exports.resolveByProperty)(result, byProperty, ...values));
551
497
  }
552
498
  };
553
- exports.cachedSetProperty = cachedSetProperty;
554
- exports.cachedCleverMerge = cachedCleverMerge;
555
- exports.cleverMerge = cleverMerge;
556
499
  exports.resolveByProperty = resolveByProperty;
557
- exports.removeOperations = removeOperations;
558
- exports.DELETE = DELETE;
500
+ function isPropertyInObject(obj, property) {
501
+ return typeof obj === "object" && obj !== null && property in obj;
502
+ }
@@ -86,12 +86,10 @@ const compareSelect = (getter, comparator) => {
86
86
  }
87
87
  return -1;
88
88
  }
89
- else {
90
- if (bValue !== undefined && bValue !== null) {
91
- return 1;
92
- }
93
- return 0;
89
+ if (bValue !== undefined && bValue !== null) {
90
+ return 1;
94
91
  }
92
+ return 0;
95
93
  };
96
94
  compareSelectCache.set(getter, comparator, result);
97
95
  return result;
@@ -7,9 +7,10 @@
7
7
  * Copyright (c) JS Foundation and other contributors
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
+ import Hash from "./hash";
10
11
  /**
11
12
  * Creates a hash by name or function
12
- * @param {string | typeof Hash} algorithm the algorithm name or a constructor creating a hash
13
- * @returns {Hash} the hash
13
+ * @param algorithm the algorithm name or a constructor creating a hash
14
+ * @returns the hash
14
15
  */
15
- export declare const createHash: (algorithm: any) => any;
16
+ export declare const createHash: (algorithm: "debug" | "xxhash64" | "md4" | "native-md4" | (string & {}) | (new () => Hash)) => Hash;