@rspack/core 1.0.0-beta.1 → 1.0.0-beta.2
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.
- package/dist/ChunkGroup.d.ts +1 -0
- package/dist/ChunkGroup.js +3 -0
- package/dist/Compilation.d.ts +18 -0
- package/dist/Compiler.js +2 -2
- package/dist/ExecuteModulePlugin.d.ts +0 -1
- package/dist/ExecuteModulePlugin.js +0 -1
- package/dist/Module.d.ts +1 -2
- package/dist/Module.js +0 -1
- package/dist/MultiCompiler.js +1 -1
- package/dist/Resolver.d.ts +1 -2
- package/dist/RspackError.js +1 -1
- package/dist/Stats.js +22 -2
- package/dist/Template.js +2 -2
- package/dist/builtin-loader/lightningcss/index.js +1 -1
- package/dist/builtin-plugin/DefinePlugin.js +1 -1
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +2 -2
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +1 -1
- package/dist/builtin-plugin/EnableLibraryPlugin.js +1 -6
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +2 -2
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +1 -1
- package/dist/builtin-plugin/ExternalsPlugin.js +1 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +0 -1
- package/dist/builtin-plugin/JavascriptModulesPlugin.js +1 -1
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -2
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +3 -5
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +7 -5
- package/dist/builtin-plugin/css-extract/loader.js +4 -10
- package/dist/builtin-plugin/lazy-compilation/backend.js +4 -4
- package/dist/config/adapter.js +1 -0
- package/dist/config/adapterRuleUse.d.ts +2 -6
- package/dist/config/adapterRuleUse.js +7 -6
- package/dist/config/defaults.js +21 -32
- package/dist/config/normalization.d.ts +1 -0
- package/dist/config/normalization.js +5 -2
- package/dist/config/zod.d.ts +440 -68
- package/dist/config/zod.js +21 -1
- package/dist/container/default.runtime.js +1 -1
- package/dist/lib/AbstractMethodError.js +2 -3
- package/dist/lib/Cache.d.ts +1 -1
- package/dist/lib/Dependency.d.ts +23 -0
- package/dist/lib/Dependency.js +11 -0
- package/dist/lib/EnvironmentPlugin.js +1 -3
- package/dist/lib/ModuleFilenameHelpers.js +1 -1
- package/dist/lib/WebpackError.d.ts +0 -6
- package/dist/lib/WebpackError.js +0 -8
- package/dist/lib/cache/MemoryCachePlugin.d.ts +5 -0
- package/dist/lib/cache/MemoryCachePlugin.js +40 -0
- package/dist/lib/formatLocation.d.ts +1 -1
- package/dist/loader-runner/index.js +6 -7
- package/dist/loader-runner/loadLoader.js +8 -11
- package/dist/logging/Logger.js +3 -3
- package/dist/logging/createConsoleLogger.d.ts +26 -6
- package/dist/logging/createConsoleLogger.js +21 -58
- package/dist/logging/runtime.d.ts +4 -10
- package/dist/logging/runtime.js +8 -23
- package/dist/logging/truncateArgs.d.ts +4 -4
- package/dist/logging/truncateArgs.js +5 -10
- package/dist/node/NodeEnvironmentPlugin.js +2 -2
- package/dist/node/NodeWatchFileSystem.js +6 -6
- package/dist/node/nodeConsole.d.ts +7 -21
- package/dist/node/nodeConsole.js +29 -36
- package/dist/rspackOptionsApply.d.ts +0 -1
- package/dist/rspackOptionsApply.js +8 -7
- package/dist/sharing/ProvideSharedPlugin.d.ts +20 -19
- package/dist/sharing/ProvideSharedPlugin.js +26 -17
- package/dist/sharing/SharePlugin.d.ts +3 -0
- package/dist/sharing/SharePlugin.js +4 -1
- package/dist/stats/DefaultStatsFactoryPlugin.js +187 -96
- package/dist/stats/DefaultStatsPresetPlugin.js +1 -2
- package/dist/stats/DefaultStatsPrinterPlugin.js +18 -19
- package/dist/stats/StatsFactory.d.ts +2 -1
- package/dist/stats/StatsFactory.js +2 -6
- package/dist/stats/statsFactoryUtils.d.ts +63 -23
- package/dist/util/SizeFormatHelpers.js +1 -1
- package/dist/util/bindingVersionCheck.js +3 -3
- package/dist/util/cleverMerge.js +3 -2
- package/dist/util/comparators.d.ts +1 -1
- package/dist/util/comparators.js +5 -4
- package/dist/util/createHash.js +1 -1
- package/dist/util/fs.js +2 -2
- package/dist/util/identifier.js +2 -2
- package/dist/util/index.js +1 -1
- package/dist/util/memoize.js +1 -4
- package/dist/util/smartGrouping.js +4 -6
- package/dist/util/webpack.d.ts +1 -1
- package/dist/util/webpack.js +2 -1
- package/module.d.ts +1 -1
- package/package.json +3 -3
|
@@ -120,7 +120,7 @@ const ASSETS_GROUPERS = {
|
|
|
120
120
|
? `${path.join("/")}/*${extension}`
|
|
121
121
|
: `*${extension}`);
|
|
122
122
|
while (path.length > 0) {
|
|
123
|
-
keys.push(path.join("/")
|
|
123
|
+
keys.push(`${path.join("/")}/`);
|
|
124
124
|
path.pop();
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -146,7 +146,7 @@ const ASSETS_GROUPERS = {
|
|
|
146
146
|
const groupByAssetInfoFlag = (name) => {
|
|
147
147
|
groupConfigs.push({
|
|
148
148
|
getKeys: asset => {
|
|
149
|
-
return asset.info
|
|
149
|
+
return asset.info?.[name] ? ["1"] : undefined;
|
|
150
150
|
},
|
|
151
151
|
// @ts-expect-error
|
|
152
152
|
createGroup: (key, children) => {
|
|
@@ -256,12 +256,13 @@ const MODULES_GROUPERS = (type) => ({
|
|
|
256
256
|
if (groupModulesByType || !options.runtimeModules) {
|
|
257
257
|
groupConfigs.push({
|
|
258
258
|
getKeys: (module) => {
|
|
259
|
-
|
|
259
|
+
const moduleType = module.moduleType;
|
|
260
|
+
if (!moduleType)
|
|
260
261
|
return;
|
|
261
262
|
if (groupModulesByType) {
|
|
262
|
-
return [
|
|
263
|
+
return [moduleType.split("/", 1)[0]];
|
|
263
264
|
}
|
|
264
|
-
if (
|
|
265
|
+
if (moduleType === "runtime") {
|
|
265
266
|
return ["runtime"];
|
|
266
267
|
}
|
|
267
268
|
},
|
|
@@ -305,7 +306,7 @@ const MODULES_GROUPERS = (type) => ({
|
|
|
305
306
|
? `${path.join("/")}/*${extension}`
|
|
306
307
|
: `*${extension}`);
|
|
307
308
|
while (path.length > 0) {
|
|
308
|
-
keys.push(path.join("/")
|
|
309
|
+
keys.push(`${path.join("/")}/`);
|
|
309
310
|
path.pop();
|
|
310
311
|
}
|
|
311
312
|
}
|
|
@@ -397,7 +398,7 @@ const RESULT_SORTERS = {
|
|
|
397
398
|
};
|
|
398
399
|
const MODULES_SORTER = {
|
|
399
400
|
_: comparators => {
|
|
400
|
-
comparators.push((0, comparators_1.compareSelect)((m) => m.depth, comparators_1.compareNumbers), (0, comparators_1.compareSelect)((m) => m.preOrderIndex, comparators_1.compareNumbers), (0, comparators_1.compareSelect)((m) => m.identifier, compareIds));
|
|
401
|
+
comparators.push((0, comparators_1.compareSelect)((m) => m.commonAttributes.depth, comparators_1.compareNumbers), (0, comparators_1.compareSelect)((m) => m.commonAttributes.preOrderIndex, comparators_1.compareNumbers), (0, comparators_1.compareSelect)((m) => m.commonAttributes.moduleDescriptor?.identifier, compareIds));
|
|
401
402
|
}
|
|
402
403
|
};
|
|
403
404
|
const SORTERS = {
|
|
@@ -426,16 +427,33 @@ const SORTERS = {
|
|
|
426
427
|
const EXTRACT_ERROR = {
|
|
427
428
|
_: (object, error) => {
|
|
428
429
|
object.message = error.message;
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
430
|
+
if (error.chunkName) {
|
|
431
|
+
object.chunkName = error.chunkName;
|
|
432
|
+
}
|
|
433
|
+
if (error.chunkEntry) {
|
|
434
|
+
object.chunkEntry = error.chunkEntry;
|
|
435
|
+
}
|
|
436
|
+
if (error.chunkInitial) {
|
|
437
|
+
object.chunkInitial = error.chunkInitial;
|
|
438
|
+
}
|
|
439
|
+
if (error.file) {
|
|
440
|
+
object.file = error.file;
|
|
441
|
+
}
|
|
442
|
+
if (error.moduleDescriptor) {
|
|
443
|
+
object.moduleIdentifier = error.moduleDescriptor.identifier;
|
|
444
|
+
object.moduleName = error.moduleDescriptor.name;
|
|
445
|
+
}
|
|
446
|
+
if ("loc" in error) {
|
|
447
|
+
object.loc = error.loc;
|
|
448
|
+
}
|
|
435
449
|
},
|
|
436
450
|
ids: (object, error) => {
|
|
437
|
-
|
|
438
|
-
|
|
451
|
+
if (error.chunkId) {
|
|
452
|
+
object.chunkId = error.chunkId;
|
|
453
|
+
}
|
|
454
|
+
if (error.moduleDescriptor) {
|
|
455
|
+
object.moduleId = error.moduleDescriptor.id;
|
|
456
|
+
}
|
|
439
457
|
},
|
|
440
458
|
moduleTrace: (object, error, context, _, factory) => {
|
|
441
459
|
const { type } = context;
|
|
@@ -451,17 +469,18 @@ const EXTRACT_ERROR = {
|
|
|
451
469
|
const SIMPLE_EXTRACTORS = {
|
|
452
470
|
compilation: {
|
|
453
471
|
_: (object, compilation, context, options) => {
|
|
472
|
+
const statsCompilation = context.getStatsCompilation(compilation);
|
|
454
473
|
if (!context.makePathsRelative) {
|
|
455
474
|
context.makePathsRelative = identifier_1.makePathsRelative.bindContextCache(compilation.compiler.context, compilation.compiler.root);
|
|
456
475
|
}
|
|
457
476
|
if (!context.cachedGetErrors) {
|
|
458
477
|
context.cachedGetErrors = _compilation => {
|
|
459
|
-
return
|
|
478
|
+
return statsCompilation.errors;
|
|
460
479
|
};
|
|
461
480
|
}
|
|
462
481
|
if (!context.cachedGetWarnings) {
|
|
463
482
|
context.cachedGetWarnings = _compilation => {
|
|
464
|
-
const warnings =
|
|
483
|
+
const warnings = statsCompilation.warnings;
|
|
465
484
|
return compilation.hooks.processWarnings.call(warnings);
|
|
466
485
|
};
|
|
467
486
|
}
|
|
@@ -605,7 +624,8 @@ const SIMPLE_EXTRACTORS = {
|
|
|
605
624
|
}
|
|
606
625
|
},
|
|
607
626
|
hash: (object, compilation, context) => {
|
|
608
|
-
|
|
627
|
+
const statsCompilation = context.getStatsCompilation(compilation);
|
|
628
|
+
object.hash = statsCompilation.hash;
|
|
609
629
|
},
|
|
610
630
|
version: object => {
|
|
611
631
|
const { version, webpackVersion } = require("../../package.json");
|
|
@@ -628,9 +648,10 @@ const SIMPLE_EXTRACTORS = {
|
|
|
628
648
|
object.outputPath = compilation.outputOptions.path;
|
|
629
649
|
},
|
|
630
650
|
assets: (object, compilation, context, options, factory) => {
|
|
631
|
-
const {
|
|
632
|
-
|
|
633
|
-
|
|
651
|
+
const { type, getStatsCompilation } = context;
|
|
652
|
+
const statsCompilation = getStatsCompilation(compilation);
|
|
653
|
+
const compilationAssets = statsCompilation.assets;
|
|
654
|
+
const assetsByChunkName = statsCompilation.assetsByChunkName;
|
|
634
655
|
const assetMap = new Map();
|
|
635
656
|
const assets = new Set();
|
|
636
657
|
for (const asset of compilationAssets) {
|
|
@@ -665,7 +686,7 @@ const SIMPLE_EXTRACTORS = {
|
|
|
665
686
|
acc[cur.name] = cur.files;
|
|
666
687
|
return acc;
|
|
667
688
|
}, {});
|
|
668
|
-
const groupedAssets = factory.create(`${
|
|
689
|
+
const groupedAssets = factory.create(`${type}.assets`, Array.from(assets), {
|
|
669
690
|
...context
|
|
670
691
|
// compilationFileToChunks
|
|
671
692
|
// compilationAuxiliaryFileToChunks
|
|
@@ -675,28 +696,24 @@ const SIMPLE_EXTRACTORS = {
|
|
|
675
696
|
object.filteredAssets = limited.filteredChildren;
|
|
676
697
|
},
|
|
677
698
|
chunks: (object, compilation, context, options, factory) => {
|
|
678
|
-
const { type } = context;
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
.getChunks(options.chunkModules, options.chunkRelations, options.reasons, options.moduleAssets, options.nestedModules, options.source, options.usedExports, options.providedExports);
|
|
699
|
+
const { type, getStatsCompilation } = context;
|
|
700
|
+
const statsCompilation = getStatsCompilation(compilation);
|
|
701
|
+
const chunks = statsCompilation.chunks;
|
|
682
702
|
object.chunks = factory.create(`${type}.chunks`, chunks, context);
|
|
683
703
|
},
|
|
684
704
|
modules: (object, compilation, context, options, factory) => {
|
|
685
|
-
const { type } = context;
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
.getModules(options.reasons, options.moduleAssets, options.nestedModules, options.source, options.usedExports, options.providedExports);
|
|
705
|
+
const { type, getStatsCompilation } = context;
|
|
706
|
+
const statsCompilation = getStatsCompilation(compilation);
|
|
707
|
+
const array = statsCompilation.modules;
|
|
689
708
|
const groupedModules = factory.create(`${type}.modules`, array, context);
|
|
690
709
|
const limited = (0, statsFactoryUtils_1.spaceLimited)(groupedModules, options.modulesSpace);
|
|
691
710
|
object.modules = limited.children;
|
|
692
711
|
object.filteredModules = limited.filteredChildren;
|
|
693
712
|
},
|
|
694
713
|
entrypoints: (object, compilation, context, { entrypoints, chunkGroups, chunkGroupAuxiliary, chunkGroupChildren }, factory) => {
|
|
695
|
-
const { type } = context;
|
|
696
|
-
const
|
|
697
|
-
|
|
698
|
-
.getEntrypoints(chunkGroupAuxiliary, chunkGroupChildren)
|
|
699
|
-
.map(entrypoint => ({
|
|
714
|
+
const { type, getStatsCompilation } = context;
|
|
715
|
+
const statsCompilation = getStatsCompilation(compilation);
|
|
716
|
+
const array = statsCompilation.entrypoints.map(entrypoint => ({
|
|
700
717
|
name: entrypoint.name,
|
|
701
718
|
chunkGroup: entrypoint
|
|
702
719
|
}));
|
|
@@ -722,26 +739,65 @@ const SIMPLE_EXTRACTORS = {
|
|
|
722
739
|
object.entrypoints = factory.create(`${type}.entrypoints`, array, context);
|
|
723
740
|
},
|
|
724
741
|
chunkGroups: (object, compilation, context, { chunkGroupAuxiliary, chunkGroupChildren }, factory) => {
|
|
725
|
-
const { type } = context;
|
|
726
|
-
const
|
|
727
|
-
|
|
728
|
-
.getNamedChunkGroups(chunkGroupAuxiliary, chunkGroupChildren)
|
|
729
|
-
.map(cg => ({
|
|
742
|
+
const { type, getStatsCompilation } = context;
|
|
743
|
+
const statsCompilation = getStatsCompilation(compilation);
|
|
744
|
+
const namedChunkGroups = statsCompilation.namedChunkGroups.map(cg => ({
|
|
730
745
|
name: cg.name,
|
|
731
746
|
chunkGroup: cg
|
|
732
747
|
}));
|
|
733
748
|
object.namedChunkGroups = factory.create(`${type}.namedChunkGroups`, namedChunkGroups, context);
|
|
734
749
|
},
|
|
735
|
-
errors: (object, compilation, context,
|
|
736
|
-
const { cachedGetErrors } = context;
|
|
737
|
-
|
|
750
|
+
errors: (object, compilation, context, options, factory) => {
|
|
751
|
+
const { type, cachedGetErrors } = context;
|
|
752
|
+
// const rawErrors = cachedGetErrors!(compilation);
|
|
753
|
+
const factorizedErrors = factory.create(`${type}.errors`, cachedGetErrors(compilation), context);
|
|
754
|
+
// let filtered = 0;
|
|
755
|
+
// if (options.errorDetails === "auto" && rawErrors.length >= 3) {
|
|
756
|
+
// filtered = rawErrors
|
|
757
|
+
// .map(e => typeof e !== "string" && e.details)
|
|
758
|
+
// .filter(Boolean).length;
|
|
759
|
+
// }
|
|
760
|
+
// if (
|
|
761
|
+
// options.errorDetails === true ||
|
|
762
|
+
// !Number.isFinite(options.errorsSpace)
|
|
763
|
+
// ) {
|
|
764
|
+
// object.errors = factorizedErrors;
|
|
765
|
+
// if (filtered) object.filteredErrorDetailsCount = filtered;
|
|
766
|
+
// return;
|
|
767
|
+
// }
|
|
768
|
+
// const [errors, filteredBySpace] = errorsSpaceLimit(
|
|
769
|
+
// factorizedErrors,
|
|
770
|
+
// options.errorsSpace
|
|
771
|
+
// );
|
|
772
|
+
// object.filteredErrorDetailsCount = filtered + filteredBySpace;
|
|
773
|
+
object.errors = factorizedErrors;
|
|
738
774
|
},
|
|
739
775
|
errorsCount: (object, compilation, { cachedGetErrors }) => {
|
|
740
776
|
object.errorsCount = (0, statsFactoryUtils_1.countWithChildren)(compilation, c => cachedGetErrors(c));
|
|
741
777
|
},
|
|
742
|
-
warnings: (object, compilation, context,
|
|
743
|
-
const { cachedGetWarnings } = context;
|
|
744
|
-
|
|
778
|
+
warnings: (object, compilation, context, options, factory) => {
|
|
779
|
+
const { type, cachedGetWarnings } = context;
|
|
780
|
+
const rawWarnings = factory.create(`${type}.warnings`, cachedGetWarnings(compilation), context);
|
|
781
|
+
// let filtered = 0;
|
|
782
|
+
// if (options.errorDetails === "auto") {
|
|
783
|
+
// filtered = cachedGetWarnings!(compilation)
|
|
784
|
+
// .map(e => typeof e !== "string" && e.details)
|
|
785
|
+
// .filter(Boolean).length;
|
|
786
|
+
// }
|
|
787
|
+
// if (
|
|
788
|
+
// options.errorDetails === true ||
|
|
789
|
+
// !Number.isFinite(options.warningsSpace)
|
|
790
|
+
// ) {
|
|
791
|
+
// object.warnings = rawWarnings;
|
|
792
|
+
// if (filtered) object.filteredWarningDetailsCount = filtered;
|
|
793
|
+
// return;
|
|
794
|
+
// }
|
|
795
|
+
// const [warnings, filteredBySpace] = errorsSpaceLimit(
|
|
796
|
+
// rawWarnings,
|
|
797
|
+
// options.warningsSpace
|
|
798
|
+
// );
|
|
799
|
+
// object.filteredWarningDetailsCount = filtered + filteredBySpace;
|
|
800
|
+
object.warnings = rawWarnings;
|
|
745
801
|
},
|
|
746
802
|
warningsCount: (object, compilation, context) => {
|
|
747
803
|
const { cachedGetWarnings } = context;
|
|
@@ -808,21 +864,24 @@ const SIMPLE_EXTRACTORS = {
|
|
|
808
864
|
module: {
|
|
809
865
|
_: (object, module, context, options, factory) => {
|
|
810
866
|
const { type } = context;
|
|
811
|
-
|
|
812
|
-
object.
|
|
813
|
-
object.
|
|
814
|
-
object.
|
|
815
|
-
|
|
867
|
+
const { commonAttributes } = module;
|
|
868
|
+
object.type = commonAttributes.type;
|
|
869
|
+
object.moduleType = commonAttributes.moduleType;
|
|
870
|
+
object.layer = commonAttributes.layer;
|
|
871
|
+
object.size = commonAttributes.size;
|
|
872
|
+
const sizes = commonAttributes.sizes.map(({ sourceType, size }) => [
|
|
816
873
|
sourceType,
|
|
817
874
|
size
|
|
818
875
|
]);
|
|
819
876
|
sizes.sort((a, b) => -compareIds(a, b));
|
|
820
877
|
object.sizes = Object.fromEntries(sizes);
|
|
821
|
-
object.built =
|
|
822
|
-
object.codeGenerated =
|
|
823
|
-
object.buildTimeExecuted =
|
|
824
|
-
object.cached =
|
|
825
|
-
if (
|
|
878
|
+
object.built = commonAttributes.built;
|
|
879
|
+
object.codeGenerated = commonAttributes.codeGenerated;
|
|
880
|
+
object.buildTimeExecuted = commonAttributes.buildTimeExecuted;
|
|
881
|
+
object.cached = commonAttributes.cached;
|
|
882
|
+
if (commonAttributes.built ||
|
|
883
|
+
commonAttributes.codeGenerated ||
|
|
884
|
+
options.cachedModules) {
|
|
826
885
|
Object.assign(object, factory.create(`${type}$visible`, module, context));
|
|
827
886
|
}
|
|
828
887
|
}
|
|
@@ -830,43 +889,52 @@ const SIMPLE_EXTRACTORS = {
|
|
|
830
889
|
module$visible: {
|
|
831
890
|
_: (object, module, context, options, factory) => {
|
|
832
891
|
const { type } = context;
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
object.
|
|
839
|
-
object.
|
|
840
|
-
object.
|
|
841
|
-
object.
|
|
842
|
-
object.
|
|
892
|
+
const { commonAttributes } = module;
|
|
893
|
+
if (commonAttributes.moduleDescriptor) {
|
|
894
|
+
object.identifier = commonAttributes.moduleDescriptor.identifier;
|
|
895
|
+
object.name = commonAttributes.moduleDescriptor.name;
|
|
896
|
+
}
|
|
897
|
+
object.nameForCondition = commonAttributes.nameForCondition;
|
|
898
|
+
object.index = commonAttributes.preOrderIndex;
|
|
899
|
+
object.preOrderIndex = commonAttributes.preOrderIndex;
|
|
900
|
+
object.index2 = commonAttributes.postOrderIndex;
|
|
901
|
+
object.postOrderIndex = commonAttributes.postOrderIndex;
|
|
902
|
+
object.cacheable = commonAttributes.cacheable;
|
|
903
|
+
object.optional = commonAttributes.optional;
|
|
904
|
+
object.orphan = commonAttributes.orphan;
|
|
843
905
|
object.dependent = module.dependent;
|
|
844
|
-
object.issuer = module.
|
|
845
|
-
object.issuerName = module.
|
|
846
|
-
object.issuerPath =
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
object.
|
|
850
|
-
|
|
906
|
+
object.issuer = module.issuerDescriptor?.identifier;
|
|
907
|
+
object.issuerName = module.issuerDescriptor?.name;
|
|
908
|
+
object.issuerPath =
|
|
909
|
+
module.issuerDescriptor &&
|
|
910
|
+
factory.create(`${type.slice(0, -8)}.issuerPath`, module.issuerPath, context);
|
|
911
|
+
object.failed = commonAttributes.failed;
|
|
912
|
+
object.errors = commonAttributes.errors;
|
|
913
|
+
object.warnings = commonAttributes.warnings;
|
|
914
|
+
const profile = commonAttributes.profile;
|
|
851
915
|
if (profile) {
|
|
852
916
|
object.profile = factory.create(`${type}.profile`, profile, context);
|
|
853
917
|
}
|
|
854
918
|
},
|
|
855
919
|
ids: (object, module) => {
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
920
|
+
const { commonAttributes } = module;
|
|
921
|
+
if (commonAttributes.moduleDescriptor) {
|
|
922
|
+
object.id = commonAttributes.moduleDescriptor.id;
|
|
923
|
+
}
|
|
924
|
+
object.issuerId = module.issuerDescriptor?.id;
|
|
925
|
+
object.chunks = commonAttributes.chunks;
|
|
859
926
|
},
|
|
860
927
|
moduleAssets: (object, module) => {
|
|
861
|
-
object.assets = module.assets;
|
|
928
|
+
object.assets = module.commonAttributes.assets;
|
|
862
929
|
},
|
|
863
930
|
reasons: (object, module, context, options, factory) => {
|
|
864
931
|
const { type } = context;
|
|
865
|
-
object.reasons = factory.create(`${type.slice(0, -8)}.reasons`, module.reasons, context);
|
|
932
|
+
object.reasons = factory.create(`${type.slice(0, -8)}.reasons`, module.commonAttributes.reasons, context);
|
|
866
933
|
// object.filteredReasons
|
|
867
934
|
},
|
|
868
935
|
source: (object, module) => {
|
|
869
|
-
|
|
936
|
+
const { commonAttributes } = module;
|
|
937
|
+
object.source = commonAttributes.source;
|
|
870
938
|
},
|
|
871
939
|
usedExports: (object, module) => {
|
|
872
940
|
if (typeof module.usedExports === "string") {
|
|
@@ -885,18 +953,20 @@ const SIMPLE_EXTRACTORS = {
|
|
|
885
953
|
}
|
|
886
954
|
},
|
|
887
955
|
providedExports: (object, module) => {
|
|
888
|
-
|
|
889
|
-
|
|
956
|
+
const { commonAttributes } = module;
|
|
957
|
+
if (Array.isArray(commonAttributes.providedExports)) {
|
|
958
|
+
object.providedExports = commonAttributes.providedExports;
|
|
890
959
|
}
|
|
891
960
|
else {
|
|
892
961
|
object.providedExports = null;
|
|
893
962
|
}
|
|
894
963
|
},
|
|
895
964
|
optimizationBailout: (object, module) => {
|
|
896
|
-
object.optimizationBailout =
|
|
965
|
+
object.optimizationBailout =
|
|
966
|
+
module.commonAttributes.optimizationBailout || null;
|
|
897
967
|
},
|
|
898
968
|
depth: (object, module) => {
|
|
899
|
-
object.depth = module.depth;
|
|
969
|
+
object.depth = module.commonAttributes.depth;
|
|
900
970
|
},
|
|
901
971
|
nestedModules: (object, module, context, options, factory) => {
|
|
902
972
|
const { type } = context;
|
|
@@ -924,22 +994,28 @@ const SIMPLE_EXTRACTORS = {
|
|
|
924
994
|
},
|
|
925
995
|
moduleIssuer: {
|
|
926
996
|
_: (object, module, context, options, factory) => {
|
|
927
|
-
|
|
928
|
-
|
|
997
|
+
if (module.moduleDescriptor) {
|
|
998
|
+
object.identifier = module.moduleDescriptor.identifier;
|
|
999
|
+
object.name = module.moduleDescriptor.name;
|
|
1000
|
+
}
|
|
929
1001
|
},
|
|
930
1002
|
ids: (object, module) => {
|
|
931
|
-
object.id = module.id;
|
|
1003
|
+
object.id = module.moduleDescriptor.id;
|
|
932
1004
|
}
|
|
933
1005
|
},
|
|
934
1006
|
moduleReason: {
|
|
935
1007
|
_: (object, reason) => {
|
|
936
|
-
|
|
937
|
-
|
|
1008
|
+
if (reason.moduleDescriptor) {
|
|
1009
|
+
object.moduleIdentifier = reason.moduleDescriptor.identifier;
|
|
1010
|
+
object.moduleName = reason.moduleDescriptor.name;
|
|
1011
|
+
}
|
|
938
1012
|
object.type = reason.type;
|
|
939
1013
|
object.userRequest = reason.userRequest;
|
|
940
1014
|
},
|
|
941
1015
|
ids: (object, reason) => {
|
|
942
|
-
object.moduleId = reason.
|
|
1016
|
+
object.moduleId = reason.moduleDescriptor
|
|
1017
|
+
? reason.moduleDescriptor.id
|
|
1018
|
+
: null;
|
|
943
1019
|
}
|
|
944
1020
|
},
|
|
945
1021
|
chunk: {
|
|
@@ -972,7 +1048,18 @@ const SIMPLE_EXTRACTORS = {
|
|
|
972
1048
|
object.modules = factory.create(`${type}.modules`, chunk.modules, context);
|
|
973
1049
|
},
|
|
974
1050
|
chunkOrigins: (object, chunk, context, options, factory) => {
|
|
975
|
-
object.origins = chunk.origins
|
|
1051
|
+
object.origins = chunk.origins.map(origin => {
|
|
1052
|
+
const { moduleDescriptor, loc, request } = origin;
|
|
1053
|
+
const statsChunkOrigin = {
|
|
1054
|
+
module: moduleDescriptor ? moduleDescriptor.identifier : "",
|
|
1055
|
+
moduleIdentifier: moduleDescriptor ? moduleDescriptor.identifier : "",
|
|
1056
|
+
moduleName: moduleDescriptor ? moduleDescriptor.name : "",
|
|
1057
|
+
moduleId: moduleDescriptor ? moduleDescriptor.id : undefined,
|
|
1058
|
+
loc,
|
|
1059
|
+
request
|
|
1060
|
+
};
|
|
1061
|
+
return statsChunkOrigin;
|
|
1062
|
+
});
|
|
976
1063
|
}
|
|
977
1064
|
},
|
|
978
1065
|
// chunkOrigin
|
|
@@ -980,14 +1067,18 @@ const SIMPLE_EXTRACTORS = {
|
|
|
980
1067
|
warning: EXTRACT_ERROR,
|
|
981
1068
|
moduleTraceItem: {
|
|
982
1069
|
_: (object, { origin, module }, context, { requestShortener }, factory) => {
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1070
|
+
if (origin.moduleDescriptor) {
|
|
1071
|
+
object.originIdentifier = origin.moduleDescriptor.identifier;
|
|
1072
|
+
object.originName = origin.moduleDescriptor.name;
|
|
1073
|
+
}
|
|
1074
|
+
if (module.moduleDescriptor) {
|
|
1075
|
+
object.moduleIdentifier = module.moduleDescriptor.identifier;
|
|
1076
|
+
object.moduleName = module.moduleDescriptor.name;
|
|
1077
|
+
}
|
|
987
1078
|
},
|
|
988
1079
|
ids: (object, { origin, module }) => {
|
|
989
|
-
object.originId = origin.id;
|
|
990
|
-
object.moduleId = module.id;
|
|
1080
|
+
object.originId = origin.moduleDescriptor.id;
|
|
1081
|
+
object.moduleId = module.moduleDescriptor.id;
|
|
991
1082
|
}
|
|
992
1083
|
}
|
|
993
1084
|
// moduleTraceDependency
|
|
@@ -194,8 +194,7 @@ const DEFAULTS = {
|
|
|
194
194
|
: forToString
|
|
195
195
|
? all === true
|
|
196
196
|
: all !== false,
|
|
197
|
-
|
|
198
|
-
// cached !== undefined ? cached : forToString ? all === true : all !== false,
|
|
197
|
+
cachedModules: ({ all, cached }, { forToString }) => cached !== undefined ? cached : forToString ? all === true : all !== false,
|
|
199
198
|
moduleAssets: OFF_FOR_TO_STRING,
|
|
200
199
|
depth: OFF_FOR_TO_STRING,
|
|
201
200
|
// cachedAssets: OFF_FOR_TO_STRING,
|
|
@@ -206,7 +206,7 @@ const SIMPLE_PRINTERS = {
|
|
|
206
206
|
"module.codeGenerated": (codeGenerated, { formatFlag, yellow }) => codeGenerated ? yellow(formatFlag("code generated")) : undefined,
|
|
207
207
|
"module.buildTimeExecuted": (buildTimeExecuted, { formatFlag, green }) => buildTimeExecuted ? green(formatFlag("build time executed")) : undefined,
|
|
208
208
|
"module.cached": (cached, { formatFlag, green }) => cached ? green(formatFlag("cached")) : undefined,
|
|
209
|
-
"module.assets": (assets, { formatFlag, magenta }) => assets
|
|
209
|
+
"module.assets": (assets, { formatFlag, magenta }) => assets?.length
|
|
210
210
|
? magenta(formatFlag(`${assets.length} ${plural(assets.length, "asset", "assets")}`))
|
|
211
211
|
: undefined,
|
|
212
212
|
"module.warnings": (warnings, { formatFlag, yellow }) => warnings === true
|
|
@@ -700,7 +700,7 @@ const joinInBrackets = (items) => {
|
|
|
700
700
|
return res.join("");
|
|
701
701
|
};
|
|
702
702
|
const indent = (str, prefix, noPrefixInFirstLine) => {
|
|
703
|
-
const rem = str.replace(/\n([^\n])/g,
|
|
703
|
+
const rem = str.replace(/\n([^\n])/g, `\n${prefix}$1`);
|
|
704
704
|
if (noPrefixInFirstLine)
|
|
705
705
|
return rem;
|
|
706
706
|
const ind = str[0] === "\n" ? "" : prefix;
|
|
@@ -722,7 +722,7 @@ const joinExplicitNewLine = (items, indenter) => {
|
|
|
722
722
|
first = false;
|
|
723
723
|
const noJoiner = firstInLine || content.startsWith("\n");
|
|
724
724
|
firstInLine = content.endsWith("\n");
|
|
725
|
-
return noJoiner ? content :
|
|
725
|
+
return noJoiner ? content : ` ${content}`;
|
|
726
726
|
})
|
|
727
727
|
.filter(Boolean)
|
|
728
728
|
.join("")
|
|
@@ -803,20 +803,19 @@ const SIMPLE_ELEMENT_JOINERS = {
|
|
|
803
803
|
},
|
|
804
804
|
chunk: items => {
|
|
805
805
|
let hasEntry = false;
|
|
806
|
-
return
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
}), " "));
|
|
806
|
+
return `chunk ${joinExplicitNewLine(items.filter(item => {
|
|
807
|
+
switch (item.element) {
|
|
808
|
+
case "entry":
|
|
809
|
+
if (item.content)
|
|
810
|
+
hasEntry = true;
|
|
811
|
+
break;
|
|
812
|
+
case "initial":
|
|
813
|
+
if (hasEntry)
|
|
814
|
+
return false;
|
|
815
|
+
break;
|
|
816
|
+
}
|
|
817
|
+
return true;
|
|
818
|
+
}), " ")}`;
|
|
820
819
|
},
|
|
821
820
|
"chunk.childrenByOrder[]": items => `(${joinOneLine(items)})`,
|
|
822
821
|
chunkGroup: items => joinExplicitNewLine(items, " "),
|
|
@@ -856,11 +855,11 @@ const SIMPLE_ELEMENT_JOINERS = {
|
|
|
856
855
|
},
|
|
857
856
|
"module.profile": joinInBrackets,
|
|
858
857
|
moduleIssuer: joinOneLine,
|
|
859
|
-
chunkOrigin: items =>
|
|
858
|
+
chunkOrigin: items => `> ${joinOneLine(items)}`,
|
|
860
859
|
"errors[].error": joinError(true),
|
|
861
860
|
"warnings[].error": joinError(false),
|
|
862
861
|
loggingGroup: items => joinExplicitNewLine(items, "").trimEnd(),
|
|
863
|
-
moduleTraceItem: items =>
|
|
862
|
+
moduleTraceItem: items => ` @ ${joinOneLine(items)}`,
|
|
864
863
|
moduleTraceDependency: joinOneLine
|
|
865
864
|
};
|
|
866
865
|
const AVAILABLE_COLORS = {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Copyright (c) JS Foundation and other contributors
|
|
8
8
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
|
-
import type { JsStats, JsStatsError, JsStatsWarning } from "@rspack/binding";
|
|
10
|
+
import type { JsStats, JsStatsCompilation, JsStatsError, JsStatsWarning } from "@rspack/binding";
|
|
11
11
|
import { HookMap, SyncBailHook, SyncWaterfallHook } from "@rspack/lite-tapable";
|
|
12
12
|
import type { Compilation } from "../Compilation";
|
|
13
13
|
import { type GroupConfig } from "../util/smartGrouping";
|
|
@@ -17,6 +17,7 @@ export type KnownStatsFactoryContext = {
|
|
|
17
17
|
compilation?: Compilation | undefined;
|
|
18
18
|
cachedGetErrors?: ((arg0: Compilation) => JsStatsError[]) | undefined;
|
|
19
19
|
cachedGetWarnings?: ((arg0: Compilation) => JsStatsWarning[]) | undefined;
|
|
20
|
+
getStatsCompilation: (compilation: Compilation) => JsStatsCompilation;
|
|
20
21
|
getInner: (compilation: Compilation) => JsStats;
|
|
21
22
|
};
|
|
22
23
|
export type StatsFactoryContext = KnownStatsFactoryContext & Record<string, any>;
|
|
@@ -121,9 +121,7 @@ class StatsFactory {
|
|
|
121
121
|
const comparators = [];
|
|
122
122
|
this._forEachLevel(this.hooks.sort, this._caches.sort, type, h => h.call(comparators, context));
|
|
123
123
|
if (comparators.length > 0) {
|
|
124
|
-
items.sort(
|
|
125
|
-
// @ts-expect-error number of arguments is correct
|
|
126
|
-
(0, comparators_1.concatComparators)(...comparators));
|
|
124
|
+
items.sort((0, comparators_1.concatComparators)(...comparators));
|
|
127
125
|
}
|
|
128
126
|
// run filter on sorted items
|
|
129
127
|
const items2 = this._forEachLevelFilter(this.hooks.filterSorted, this._caches.filterSorted, type, items, (h, r, idx, i) => h.call(r, context, idx, i), false);
|
|
@@ -147,9 +145,7 @@ class StatsFactory {
|
|
|
147
145
|
const comparators2 = [];
|
|
148
146
|
this._forEachLevel(this.hooks.sortResults, this._caches.sortResults, type, h => h.call(comparators2, context));
|
|
149
147
|
if (comparators2.length > 0) {
|
|
150
|
-
resultItems.sort(
|
|
151
|
-
// @ts-expect-error number of arguments is correct
|
|
152
|
-
(0, comparators_1.concatComparators)(...comparators2));
|
|
148
|
+
resultItems.sort((0, comparators_1.concatComparators)(...comparators2));
|
|
153
149
|
}
|
|
154
150
|
// group result items
|
|
155
151
|
const groupConfigs = [];
|