@rspack/core 1.0.0-beta.2 → 1.0.0-beta.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 (53) hide show
  1. package/dist/Compilation.d.ts +20 -1
  2. package/dist/Compilation.js +109 -44
  3. package/dist/Compiler.d.ts +1 -0
  4. package/dist/Compiler.js +29 -24
  5. package/dist/MultiCompiler.js +10 -6
  6. package/dist/MultiStats.d.ts +1 -1
  7. package/dist/MultiStats.js +19 -16
  8. package/dist/NormalModule.js +3 -4
  9. package/dist/Stats.d.ts +1 -1
  10. package/dist/Template.d.ts +4 -4
  11. package/dist/Template.js +6 -4
  12. package/dist/Watching.js +3 -5
  13. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +11 -10
  14. package/dist/builtin-plugin/DynamicEntryPlugin.js +26 -15
  15. package/dist/builtin-plugin/EntryPlugin.d.ts +2 -2
  16. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +21 -4
  17. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +29 -5
  18. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +4 -6
  19. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +16 -10
  20. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +11 -9
  21. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +10 -6
  22. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +1 -1
  23. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +2 -2
  24. package/dist/builtin-plugin/css-extract/loader.js +1 -2
  25. package/dist/config/adapter.d.ts +2 -2
  26. package/dist/config/zod.d.ts +338 -62
  27. package/dist/config/zod.js +8 -5
  28. package/dist/exports.d.ts +4 -3
  29. package/dist/exports.js +5 -2
  30. package/dist/lib/Cache.js +6 -4
  31. package/dist/lib/CacheFacade.js +8 -9
  32. package/dist/lib/LoaderOptionsPlugin.d.ts +4 -2
  33. package/dist/lib/LoaderOptionsPlugin.js +0 -2
  34. package/dist/lib/cache/mergeEtags.d.ts +3 -3
  35. package/dist/lib/cache/mergeEtags.js +5 -3
  36. package/dist/loader-runner/index.js +4 -2
  37. package/dist/node/nodeConsole.js +5 -5
  38. package/dist/stats/DefaultStatsPresetPlugin.js +1 -3
  39. package/dist/stats/StatsFactory.js +3 -4
  40. package/dist/stats/StatsPrinter.js +3 -4
  41. package/dist/stats/statsFactoryUtils.d.ts +106 -19
  42. package/dist/util/assertNotNil.d.ts +1 -1
  43. package/dist/util/assetCondition.d.ts +2 -0
  44. package/dist/util/assetCondition.js +2 -0
  45. package/dist/util/cleverMerge.js +5 -4
  46. package/dist/util/createHash.js +10 -5
  47. package/dist/util/hash/wasm-hash.js +5 -4
  48. package/dist/util/identifier.d.ts +4 -4
  49. package/dist/util/identifier.js +10 -10
  50. package/dist/util/memoize.js +3 -2
  51. package/package.json +3 -3
  52. package/dist/builtin-plugin/css-extract/loader-options.json +0 -37
  53. package/dist/builtin-plugin/css-extract/plugin-options.json +0 -79
@@ -167,6 +167,7 @@ export declare class Compilation {
167
167
  Set<string>
168
168
  ], void>;
169
169
  runtimeModule: RuntimeModule;
170
+ seal: liteTapable.SyncHook<[], void>;
170
171
  afterSeal: liteTapable.AsyncSeriesHook<[], void>;
171
172
  }>;
172
173
  name?: string;
