@rspack/core 1.0.0-alpha.2 → 1.0.0-alpha.4

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 (166) hide show
  1. package/compiled/browserslist/index.js +17 -17
  2. package/compiled/enhanced-resolve/index.js +107 -107
  3. package/compiled/graceful-fs/index.js +8 -8
  4. package/compiled/json-parse-even-better-errors/index.js +2 -2
  5. package/compiled/neo-async/index.js +2 -2
  6. package/compiled/watchpack/index.js +15 -15
  7. package/compiled/webpack-sources/index.js +76 -76
  8. package/compiled/zod/index.js +30 -30
  9. package/compiled/zod-validation-error/index.js +6 -6
  10. package/dist/ChunkGraph.d.ts +1 -1
  11. package/dist/Compilation.d.ts +9 -9
  12. package/dist/Compilation.js +27 -24
  13. package/dist/Compiler.d.ts +6 -6
  14. package/dist/Compiler.js +5 -6
  15. package/dist/ContextModuleFactory.d.ts +1 -1
  16. package/dist/ErrorHelpers.d.ts +16 -7
  17. package/dist/ErrorHelpers.js +34 -33
  18. package/dist/ExecuteModulePlugin.js +1 -1
  19. package/dist/FileSystem.d.ts +2 -2
  20. package/dist/Module.d.ts +5 -5
  21. package/dist/Module.js +3 -6
  22. package/dist/MultiCompiler.d.ts +3 -3
  23. package/dist/MultiCompiler.js +1 -1
  24. package/dist/MultiStats.d.ts +2 -2
  25. package/dist/MultiWatching.d.ts +2 -2
  26. package/dist/NormalModule.d.ts +1 -1
  27. package/dist/NormalModuleFactory.d.ts +1 -1
  28. package/dist/Resolver.d.ts +19 -0
  29. package/dist/Resolver.js +39 -0
  30. package/dist/ResolverFactory.d.ts +12 -46
  31. package/dist/ResolverFactory.js +55 -120
  32. package/dist/RspackError.d.ts +1 -1
  33. package/dist/RuntimeGlobals.d.ts +1 -1
  34. package/dist/RuntimeGlobals.js +3 -3
  35. package/dist/Stats.d.ts +2 -2
  36. package/dist/Stats.js +4 -4
  37. package/dist/Template.js +2 -2
  38. package/dist/Watching.d.ts +3 -3
  39. package/dist/builtin-loader/swc/index.d.ts +0 -2
  40. package/dist/builtin-loader/swc/index.js +1 -3
  41. package/dist/builtin-loader/swc/pluginImport.d.ts +17 -1
  42. package/dist/builtin-loader/swc/react.d.ts +11 -1
  43. package/dist/builtin-plugin/APIPlugin.d.ts +3 -3
  44. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +3 -3
  45. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +3 -3
  46. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +3 -3
  47. package/dist/builtin-plugin/BannerPlugin.d.ts +25 -4
  48. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +4 -4
  49. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +3 -3
  50. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +3 -3
  51. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +4 -4
  52. package/dist/builtin-plugin/CssModulesPlugin.d.ts +3 -3
  53. package/dist/builtin-plugin/DataUriPlugin.d.ts +3 -3
  54. package/dist/builtin-plugin/DefinePlugin.d.ts +10 -4
  55. package/dist/builtin-plugin/DefinePlugin.js +42 -8
  56. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +3 -3
  57. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +3 -3
  58. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +5 -5
  59. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +3 -3
  60. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +3 -3
  61. package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +2 -2
  62. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +3 -3
  63. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +3 -3
  64. package/dist/builtin-plugin/EntryPlugin.d.ts +5 -5
  65. package/dist/builtin-plugin/EntryPlugin.js +1 -1
  66. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +4 -4
  67. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +5 -5
  68. package/dist/builtin-plugin/ExternalsPlugin.d.ts +22 -6
  69. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +3 -3
  70. package/dist/builtin-plugin/FileUriPlugin.d.ts +3 -3
  71. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +3 -3
  72. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +3 -3
  73. package/dist/builtin-plugin/HotModuleReplacementPlugin.d.ts +2 -2
  74. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +19 -4
  75. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +4 -4
  76. package/dist/builtin-plugin/IgnorePlugin.d.ts +4 -4
  77. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +3 -3
  78. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +2 -2
  79. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +4 -4
  80. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +3 -3
  81. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +4 -4
  82. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +4 -4
  83. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +3 -3
  84. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +3 -3
  85. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +3 -3
  86. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +3 -3
  87. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +3 -3
  88. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +3 -3
  89. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +3 -3
  90. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +3 -3
  91. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +3 -3
  92. package/dist/builtin-plugin/ProgressPlugin.d.ts +4 -4
  93. package/dist/builtin-plugin/ProvidePlugin.d.ts +3 -3
  94. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +3 -3
  95. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +3 -3
  96. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +4 -4
  97. package/dist/builtin-plugin/RuntimePlugin.d.ts +3 -3
  98. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +3 -3
  99. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +9 -4
  100. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +4 -4
  101. package/dist/builtin-plugin/SplitChunksPlugin.d.ts +3 -3
  102. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +12 -4
  103. package/dist/builtin-plugin/SwcCssMinimizerPlugin.js +7 -1
  104. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +4 -4
  105. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +2 -2
  106. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +3 -3
  107. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +3 -3
  108. package/dist/builtin-plugin/WorkerPlugin.d.ts +3 -3
  109. package/dist/builtin-plugin/WorkerPlugin.js +5 -1
  110. package/dist/builtin-plugin/base.d.ts +6 -6
  111. package/dist/builtin-plugin/base.js +4 -4
  112. package/dist/builtin-plugin/css-extract/index.d.ts +1 -1
  113. package/dist/builtin-plugin/css-extract/loader.js +15 -5
  114. package/dist/builtin-plugin/css-extract/utils.d.ts +1 -1
  115. package/dist/builtin-plugin/index.d.ts +1 -7
  116. package/dist/builtin-plugin/index.js +3 -17
  117. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +11 -17
  118. package/dist/builtin-plugin/lazy-compilation/plugin.d.ts +2 -2
  119. package/dist/config/adapter.d.ts +5 -4
  120. package/dist/config/adapter.js +23 -11
  121. package/dist/config/adapterRuleUse.d.ts +7 -7
  122. package/dist/config/adapterRuleUse.js +1 -1
  123. package/dist/config/browserslistTargetHandler.js +1 -1
  124. package/dist/config/defaults.d.ts +1 -1
  125. package/dist/config/defaults.js +4 -3
  126. package/dist/config/zod.d.ts +491 -384
  127. package/dist/config/zod.js +44 -42
  128. package/dist/container/ContainerPlugin.d.ts +3 -3
  129. package/dist/container/ContainerReferencePlugin.d.ts +4 -4
  130. package/dist/container/ModuleFederationPlugin.d.ts +2 -2
  131. package/dist/container/ModuleFederationPlugin.js +2 -2
  132. package/dist/container/ModuleFederationPluginV1.d.ts +5 -5
  133. package/dist/container/ModuleFederationRuntimePlugin.d.ts +3 -3
  134. package/dist/container/default.runtime.js +1 -1
  135. package/dist/lib/EntryOptionPlugin.d.ts +2 -2
  136. package/dist/lib/NormalModuleReplacementPlugin.d.ts +2 -2
  137. package/dist/loader-runner/index.d.ts +2 -2
  138. package/dist/loader-runner/index.js +38 -51
  139. package/dist/loader-runner/loadLoader.js +1 -1
  140. package/dist/logging/runtime.js +1 -1
  141. package/dist/node/NodeTemplatePlugin.d.ts +1 -1
  142. package/dist/node/NodeWatchFileSystem.d.ts +1 -1
  143. package/dist/rspack.d.ts +3 -3
  144. package/dist/rspack.js +1 -1
  145. package/dist/rspackOptionsApply.d.ts +1 -1
  146. package/dist/rspackOptionsApply.js +1 -19
  147. package/dist/sharing/ConsumeSharedPlugin.d.ts +2 -2
  148. package/dist/sharing/ConsumeSharedPlugin.js +1 -1
  149. package/dist/sharing/ProvideSharedPlugin.d.ts +2 -2
  150. package/dist/sharing/SharePlugin.d.ts +1 -1
  151. package/dist/sharing/ShareRuntimePlugin.d.ts +2 -2
  152. package/dist/stats/DefaultStatsFactoryPlugin.js +246 -46
  153. package/dist/stats/DefaultStatsPresetPlugin.js +17 -17
  154. package/dist/stats/DefaultStatsPrinterPlugin.js +1 -1
  155. package/dist/stats/StatsFactory.d.ts +2 -2
  156. package/dist/stats/statsFactoryUtils.d.ts +16 -1
  157. package/dist/util/SplitChunkSize.d.ts +1 -1
  158. package/dist/util/bindingVersionCheck.js +1 -1
  159. package/dist/util/comparators.d.ts +1 -1
  160. package/dist/util/fs.d.ts +1 -1
  161. package/dist/util/identifier.d.ts +65 -62
  162. package/dist/util/identifier.js +30 -55
  163. package/dist/util/index.d.ts +1 -1
  164. package/dist/util/index.js +4 -2
  165. package/dist/util/validate.d.ts +1 -1
  166. package/package.json +7 -34