@@ -210,6 +211,7 @@ export declare class Compilation {
210
211
  * Note: This is a proxy for webpack internal API, only method `get` and `keys` is supported now.
211
212
  */
212
213
  get namedChunks(): ReadonlyMap<string, Readonly<Chunk>>;
214
+ get entries(): Map<string, EntryData>;
213
215
  /**
214
216
  * Note: This is not a webpack public API, maybe removed in future.
215
217
  *
@@ -220,7 +222,7 @@ export declare class Compilation {
220
222
  buildMeta: Record<string, unknown>;
221
223
  };
222
224
  getCache(name: string): import("./lib/CacheFacade").CacheFacade;
223
- createStatsOptions(optionsOrPreset: StatsValue | undefined, context?: CreateStatsOptionsContext): NormalizedStatsOptions;
225
+ createStatsOptions(statsValue: StatsValue | undefined, context?: CreateStatsOptionsContext): NormalizedStatsOptions;
224
226
  createStatsFactory(options: StatsOptions): StatsFactory;
225
227
  createStatsPrinter(options: StatsOptions): StatsPrinter;
226
228
  /**
@@ -373,3 +375,20 @@ export declare class Compilation {
373
375
  static PROCESS_ASSETS_STAGE_ANALYSE: number;
374
376
  static PROCESS_ASSETS_STAGE_REPORT: number;
375
377
  }
378
+ export type EntryData = binding.JsEntryData;
379
+ export declare class Entries implements Map<string, EntryData> {
380
+ #private;
381
+ constructor(data: binding.JsEntries);
382
+ clear(): void;
383
+ forEach(callback: (value: binding.JsEntryData, key: string, map: Map<string, binding.JsEntryData>) => void, thisArg?: any): void;
384
+ get size(): number;
385
+ entries(): IterableIterator<[string, binding.JsEntryData]>;
386
+ values(): IterableIterator<binding.JsEntryData>;
387
+ [Symbol.iterator](): IterableIterator<[string, binding.JsEntryData]>;
388
+ get [Symbol.toStringTag](): string;
389
+ has(key: string): boolean;
390
+ set(key: string, value: EntryData): this;
391
+ delete(key: string): boolean;
392
+ get(key: string): EntryData | undefined;
393
+ keys(): IterableIterator<string>;
394
+ }
@@ -36,9 +36,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
36
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
- var _Compilation_instances, _Compilation_inner, _Compilation_customModules, _Compilation_createCachedAssets, _Compilation_rebuildModuleCaller;
39
+ var _Compilation_instances, _Compilation_inner, _Compilation_customModules, _Compilation_createCachedAssets, _Compilation_rebuildModuleCaller, _Entries_data;
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.Compilation = void 0;
41
+ exports.Entries = exports.Compilation = void 0;
42
42
  const binding_1 = require("@rspack/binding");
43
43
  const liteTapable = __importStar(require("@rspack/lite-tapable"));
44
44
  const Chunk_1 = require("./Chunk");
@@ -98,12 +98,14 @@ class Compilation {
98
98
  const errorMessage = (reason) => `Can't automatically convert plugin using Compilation.hooks.${name} to Compilation.hooks.processAssets because ${reason}.
99
99
  BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a single Compilation.hooks.processAssets hook.`;
100
100
  const getOptions = (options) => {
101
- if (typeof options === "string")
102
- options = { name: options };
103
- if (options.stage) {
101
+ const isString = typeof options === "string";
102
+ if (!isString && options.stage) {
104
103
  throw new Error(errorMessage("it's using the 'stage' option"));
105
104
  }
106
- return { ...options, stage: stage };
105
+ return {
106
+ ...(isString ? { name: options } : options),
107
+ stage: stage
108
+ };
107
109
  };
108
110
  return Object.freeze({
109
111
  name,
@@ -157,6 +159,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
157
159
  "runtimeRequirements"
158
160
  ]),
159
161
  runtimeModule: new liteTapable.SyncHook(["module", "chunk"]),
162
+ seal: new liteTapable.SyncHook([]),
160
163
  afterSeal: new liteTapable.AsyncSeriesHook([])
161
164
  };
162
165
  this.compiler = compiler;
@@ -237,6 +240,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
237
240
  }
238
241
  };
239
242
  }
243
+ get entries() {
244
+ return new Entries(__classPrivateFieldGet(this, _Compilation_inner, "f").entries);
245
+ }
240
246
  /**
241
247
  * Note: This is not a webpack public API, maybe removed in future.
242
248
  *
@@ -255,7 +261,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
255
261
  getCache(name) {
256
262
  return this.compiler.getCache(name);
257
263
  }
258
- createStatsOptions(optionsOrPreset, context = {}) {
264
+ createStatsOptions(statsValue, context = {}) {
265
+ let optionsOrPreset = statsValue;
259
266
  if (typeof optionsOrPreset === "boolean" ||
260
267
  typeof optionsOrPreset === "string") {
261
268
  optionsOrPreset = { preset: optionsOrPreset };
@@ -448,12 +455,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
448
455
  {
449
456
  method: "push",
450
457
  handler(target, thisArg, warns) {
451
- warns = processWarningsHook.call(warns);
452
- for (let i = 0; i < warns.length; i++) {
453
- const warn = warns[i];
458
+ return Reflect.apply(target, thisArg, processWarningsHook.call(warns).map(warn => {
454
459
  inner.pushDiagnostic(RspackError_1.JsDiagnostic.__to_binding(warn, binding_1.JsRspackSeverity.Warn));
455
- }
456
- return Reflect.apply(target, thisArg, warns);
460
+ return warn;
461
+ }));
457
462
  }
458
463
  },
459
464
  {
@@ -473,12 +478,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
473
478
  {
474
479
  method: "unshift",
475
480
  handler(target, thisArg, warns) {
476
- warns = processWarningsHook.call(warns);
477
- const warnList = warns.map(warn => {
481
+ const warnings = processWarningsHook.call(warns);
482
+ inner.spliceDiagnostic(0, 0, warnings.map(warn => {
478
483
  return RspackError_1.JsDiagnostic.__to_binding(warn, binding_1.JsRspackSeverity.Warn);
479
- });
480
- inner.spliceDiagnostic(0, 0, warnList);
481
- return Reflect.apply(target, thisArg, warns);
484
+ }));
485
+ return Reflect.apply(target, thisArg, warnings);
482
486
  }
483
487
  },
484
488
  {
@@ -521,11 +525,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
521
525
  if (!name) {
522
526
  throw new TypeError("Compilation.getLogger(name) called without a name");
523
527
  }
528
+ let logName = name;
524
529
  let logEntries;
525
530
  return new Logger_1.Logger((type, args) => {
526
- if (typeof name === "function") {
527
- name = name();
528
- if (!name) {
531
+ if (typeof logName === "function") {
532
+ logName = logName();
533
+ if (!logName) {
529
534
  throw new TypeError("Compilation.getLogger(name) called with a function not returning a name");
530
535
  }
531
536
  }
@@ -545,67 +550,68 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
545
550
  args,
546
551
  trace
547
552
  };
548
- if (this.hooks.log.call(name, logEntry) === undefined) {
553
+ if (this.hooks.log.call(logName, logEntry) === undefined) {
549
554
  if (logEntry.type === Logger_1.LogType.profileEnd) {
550
555
  if (typeof console.profileEnd === "function") {
551
- console.profileEnd(`[${name}] ${logEntry.args[0]}`);
556
+ console.profileEnd(`[${logName}] ${logEntry.args[0]}`);
552
557
  }
553
558
  }
554
559
  if (logEntries === undefined) {
555
- logEntries = this.logging.get(name);
560
+ logEntries = this.logging.get(logName);
556
561
  if (logEntries === undefined) {
557
562
  logEntries = [];
558
- this.logging.set(name, logEntries);
563
+ this.logging.set(logName, logEntries);
559
564
  }
560
565
  }
561
566
  logEntries.push(logEntry);
562
567
  if (logEntry.type === Logger_1.LogType.profile) {
563
568
  if (typeof console.profile === "function") {
564
- console.profile(`[${name}] ${logEntry.args[0]}`);
569
+ console.profile(`[${logName}] ${logEntry.args[0]}`);
565
570
  }
566
571
  }
567
572
  }
568
573
  }, (childName) => {
569
- if (typeof name === "function") {
570
- if (typeof childName === "function") {
574
+ let normalizedChildName = childName;
575
+ if (typeof logName === "function") {
576
+ if (typeof normalizedChildName === "function") {
571
577
  return this.getLogger(() => {
572
- if (typeof name === "function") {
573
- name = name();
574
- if (!name) {
578
+ if (typeof logName === "function") {
579
+ logName = logName();
580
+ if (!logName) {
575
581
  throw new TypeError("Compilation.getLogger(name) called with a function not returning a name");
576
582
  }
577
583
  }
578
- if (typeof childName === "function") {
579
- childName = childName();
580
- if (!childName) {
584
+ if (typeof normalizedChildName === "function") {
585
+ normalizedChildName = normalizedChildName();
586
+ if (!normalizedChildName) {
581
587
  throw new TypeError("Logger.getChildLogger(name) called with a function not returning a name");
582
588
  }
583
589
  }
584
- return `${name}/${childName}`;
590
+ return `${logName}/${normalizedChildName}`;
585
591
  });
586
592
  }
587
593
  return this.getLogger(() => {
588
- if (typeof name === "function") {
589
- name = name();
590
- if (!name) {
594
+ if (typeof logName === "function") {
595
+ logName = logName();
596
+ if (!logName) {
591
597
  throw new TypeError("Compilation.getLogger(name) called with a function not returning a name");
592
598
  }
593
599
  }
594
- return `${name}/${childName}`;
600
+ return `${logName}/${normalizedChildName}`;
595
601
  });
596
602
  }
597
- if (typeof childName === "function") {
603
+ if (typeof normalizedChildName === "function") {
598
604
  return this.getLogger(() => {
599
- if (typeof childName === "function") {
600
- childName = childName();
601
- if (!childName) {
605
+ if (typeof normalizedChildName === "function") {
606
+ normalizedChildName = normalizedChildName();
607
+ if (!normalizedChildName) {
602
608
  throw new TypeError("Logger.getChildLogger(name) called with a function not returning a name");
603
609
  }
604
610
  }
605
- return `${name}/${childName}`;
611
+ return `${logName}/${normalizedChildName}`;
606
612
  });
607
613
  }
608
- return this.getLogger(`${name}/${childName}`);
614
+ return this.getLogger(`${logName}/${normalizedChildName}`);
609
615
  });
610
616
  }
611
617
  getStats() {
@@ -759,3 +765,62 @@ Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER = 3000;
759
765
  Compilation.PROCESS_ASSETS_STAGE_ANALYSE = 4000;
760
766
  Compilation.PROCESS_ASSETS_STAGE_REPORT = 5000;
761
767
  exports.Compilation = Compilation;
768
+ class Entries {
769
+ constructor(data) {
770
+ _Entries_data.set(this, void 0);
771
+ __classPrivateFieldSet(this, _Entries_data, data, "f");
772
+ }
773
+ clear() {
774
+ __classPrivateFieldGet(this, _Entries_data, "f").clear();
775
+ }
776
+ forEach(callback, thisArg) {
777
+ for (const [key, value] of this) {
778
+ callback.call(thisArg, value, key, this);
779
+ }
780
+ }
781
+ get size() {
782
+ return __classPrivateFieldGet(this, _Entries_data, "f").size;
783
+ }
784
+ entries() {
785
+ const self = this;
786
+ const keys = this.keys();
787
+ return {
788
+ [Symbol.iterator]() {
789
+ return this;
790
+ },
791
+ next() {
792
+ const { done, value } = keys.next();
793
+ return {
794
+ done,
795
+ value: done ? undefined : [value, self.get(value)]
796
+ };
797
+ }
798
+ };
799
+ }
800
+ values() {
801
+ return __classPrivateFieldGet(this, _Entries_data, "f").values()[Symbol.iterator]();
802
+ }
803
+ [(_Entries_data = new WeakMap(), Symbol.iterator)]() {
804
+ return this.entries();
805
+ }
806
+ get [Symbol.toStringTag]() {
807
+ return "Map";
808
+ }
809
+ has(key) {
810
+ return __classPrivateFieldGet(this, _Entries_data, "f").has(key);
811
+ }
812
+ set(key, value) {
813
+ __classPrivateFieldGet(this, _Entries_data, "f").set(key, value);
814
+ return this;
815
+ }
816
+ delete(key) {
817
+ return __classPrivateFieldGet(this, _Entries_data, "f").delete(key);
818
+ }
819
+ get(key) {
820
+ return __classPrivateFieldGet(this, _Entries_data, "f").get(key);
821
+ }
822
+ keys() {
823
+ return __classPrivateFieldGet(this, _Entries_data, "f").keys()[Symbol.iterator]();
824
+ }
825
+ }
826
+ exports.Entries = Entries;
@@ -69,6 +69,7 @@ declare class Compiler {
69
69
  entryOption: liteTapable.SyncBailHook<[string, EntryNormalized], any>;
70
70
  };
71
71
  webpack: typeof rspack;
72
+ rspack: typeof rspack;
72
73
  name?: string;
73
74
  parentCompilation?: Compilation;
74
75
  root: Compiler;
package/dist/Compiler.js CHANGED
@@ -137,6 +137,7 @@ class Compiler {
137
137
  entryOption: new liteTapable.SyncBailHook(["context", "entry"])
138
138
  };
139
139
  this.webpack = index_1.rspack;
140
+ this.rspack = index_1.rspack;
140
141
  this.root = this;
141
142
  this.outputPath = "";
142
143
  this.inputFileSystem = null;
@@ -199,62 +200,65 @@ class Compiler {
199
200
  if (!name) {
200
201
  throw new TypeError("Compiler.getInfrastructureLogger(name) called without a name");
201
202
  }
203
+ let normalizedName = name;
202
204
  return new Logger_1.Logger((type, args) => {
203
- if (typeof name === "function") {
204
- name = name();
205
- if (!name) {
205
+ if (typeof normalizedName === "function") {
206
+ normalizedName = normalizedName();
207
+ if (!normalizedName) {
206
208
  throw new TypeError("Compiler.getInfrastructureLogger(name) called with a function not returning a name");
207
209
  }
208
210
  }
209
211
  else {
210
- if (this.hooks.infrastructureLog.call(name, type, args) === undefined) {
212
+ if (this.hooks.infrastructureLog.call(normalizedName, type, args) ===
213
+ undefined) {
211
214
  if (this.infrastructureLogger !== undefined) {
212
- this.infrastructureLogger(name, type, args);
215
+ this.infrastructureLogger(normalizedName, type, args);
213
216
  }
214
217
  }
215
218
  }
216
219
  }, (childName) => {
217
- if (typeof name === "function") {
218
- if (typeof childName === "function") {
220
+ let normalizedChildName = childName;
221
+ if (typeof normalizedName === "function") {
222
+ if (typeof normalizedChildName === "function") {
219
223
  // @ts-expect-error
220
224
  return this.getInfrastructureLogger(_ => {
221
- if (typeof name === "function") {
222
- name = name();
223
- if (!name) {
225
+ if (typeof normalizedName === "function") {
226
+ normalizedName = normalizedName();
227
+ if (!normalizedName) {
224
228
  throw new TypeError("Compiler.getInfrastructureLogger(name) called with a function not returning a name");
225
229
  }
226
230
  }
227
- if (typeof childName === "function") {
228
- childName = childName();
229
- if (!childName) {
231
+ if (typeof normalizedChildName === "function") {
232
+ normalizedChildName = normalizedChildName();
233
+ if (!normalizedChildName) {
230
234
  throw new TypeError("Logger.getChildLogger(name) called with a function not returning a name");
231
235
  }
232
236
  }
233
- return `${name}/${childName}`;
237
+ return `${normalizedName}/${normalizedChildName}`;
234
238
  });
235
239
  }
236
240
  return this.getInfrastructureLogger(() => {
237
- if (typeof name === "function") {
238
- name = name();
239
- if (!name) {
241
+ if (typeof normalizedName === "function") {
242
+ normalizedName = normalizedName();
243
+ if (!normalizedName) {
240
244
  throw new TypeError("Compiler.getInfrastructureLogger(name) called with a function not returning a name");
241
245
  }
242
246
  }
243
- return `${name}/${childName}`;
247
+ return `${normalizedName}/${normalizedChildName}`;
244
248
  });
245
249
  }
246
- if (typeof childName === "function") {
250
+ if (typeof normalizedChildName === "function") {
247
251
  return this.getInfrastructureLogger(() => {
248
- if (typeof childName === "function") {
249
- childName = childName();
250
- if (!childName) {
252
+ if (typeof normalizedChildName === "function") {
253
+ normalizedChildName = normalizedChildName();
254
+ if (!normalizedChildName) {
251
255
  throw new TypeError("Logger.getChildLogger(name) called with a function not returning a name");
252
256
  }
253
257
  }
254
- return `${name}/${childName}`;
258
+ return `${normalizedName}/${normalizedChildName}`;
255
259
  });
256
260
  }
257
- return this.getInfrastructureLogger(`${name}/${childName}`);
261
+ return this.getInfrastructureLogger(`${normalizedName}/${normalizedChildName}`);
258
262
  });
259
263
  }
260
264
  /**
@@ -665,6 +669,7 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
665
669
  registerCompilationChunkAssetTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationChunkAsset, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.chunkAsset, queried => ({ chunk, filename }) => queried.call(Chunk_1.Chunk.__from_binding(chunk, __classPrivateFieldGet(this, _Compiler_compilation, "f")), filename)),
666
670
  registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationProcessAssets, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.processAssets, queried => async () => await queried.promise(__classPrivateFieldGet(this, _Compiler_compilation, "f").assets)),
667
671
  registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterProcessAssets, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.afterProcessAssets, queried => () => queried.call(__classPrivateFieldGet(this, _Compiler_compilation, "f").assets)),
672
+ registerCompilationSealTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationSeal, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.seal, queried => () => queried.call()),
668
673
  registerCompilationAfterSealTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterSeal, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.afterSeal, queried => async () => await queried.promise()),
669
674
  registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryBeforeResolve, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
670
675
  const normalizedResolveData = {
@@ -51,21 +51,25 @@ const ArrayQueue_1 = __importDefault(require("./util/ArrayQueue"));
51
51
  class MultiCompiler {
52
52
  constructor(compilers, options) {
53
53
  _MultiCompiler_instances.add(this);
54
+ let normalizedCompilers;
54
55
  if (!Array.isArray(compilers)) {
55
- compilers = Object.entries(compilers).map(([name, compiler]) => {
56
+ normalizedCompilers = Object.entries(compilers).map(([name, compiler]) => {
56
57
  compiler.name = name;
57
58
  return compiler;
58
59
  });
59
60
  }
61
+ else {
62
+ normalizedCompilers = compilers;
63
+ }
60
64
  this.hooks = {
61
65
  done: new liteTapable.SyncHook(["stats"]),
62
- invalid: new liteTapable.MultiHook(compilers.map(c => c.hooks.invalid)),
63
- run: new liteTapable.MultiHook(compilers.map(c => c.hooks.run)),
66
+ invalid: new liteTapable.MultiHook(normalizedCompilers.map(c => c.hooks.invalid)),
67
+ run: new liteTapable.MultiHook(normalizedCompilers.map(c => c.hooks.run)),
64
68
  watchClose: new liteTapable.SyncHook([]),
65
- watchRun: new liteTapable.MultiHook(compilers.map(c => c.hooks.watchRun)),
66
- infrastructureLog: new liteTapable.MultiHook(compilers.map(c => c.hooks.infrastructureLog))
69
+ watchRun: new liteTapable.MultiHook(normalizedCompilers.map(c => c.hooks.watchRun)),
70
+ infrastructureLog: new liteTapable.MultiHook(normalizedCompilers.map(c => c.hooks.infrastructureLog))
67
71
  };
68
- this.compilers = compilers;
72
+ this.compilers = normalizedCompilers;
69
73
  this._options = {
70
74
  parallelism: options?.parallelism || Number.POSITIVE_INFINITY
71
75
  };
@@ -16,7 +16,7 @@ export default class MultiStats {
16
16
  get hash(): string;
17
17
  hasErrors(): boolean;
18
18
  hasWarnings(): boolean;
19
- toJson(options?: any): StatsCompilation;
19
+ toJson(options: any): StatsCompilation;
20
20
  toString(options: any): string;
21
21
  }
22
22
  export { MultiStats };
@@ -56,21 +56,23 @@ class MultiStats {
56
56
  return this.stats.some(stat => stat.hasWarnings());
57
57
  }
58
58
  toJson(options) {
59
- options = __classPrivateFieldGet(this, _MultiStats_instances, "m", _MultiStats_createChildOptions).call(this, options, { forToString: false });
59
+ const childOptions = __classPrivateFieldGet(this, _MultiStats_instances, "m", _MultiStats_createChildOptions).call(this, options || {}, {
60
+ forToString: false
61
+ });
60
62
  const obj = {};
61
63
  obj.children = this.stats.map((stat, idx) => {
62
- const obj = stat.toJson(options.children[idx]);
64
+ const obj = stat.toJson(childOptions.children[idx]);
63
65
  const compilationName = stat.compilation.name;
64
66
  const name = compilationName &&
65
- identifierUtils.makePathsRelative(options.context, compilationName, stat.compilation.compiler.root);
67
+ identifierUtils.makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root);
66
68
  obj.name = name;
67
69
  return obj;
68
70
  });
69
- if (options.version) {
71
+ if (childOptions.version) {
70
72
  obj.rspackVersion = require("../package.json").version;
71
73
  obj.version = require("../package.json").webpackVersion;
72
74
  }
73
- if (options.hash) {
75
+ if (childOptions.hash) {
74
76
  obj.hash = obj.children.map(j => j.hash).join("");
75
77
  }
76
78
  const mapError = (j, obj) => {
@@ -81,7 +83,7 @@ class MultiStats {
81
83
  : j.name
82
84
  };
83
85
  };
84
- if (options.errors) {
86
+ if (childOptions.errors) {
85
87
  obj.errors = [];
86
88
  for (const j of obj.children) {
87
89
  for (const i of j.errors || []) {
@@ -89,7 +91,7 @@ class MultiStats {
89
91
  }
90
92
  }
91
93
  }
92
- if (options.warnings) {
94
+ if (childOptions.warnings) {
93
95
  obj.warnings = [];
94
96
  for (const j of obj.children) {
95
97
  for (const i of j.warnings || []) {
@@ -97,13 +99,13 @@ class MultiStats {
97
99
  }
98
100
  }
99
101
  }
100
- if (options.errorsCount) {
102
+ if (childOptions.errorsCount) {
101
103
  obj.errorsCount = 0;
102
104
  for (const j of obj.children) {
103
105
  obj.errorsCount += j.errorsCount || 0;
104
106
  }
105
107
  }
106
- if (options.warningsCount) {
108
+ if (childOptions.warningsCount) {
107
109
  obj.warningsCount = 0;
108
110
  for (const j of obj.children) {
109
111
  obj.warningsCount += j.warningsCount || 0;
@@ -112,13 +114,15 @@ class MultiStats {
112
114
  return obj;
113
115
  }
114
116
  toString(options) {
115
- options = __classPrivateFieldGet(this, _MultiStats_instances, "m", _MultiStats_createChildOptions).call(this, options, { forToString: true });
117
+ const childOptions = __classPrivateFieldGet(this, _MultiStats_instances, "m", _MultiStats_createChildOptions).call(this, options || {}, {
118
+ forToString: true
119
+ });
116
120
  const results = this.stats.map((stat, idx) => {
117
- const str = stat.toString(options.children[idx]);
121
+ const str = stat.toString(childOptions.children[idx]);
118
122
  const compilationName = stat.compilation.name;
119
123
  const name = compilationName &&
120
124
  identifierUtils
121
- .makePathsRelative(options.context, compilationName, stat.compilation.compiler.root)
125
+ .makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root)
122
126
  .replace(/\|/g, " ");
123
127
  if (!str)
124
128
  return str;
@@ -130,9 +134,6 @@ class MultiStats {
130
134
  exports.default = MultiStats;
131
135
  exports.MultiStats = MultiStats;
132
136
  _MultiStats_instances = new WeakSet(), _MultiStats_createChildOptions = function _MultiStats_createChildOptions(options, context) {
133
- if (!options) {
134
- options = {};
135
- }
136
137
  const { children: childrenOptions = undefined, ...baseOptions } = typeof options === "string" ? { preset: options } : options;
137
138
  const children = this.stats.map((stat, idx) => {
138
139
  const childOptions = Array.isArray(childrenOptions)
@@ -153,6 +154,8 @@ _MultiStats_instances = new WeakSet(), _MultiStats_createChildOptions = function
153
154
  warningsCount: children.every(o => o.warningsCount),
154
155
  errors: children.every(o => o.errors),
155
156
  warnings: children.every(o => o.warnings),
156
- children
157
+ children,
158
+ context: "",
159
+ version: ""
157
160
  };
158
161
  };
@@ -32,10 +32,9 @@ const liteTapable = __importStar(require("@rspack/lite-tapable"));
32
32
  const Compilation_1 = require("./Compilation");
33
33
  const compilationHooksMap = new WeakMap();
34
34
  const createFakeHook = (fakeHook, message, code) => {
35
- if (message && code) {
36
- fakeHook = deprecateAllProperties(fakeHook, message, code);
37
- }
38
- return Object.freeze(Object.assign(fakeHook, { _fakeHook: true }));
35
+ return Object.freeze(Object.assign(message && code
36
+ ? deprecateAllProperties(fakeHook, message, code)
37
+ : fakeHook, { _fakeHook: true }));
39
38
  };
40
39
  const deprecateAllProperties = (obj, message, code) => {
41
40
  const newObj = {};
package/dist/Stats.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Compilation } from "./Compilation";
2
2
  import type { StatsOptions, StatsValue } from "./config";
3
3
  import type { StatsCompilation } from "./stats/statsFactoryUtils";
4
- export type { StatsAsset, StatsChunk, StatsCompilation, StatsError, StatsModule, StatsWarnings } from "./stats/statsFactoryUtils";
4
+ export type { StatsAsset, StatsChunk, StatsCompilation, StatsError, StatsModule } from "./stats/statsFactoryUtils";
5
5
  export declare class Stats {
6
6
  #private;
7
7
  compilation: Compilation;
@@ -37,15 +37,15 @@ declare class Template {
37
37
  */
38
38
  static toPath(str: string): string;
39
39
  /**
40
- * @param n number to convert to ident
40
+ * @param num number to convert to ident
41
41
  * @returns returns single character ident
42
42
  */
43
- static numberToIdentifier(n: number): string;
43
+ static numberToIdentifier(num: number): string;
44
44
  /**
45
- * @param n number to convert to ident
45
+ * @param num number to convert to ident
46
46
  * @returns returns single character ident
47
47
  */
48
- static numberToIdentifierContinuation(n: number): string;
48
+ static numberToIdentifierContinuation(num: number): string;
49
49
  /**
50
50
  *
51
51
  * @param s string to convert to identity
package/dist/Template.js CHANGED
@@ -80,10 +80,11 @@ class Template {
80
80
  }
81
81
  // map number to a single character a-z, A-Z or multiple characters if number is too big
82
82
  /**
83
- * @param n number to convert to ident
83
+ * @param num number to convert to ident
84
84
  * @returns returns single character ident
85
85
  */
86
- static numberToIdentifier(n) {
86
+ static numberToIdentifier(num) {
87
+ let n = num;
87
88
  if (n >= NUMBER_OF_IDENTIFIER_START_CHARS) {
88
89
  // use multiple letters
89
90
  return (Template.numberToIdentifier(n % NUMBER_OF_IDENTIFIER_START_CHARS) +
@@ -103,10 +104,11 @@ class Template {
103
104
  return "$";
104
105
  }
105
106
  /**
106
- * @param n number to convert to ident
107
+ * @param num number to convert to ident
107
108
  * @returns returns single character ident
108
109
  */
109
- static numberToIdentifierContinuation(n) {
110
+ static numberToIdentifierContinuation(num) {
111
+ let n = num;
110
112
  if (n >= NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS) {
111
113
  // use multiple letters
112
114
  return (Template.numberToIdentifierContinuation(n % NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS) +