@@ -1,4 +1,4 @@
1
- import { Compiler } from "../Compiler";
1
+ import type { Compiler } from "../Compiler";
2
2
  export type SharePluginOptions = {
3
3
  shareScope?: string;
4
4
  shared: Shared;
@@ -1,5 +1,5 @@
1
- import { BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
2
- import { Compiler } from "../Compiler";
1
+ import { type BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
2
+ import type { Compiler } from "../Compiler";
3
3
  import { RspackBuiltinPlugin } from "../builtin-plugin/base";
4
4
  export declare class ShareRuntimePlugin extends RspackBuiltinPlugin {
5
5
  private enhanced;
@@ -57,22 +57,14 @@ const ITEM_NAMES = {
57
57
  "module.issuerPath[]": "moduleIssuer",
58
58
  "module.reasons[]": "moduleReason",
59
59
  "module.modules[]": "module",
60
- "module.children[]": "module"
61
- // "moduleTrace[]": "moduleTraceItem",
60
+ "module.children[]": "module",
61
+ "moduleTrace[]": "moduleTraceItem"
62
62
  // "moduleTraceItem.dependencies[]": "moduleTraceDependency"
63
63
  };
64
- // const MERGER: Record<
65
- // string,
66
- // (
67
- // items: {
68
- // [key: string]: any;
69
- // name: string;
70
- // }[]
71
- // ) => any
72
- // > = {
73
- // "compilation.entrypoints": mergeToObject,
74
- // "compilation.namedChunkGroups": mergeToObject
75
- // };
64
+ const MERGER = {
65
+ "compilation.entrypoints": statsFactoryUtils_1.mergeToObject,
66
+ "compilation.namedChunkGroups": statsFactoryUtils_1.mergeToObject
67
+ };
76
68
  const ASSETS_GROUPERS = {
77
69
  _: (groupConfigs, context, options) => {
78
70
  const groupByFlag = (name, exclude) => {
@@ -149,10 +141,74 @@ const ASSETS_GROUPERS = {
149
141
  }
150
142
  });
151
143
  }
144
+ },
145
+ groupAssetsByInfo: groupConfigs => {
146
+ const groupByAssetInfoFlag = (name) => {
147
+ groupConfigs.push({
148
+ getKeys: asset => {
149
+ return asset.info && asset.info[name] ? ["1"] : undefined;
150
+ },
151
+ // @ts-expect-error
152
+ createGroup: (key, children) => {
153
+ return {
154
+ type: "assets by info",
155
+ info: {
156
+ [name]: !!key
157
+ },
158
+ children,
159
+ ...(0, statsFactoryUtils_1.assetGroup)(children)
160
+ };
161
+ }
162
+ });
163
+ };
164
+ groupByAssetInfoFlag("immutable");
165
+ groupByAssetInfoFlag("development");
166
+ groupByAssetInfoFlag("hotModuleReplacement");
167
+ },
168
+ groupAssetsByChunk: groupConfigs => {
169
+ const groupByNames = (name) => {
170
+ groupConfigs.push({
171
+ getKeys: asset => {
172
+ return asset[name];
173
+ },
174
+ // @ts-expect-error
175
+ createGroup: (key, children) => {
176
+ return {
177
+ type: "assets by chunk",
178
+ [name]: [key],
179
+ children,
180
+ ...(0, statsFactoryUtils_1.assetGroup)(children)
181
+ };
182
+ }
183
+ });
184
+ };
185
+ groupByNames("chunkNames");
186
+ // groupByNames("auxiliaryChunkNames");
187
+ // groupByNames("chunkIdHints");
188
+ // groupByNames("auxiliaryChunkIdHints");
189
+ },
190
+ excludeAssets: (groupConfigs, context, { excludeAssets }) => {
191
+ groupConfigs.push({
192
+ getKeys: asset => {
193
+ const ident = asset.name;
194
+ const excluded = excludeAssets.some(fn => fn(ident, asset));
195
+ if (excluded)
196
+ return ["excluded"];
197
+ },
198
+ getOptions: () => ({
199
+ groupChildren: false,
200
+ force: true
201
+ }),
202
+ // @ts-expect-error
203
+ createGroup: (key, children, assets) => ({
204
+ type: "hidden assets",
205
+ filteredChildren: assets.length,
206
+ ...(0, statsFactoryUtils_1.assetGroup)(children)
207
+ })
208
+ });
152
209
  }
153
- // not support groupAssetsByInfo / groupAssetsByChunk / excludeAssets
154
210
  };
155
- const MODULES_GROUPERS = (_type) => ({
211
+ const MODULES_GROUPERS = (type) => ({
156
212
  _: (groupConfigs, context, options) => {
157
213
  const groupByFlag = (name, type, exclude) => {
158
214
  groupConfigs.push({
@@ -176,7 +232,7 @@ const MODULES_GROUPERS = (_type) => ({
176
232
  }
177
233
  });
178
234
  };
179
- const { groupModulesByCacheStatus, groupModulesByAttributes, groupModulesByType } = options;
235
+ const { groupModulesByCacheStatus, groupModulesByAttributes, groupModulesByType, groupModulesByPath, groupModulesByExtension } = options;
180
236
  if (groupModulesByAttributes) {
181
237
  groupByFlag("errors", "modules with errors");
182
238
  groupByFlag("warnings", "modules with warnings");
@@ -228,9 +284,76 @@ const MODULES_GROUPERS = (_type) => ({
228
284
  }
229
285
  });
230
286
  }
231
- // not support groupModulesByLayer / groupModulesByPath / groupModulesByExtension
287
+ // not support groupModulesByLayer
288
+ if (groupModulesByPath || groupModulesByExtension) {
289
+ groupConfigs.push({
290
+ getKeys: module => {
291
+ if (!module.name)
292
+ return;
293
+ const resource = (0, identifier_1.parseResource)(module.name.split("!").pop()).path;
294
+ const dataUrl = /^data:[^,;]+/.exec(resource);
295
+ if (dataUrl)
296
+ return [dataUrl[0]];
297
+ const extensionMatch = groupModulesByExtension && GROUP_EXTENSION_REGEXP.exec(resource);
298
+ const extension = extensionMatch ? extensionMatch[1] : "";
299
+ const pathMatch = groupModulesByPath && GROUP_PATH_REGEXP.exec(resource);
300
+ const path = pathMatch ? pathMatch[1].split(/[/\\]/) : [];
301
+ const keys = [];
302
+ if (groupModulesByPath) {
303
+ if (extension)
304
+ keys.push(path.length
305
+ ? `${path.join("/")}/*${extension}`
306
+ : `*${extension}`);
307
+ while (path.length > 0) {
308
+ keys.push(path.join("/") + "/");
309
+ path.pop();
310
+ }
311
+ }
312
+ else {
313
+ if (extension)
314
+ keys.push(`*${extension}`);
315
+ }
316
+ return keys;
317
+ },
318
+ // @ts-expect-error
319
+ createGroup: (key, children, modules) => {
320
+ const isDataUrl = key.startsWith("data:");
321
+ return {
322
+ type: isDataUrl
323
+ ? "modules by mime type"
324
+ : groupModulesByPath
325
+ ? "modules by path"
326
+ : "modules by extension",
327
+ name: isDataUrl ? key.slice(/* 'data:'.length */ 5) : key,
328
+ children,
329
+ ...(0, statsFactoryUtils_1.moduleGroup)(children)
330
+ };
331
+ }
332
+ });
333
+ }
334
+ },
335
+ excludeModules: (groupConfigs, context, { excludeModules }) => {
336
+ groupConfigs.push({
337
+ getKeys: module => {
338
+ const name = module.name;
339
+ if (name) {
340
+ const excluded = excludeModules.some(fn => fn(name, module, type));
341
+ if (excluded)
342
+ return ["1"];
343
+ }
344
+ },
345
+ getOptions: () => ({
346
+ groupChildren: false,
347
+ force: true
348
+ }),
349
+ // @ts-expect-error
350
+ createGroup: (key, children, modules) => ({
351
+ type: "hidden modules",
352
+ filteredChildren: children.length,
353
+ ...(0, statsFactoryUtils_1.moduleGroup)(children)
354
+ })
355
+ });
232
356
  }
233
- // not support excludeModules
234
357
  });
235
358
  const RESULT_GROUPERS = {
236
359
  "compilation.assets": ASSETS_GROUPERS,
@@ -295,6 +418,31 @@ const SORTERS = {
295
418
  }
296
419
  }
297
420
  };
421
+ const EXTRACT_ERROR = {
422
+ _: (object, error) => {
423
+ object.message = error.message;
424
+ object.chunkName = error.chunkName;
425
+ object.chunkEntry = error.chunkEntry;
426
+ object.chunkInitial = error.chunkInitial;
427
+ object.file = error.file;
428
+ object.moduleIdentifier = error.moduleIdentifier;
429
+ object.moduleName = error.moduleName;
430
+ },
431
+ ids: (object, error) => {
432
+ object.chunkId = error.chunkId;
433
+ object.moduleId = error.moduleId;
434
+ },
435
+ moduleTrace: (object, error, context, _, factory) => {
436
+ const { type } = context;
437
+ object.moduleTrace = factory.create(`${type}.moduleTrace`, error.moduleTrace, context);
438
+ },
439
+ errorDetails: (object, error) => {
440
+ object.details = error.details;
441
+ },
442
+ errorStack: (object, error) => {
443
+ object.stack = error.stack;
444
+ }
445
+ };
298
446
  const SIMPLE_EXTRACTORS = {
299
447
  compilation: {
300
448
  _: (object, compilation, context, options) => {
@@ -487,7 +635,7 @@ const SIMPLE_EXTRACTORS = {
487
635
  // compilationFileToChunks
488
636
  // compilationAuxiliaryFileToChunks
489
637
  });
490
- const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedAssets, options.assetsSpace || Infinity);
638
+ const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedAssets, options.assetsSpace || Number.POSITIVE_INFINITY);
491
639
  // object.filteredAssets = limited.filteredChildren;
492
640
  // const limited = spaceLimited(groupedAssets, options.assetsSpace);
493
641
  object.assets = limited.children;
@@ -509,35 +657,46 @@ const SIMPLE_EXTRACTORS = {
509
657
  object.modules = limited.children;
510
658
  object.filteredModules = limited.filteredChildren;
511
659
  },
512
- entrypoints: (object, compilation, context, { chunkGroupAuxiliary, chunkGroupChildren }, _factory) => {
513
- // const { type } = context;
660
+ entrypoints: (object, compilation, context, { entrypoints, chunkGroups, chunkGroupAuxiliary, chunkGroupChildren }, factory) => {
661
+ const { type } = context;
514
662
  const array = context
515
663
  .getInner(compilation)
516
- .getEntrypoints(chunkGroupAuxiliary, chunkGroupChildren);
517
- // object.entrypoints = factory.create(
518
- // `${type}.entrypoints`,
519
- // array,
520
- // context
521
- // );
522
- object.entrypoints = array.reduce((acc, cur) => {
523
- acc[cur.name] = cur;
524
- return acc;
664
+ .getEntrypoints(chunkGroupAuxiliary, chunkGroupChildren)
665
+ .map(entrypoint => ({
666
+ name: entrypoint.name,
667
+ chunkGroup: entrypoint
668
+ }));
669
+ const chunks = Array.from(compilation.chunks).reduce((res, chunk) => {
670
+ res[chunk.id] = chunk;
671
+ return res;
525
672
  }, {});
673
+ if (entrypoints === "auto" && !chunkGroups) {
674
+ if (array.length > 5)
675
+ return;
676
+ if (!chunkGroupChildren &&
677
+ array.every(({ chunkGroup }) => {
678
+ if (chunkGroup.chunks.length !== 1)
679
+ return false;
680
+ const chunk = chunks[chunkGroup.chunks[0]];
681
+ return (chunk &&
682
+ chunk.files.size === 1 &&
683
+ (!chunkGroupAuxiliary || chunk.auxiliaryFiles.size === 0));
684
+ })) {
685
+ return;
686
+ }
687
+ }
688
+ object.entrypoints = factory.create(`${type}.entrypoints`, array, context);
526
689
  },
527
690
  chunkGroups: (object, compilation, context, { chunkGroupAuxiliary, chunkGroupChildren }, factory) => {
528
- // const { type } = context;
691
+ const { type } = context;
529
692
  const namedChunkGroups = context
530
693
  .getInner(compilation)
531
- .getNamedChunkGroups(chunkGroupAuxiliary, chunkGroupChildren);
532
- // object.namedChunkGroups = factory.create(
533
- // `${type}.namedChunkGroups`,
534
- // namedChunkGroups,
535
- // context
536
- // );
537
- object.namedChunkGroups = namedChunkGroups.reduce((acc, cur) => {
538
- acc[cur.name] = cur;
539
- return acc;
540
- }, {});
694
+ .getNamedChunkGroups(chunkGroupAuxiliary, chunkGroupChildren)
695
+ .map(cg => ({
696
+ name: cg.name,
697
+ chunkGroup: cg
698
+ }));
699
+ object.namedChunkGroups = factory.create(`${type}.namedChunkGroups`, namedChunkGroups, context);
541
700
  },
542
701
  errors: (object, compilation, context, _options, _factory) => {
543
702
  const { cachedGetErrors } = context;
@@ -571,15 +730,39 @@ const SIMPLE_EXTRACTORS = {
571
730
  ...asset.info,
572
731
  related: Object.fromEntries(asset.info.related.map(i => [i.name, i.value]))
573
732
  };
733
+ // - comparedForEmit
734
+ // - cached
574
735
  Object.assign(object, factory.create(`${context.type}$visible`, asset, context));
575
736
  }
576
737
  },
577
738
  asset$visible: {
578
739
  _: (object, asset) => {
579
740
  object.chunkNames = asset.chunkNames;
741
+ // - chunkIdHints
742
+ // - auxiliaryChunkNames
743
+ // - auxiliaryChunkIdHints
744
+ // - filteredRelated
580
745
  },
746
+ // relatedAssets
581
747
  ids: (object, asset) => {
582
748
  object.chunks = asset.chunks;
749
+ // - auxiliaryChunks
750
+ }
751
+ },
752
+ chunkGroup: {
753
+ _: (object, { name, chunkGroup }, _context, { chunkGroupMaxAssets }) => {
754
+ object.name = name;
755
+ object.chunks = chunkGroup.chunks;
756
+ object.assets = chunkGroup.assets;
757
+ object.filteredAssets =
758
+ chunkGroup.assets.length <= chunkGroupMaxAssets
759
+ ? 0
760
+ : chunkGroup.assets.length;
761
+ object.assetsSize = chunkGroup.assetsSize;
762
+ object.auxiliaryAssets = chunkGroup.auxiliaryAssets;
763
+ object.auxiliaryAssetsSize = chunkGroup.auxiliaryAssetsSize;
764
+ object.children = chunkGroup.children;
765
+ // - childAssets
583
766
  }
584
767
  },
585
768
  module: {
@@ -635,6 +818,7 @@ const SIMPLE_EXTRACTORS = {
635
818
  reasons: (object, module, context, options, factory) => {
636
819
  const { type } = context;
637
820
  object.reasons = factory.create(`${type.slice(0, -8)}.reasons`, module.reasons, context);
821
+ // object.filteredReasons
638
822
  },
639
823
  source: (object, module) => {
640
824
  object.source = module.source;
@@ -745,7 +929,23 @@ const SIMPLE_EXTRACTORS = {
745
929
  chunkOrigins: (object, chunk, context, options, factory) => {
746
930
  object.origins = chunk.origins;
747
931
  }
932
+ },
933
+ // chunkOrigin
934
+ error: EXTRACT_ERROR,
935
+ warning: EXTRACT_ERROR,
936
+ moduleTraceItem: {
937
+ _: (object, { origin, module }, context, { requestShortener }, factory) => {
938
+ object.originIdentifier = origin.identifier;
939
+ object.originName = origin.name;
940
+ object.moduleIdentifier = module.identifier;
941
+ object.moduleName = module.name;
942
+ },
943
+ ids: (object, { origin, module }) => {
944
+ object.originId = origin.id;
945
+ object.moduleId = module.id;
946
+ }
748
947
  }
948
+ // moduleTraceDependency
749
949
  };
750
950
  /**
751
951
  * only support below factories:
@@ -797,10 +997,10 @@ class DefaultStatsFactoryPlugin {
797
997
  .for(key)
798
998
  .tap("DefaultStatsFactoryPlugin", () => itemName);
799
999
  }
800
- // for (const key of Object.keys(MERGER)) {
801
- // const merger = MERGER[key];
802
- // stats.hooks.merge.for(key).tap("DefaultStatsFactoryPlugin", merger);
803
- // }
1000
+ for (const key of Object.keys(MERGER)) {
1001
+ const merger = MERGER[key];
1002
+ stats.hooks.merge.for(key).tap("DefaultStatsFactoryPlugin", merger);
1003
+ }
804
1004
  });
805
1005
  });
806
1006
  }
@@ -16,7 +16,7 @@ const NAMED_PRESETS = {
16
16
  verbose: {
17
17
  hash: true,
18
18
  builtAt: true,
19
- // relatedAssets: true,
19
+ relatedAssets: true,
20
20
  entrypoints: true,
21
21
  chunkGroups: true,
22
22
  ids: true,
@@ -24,16 +24,16 @@ const NAMED_PRESETS = {
24
24
  chunks: true,
25
25
  chunkRelations: true,
26
26
  chunkModules: true,
27
- // dependentModules: true,
28
- // chunkOrigins: true,
27
+ dependentModules: true,
28
+ chunkOrigins: true,
29
29
  depth: true,
30
- // env: true,
30
+ env: true,
31
31
  reasons: true,
32
32
  usedExports: true,
33
33
  providedExports: true,
34
34
  optimizationBailout: true,
35
- // errorDetails: true,
36
- // errorStack: true,
35
+ errorDetails: true,
36
+ errorStack: true,
37
37
  publicPath: true,
38
38
  logging: "verbose",
39
39
  orphanModules: true,
@@ -41,7 +41,7 @@ const NAMED_PRESETS = {
41
41
  // exclude: false,
42
42
  // errorsSpace: Infinity,
43
43
  // warningsSpace: Infinity,
44
- modulesSpace: Infinity,
44
+ modulesSpace: Number.POSITIVE_INFINITY,
45
45
  // chunkModulesSpace: Infinity,
46
46
  // assetsSpace: Infinity,
47
47
  // reasonsSpace: Infinity,
@@ -50,19 +50,19 @@ const NAMED_PRESETS = {
50
50
  detailed: {
51
51
  hash: true,
52
52
  builtAt: true,
53
- // relatedAssets: true,
53
+ relatedAssets: true,
54
54
  entrypoints: true,
55
55
  chunkGroups: true,
56
56
  ids: true,
57
57
  chunks: true,
58
58
  chunkRelations: true,
59
59
  chunkModules: false,
60
- // chunkOrigins: true,
60
+ chunkOrigins: true,
61
61
  depth: true,
62
62
  usedExports: true,
63
63
  providedExports: true,
64
64
  optimizationBailout: true,
65
- // errorDetails: true,
65
+ errorDetails: true,
66
66
  publicPath: true,
67
67
  logging: true,
68
68
  runtimeModules: true,
@@ -94,7 +94,7 @@ const NAMED_PRESETS = {
94
94
  errors: true,
95
95
  errorsCount: true,
96
96
  // errorsSpace: Infinity,
97
- // moduleTrace: true,
97
+ moduleTrace: true,
98
98
  logging: "error"
99
99
  },
100
100
  "errors-warnings": {
@@ -147,7 +147,7 @@ const DEFAULTS = {
147
147
  chunkGroups: OFF_FOR_TO_STRING,
148
148
  chunkGroupAuxiliary: OFF_FOR_TO_STRING,
149
149
  chunkGroupChildren: OFF_FOR_TO_STRING,
150
- chunkGroupMaxAssets: (o, { forToString }) => (forToString ? 5 : Infinity),
150
+ chunkGroupMaxAssets: (o, { forToString }) => forToString ? 5 : Number.POSITIVE_INFINITY,
151
151
  chunks: OFF_FOR_TO_STRING,
152
152
  chunkRelations: OFF_FOR_TO_STRING,
153
153
  chunkModules: ({ all, modules }) => {
@@ -178,16 +178,16 @@ const DEFAULTS = {
178
178
  groupModulesByAttributes: ON_FOR_TO_STRING,
179
179
  groupModulesByPath: ON_FOR_TO_STRING,
180
180
  groupModulesByExtension: ON_FOR_TO_STRING,
181
- modulesSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
182
- chunkModulesSpace: (o, { forToString }) => (forToString ? 10 : Infinity),
183
- nestedModulesSpace: (o, { forToString }) => (forToString ? 10 : Infinity),
181
+ modulesSpace: (o, { forToString }) => forToString ? 15 : Number.POSITIVE_INFINITY,
182
+ chunkModulesSpace: (o, { forToString }) => forToString ? 10 : Number.POSITIVE_INFINITY,
183
+ nestedModulesSpace: (o, { forToString }) => forToString ? 10 : Number.POSITIVE_INFINITY,
184
184
  relatedAssets: OFF_FOR_TO_STRING,
185
185
  groupAssetsByEmitStatus: ON_FOR_TO_STRING,
186
186
  groupAssetsByInfo: ON_FOR_TO_STRING,
187
187
  groupAssetsByPath: ON_FOR_TO_STRING,
188
188
  groupAssetsByExtension: ON_FOR_TO_STRING,
189
189
  groupAssetsByChunk: ON_FOR_TO_STRING,
190
- assetsSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
190
+ assetsSpace: (o, { forToString }) => forToString ? 15 : Number.POSITIVE_INFINITY,
191
191
  orphanModules: OFF_FOR_TO_STRING,
192
192
  runtimeModules: ({ all, runtime }, { forToString }) => runtime !== undefined
193
193
  ? runtime
@@ -200,7 +200,7 @@ const DEFAULTS = {
200
200
  depth: OFF_FOR_TO_STRING,
201
201
  // cachedAssets: OFF_FOR_TO_STRING,
202
202
  reasons: OFF_FOR_TO_STRING,
203
- reasonsSpace: (o, { forToString }) => (forToString ? 15 : Infinity),
203
+ reasonsSpace: (o, { forToString }) => forToString ? 15 : Number.POSITIVE_INFINITY,
204
204
  groupReasonsByOrigin: ON_FOR_TO_STRING,
205
205
  usedExports: OFF_FOR_TO_STRING,
206
206
  providedExports: OFF_FOR_TO_STRING,
@@ -367,7 +367,7 @@ const SIMPLE_PRINTERS = {
367
367
  "error.message": (message, { bold, formatError }) => message.includes("\u001b[") ? message : bold(formatError(message)),
368
368
  // "error.details": (details, { formatError }) => formatError(details),
369
369
  // "error.stack": stack => stack,
370
- // "error.moduleTrace": moduleTrace => undefined,
370
+ "error.moduleTrace": moduleTrace => undefined,
371
371
  "error.separator!": () => "\n",
372
372
  "loggingEntry(error).loggingEntry.message": (message, { red }) => mapLines(message, x => `<e> ${red(x)}`),
373
373
  "loggingEntry(warn).loggingEntry.message": (message, { yellow }) => mapLines(message, x => `<w> ${yellow(x)}`),
@@ -7,10 +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 { JsStats, JsStatsError, JsStatsWarning } from "@rspack/binding";
10
+ import type { JsStats, JsStatsError, JsStatsWarning } from "@rspack/binding";
11
11
  import { HookMap, SyncBailHook, SyncWaterfallHook } from "@rspack/lite-tapable";
12
12
  import type { Compilation } from "../Compilation";
13
- import { GroupConfig } from "../util/smartGrouping";
13
+ import { type GroupConfig } from "../util/smartGrouping";
14
14
  export type KnownStatsFactoryContext = {
15
15
  type: string;
16
16
  makePathsRelative?: ((arg0: string) => string) | undefined;
@@ -1,4 +1,4 @@
1
- import * as binding from "@rspack/binding";
1
+ import type * as binding from "@rspack/binding";
2
2
  import type { Compilation, NormalizedStatsOptions } from "../Compilation";
3
3
  import { type Comparator } from "../util/comparators";
4
4
  import type { StatsFactory, StatsFactoryContext } from "./StatsFactory";
@@ -34,6 +34,14 @@ export type StatsModule = KnownStatsModule & Record<string, any>;
34
34
  export type StatsModuleIssuer = binding.JsStatsModuleIssuer & Record<string, any>;
35
35
  export type StatsError = binding.JsStatsError & Record<string, any>;
36
36
  export type StatsWarnings = binding.JsStatsWarning & Record<string, any>;
37
+ export type StatsModuleTraceItem = {
38
+ originIdentifier?: string;
39
+ originName?: string;
40
+ moduleIdentifier?: string;
41
+ moduleName?: string;
42
+ originId?: string;
43
+ moduleId?: string;
44
+ };
37
45
  export type StatsModuleReason = binding.JsStatsModuleReason & Record<string, any>;
38
46
  export type KnownStatsCompilation = {
39
47
  /**
@@ -99,12 +107,19 @@ export type SimpleExtractors = {
99
107
  compilation: ExtractorsByOption<Compilation, StatsCompilation>;
100
108
  asset$visible: ExtractorsByOption<PreprocessedAsset, StatsAsset>;
101
109
  asset: ExtractorsByOption<PreprocessedAsset, StatsAsset>;
110
+ chunkGroup: ExtractorsByOption<{
111
+ name: string;
112
+ chunkGroup: binding.JsStatsChunkGroup;
113
+ }, StatsChunkGroup>;
102
114
  module: ExtractorsByOption<binding.JsStatsModule, StatsModule>;
103
115
  module$visible: ExtractorsByOption<binding.JsStatsModule, StatsModule>;
104
116
  moduleIssuer: ExtractorsByOption<binding.JsStatsModuleIssuer, StatsModuleIssuer>;
105
117
  profile: ExtractorsByOption<binding.JsStatsModuleProfile, StatsProfile>;
106
118
  moduleReason: ExtractorsByOption<binding.JsStatsModuleReason, StatsModuleReason>;
107
119
  chunk: ExtractorsByOption<binding.JsStatsChunk, KnownStatsChunk>;
120
+ error: ExtractorsByOption<binding.JsStatsError, StatsError>;
121
+ warning: ExtractorsByOption<binding.JsStatsWarning, StatsError>;
122
+ moduleTraceItem: ExtractorsByOption<binding.JsStatsModuleTrace, StatsModuleTraceItem>;
108
123
  };
109
124
  export declare const uniqueArray: <T, I>(items: Iterable<T>, selector: (arg: T) => Iterable<I>) => I[];
110
125
  export declare const uniqueOrderedArray: <T, I>(items: Iterable<T>, selector: (arg: T) => Iterable<I>, comparator: Comparator) => I[];
@@ -1,4 +1,4 @@
1
- import { RawSplitChunkSizes } from "@rspack/binding";
1
+ import type { RawSplitChunkSizes } from "@rspack/binding";
2
2
  declare class JsSplitChunkSizes {
3
3
  static __to_binding(sizes?: number | Record<string, number>): number | RawSplitChunkSizes | undefined;
4
4
  }
@@ -57,7 +57,7 @@ function isMusl() {
57
57
  }
58
58
  const BINDING_VERSION = require("@rspack/binding/package.json").version;
59
59
  const CORE_VERSION = require("../../package.json").version;
60
- const getAddonPlatformArchAbi = function () {
60
+ const getAddonPlatformArchAbi = () => {
61
61
  const { platform, arch } = process;
62
62
  let binding = "";
63
63
  binding += platform;
@@ -8,7 +8,7 @@
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
10
  import type { JsStatsChunk as Chunk } from "@rspack/binding";
11
- import { ChunkGroup } from "../ChunkGroup";
11
+ import type { ChunkGroup } from "../ChunkGroup";
12
12
  export type Comparator = <T>(arg0: T, arg1: T) => -1 | 0 | 1;
13
13
  type Selector<A, B> = (input: A) => B;
14
14
  export declare const concatComparators: (c1: Comparator, c2: Comparator, ...cRest: Comparator[]) => Comparator;
package/dist/util/fs.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  */
10
10
  /// <reference types="node" />
11
11
  /// <reference types="node" />
12
- import { WatchOptions } from "../config";
12
+ import type { WatchOptions } from "../config";
13
13
  export interface Watcher {
14
14
  close(): void;
15
15
  pause(): void;