webpack 5.20.1 → 5.21.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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

@@ -111,6 +111,24 @@ const SIMPLE_PRINTERS = {
111
111
  )
112
112
  return `${builtAtMessage}${subjectMessage} ${statusMessage}${timeMessage}${hashMessage}`;
113
113
  },
114
+ "compilation.filteredWarningDetailsCount": count =>
115
+ count
116
+ ? `${count} ${plural(
117
+ count,
118
+ "warning has",
119
+ "warnings have"
120
+ )} detailed information that is not shown.\nUse 'stats.errorDetails: true' resp. '--stats-error-details' to show it.`
121
+ : undefined,
122
+ "compilation.filteredErrorDetailsCount": (count, { yellow }) =>
123
+ count
124
+ ? yellow(
125
+ `${count} ${plural(
126
+ count,
127
+ "error has",
128
+ "errors have"
129
+ )} detailed information that is not shown.\nUse 'stats.errorDetails: true' resp. '--stats-error-details' to show it.`
130
+ )
131
+ : undefined,
114
132
  "compilation.env": (env, { bold }) =>
115
133
  env
116
134
  ? `Environment (--env): ${bold(JSON.stringify(env, null, 2))}`
@@ -321,7 +339,7 @@ const SIMPLE_PRINTERS = {
321
339
  : null;
322
340
  if (
323
341
  providedExportsCount !== null &&
324
- providedExportsCount === module.usedExports.length
342
+ providedExportsCount === usedExports.length
325
343
  ) {
326
344
  return cyan(formatFlag("all exports used"));
327
345
  } else {
@@ -484,8 +502,9 @@ const SIMPLE_PRINTERS = {
484
502
  : `${bold(moduleName)}`;
485
503
  },
486
504
  "error.loc": (loc, { green }) => green(loc),
487
- "error.message": (message, { bold }) => bold(message),
488
- "error.details": details => details,
505
+ "error.message": (message, { bold, formatError }) =>
506
+ message.includes("\u001b[") ? message : bold(formatError(message)),
507
+ "error.details": (details, { formatError }) => formatError(details),
489
508
  "error.stack": stack => stack,
490
509
  "error.moduleTrace": moduleTrace => undefined,
491
510
  "error.separator!": () => "\n",
@@ -613,8 +632,10 @@ const PREFERRED_ORDERS = {
613
632
  "logging",
614
633
  "warnings",
615
634
  "warningsInChildren!",
635
+ "filteredWarningDetailsCount",
616
636
  "errors",
617
637
  "errorsInChildren!",
638
+ "filteredErrorDetailsCount",
618
639
  "summary!",
619
640
  "needAdditionalPass"
620
641
  ],
@@ -895,7 +916,9 @@ const SIMPLE_ELEMENT_JOINERS = {
895
916
  if (!item.content) continue;
896
917
  const needMoreSpace =
897
918
  item.element === "warnings" ||
919
+ item.element === "filteredWarningDetailsCount" ||
898
920
  item.element === "errors" ||
921
+ item.element === "filteredErrorDetailsCount" ||
899
922
  item.element === "logging";
900
923
  if (result.length !== 0) {
901
924
  result.push(needMoreSpace || lastNeedMore ? "\n\n" : "\n");
@@ -1072,6 +1095,40 @@ const AVAILABLE_FORMATS = {
1072
1095
  } else {
1073
1096
  return `${boldQuantity ? bold(time) : time}${unit}`;
1074
1097
  }
1098
+ },
1099
+ formatError: (message, { green, yellow, red }) => {
1100
+ if (message.includes("\u001b[")) return message;
1101
+ const highlights = [
1102
+ { regExp: /(Did you mean .+)/g, format: green },
1103
+ {
1104
+ regExp: /(Set 'mode' option to 'development' or 'production')/g,
1105
+ format: green
1106
+ },
1107
+ { regExp: /(\(module has no exports\))/g, format: red },
1108
+ { regExp: /\(possible exports: (.+)\)/g, format: green },
1109
+ { regExp: /\s*(.+ doesn't exist)/g, format: red },
1110
+ { regExp: /('\w+' option has not been set)/g, format: red },
1111
+ {
1112
+ regExp: /(Emitted value instead of an instance of Error)/g,
1113
+ format: yellow
1114
+ },
1115
+ { regExp: /(Used? .+ instead)/gi, format: yellow },
1116
+ { regExp: /\b(deprecated|must|required)\b/g, format: yellow },
1117
+ {
1118
+ regExp: /\b(BREAKING CHANGE)\b/gi,
1119
+ format: red
1120
+ },
1121
+ {
1122
+ regExp: /\b(error|failed|unexpected|invalid|not found|not supported|not available|not possible|not implemented|doesn't support|conflict|conflicting|not existing|duplicate)\b/gi,
1123
+ format: red
1124
+ }
1125
+ ];
1126
+ for (const { regExp, format } of highlights) {
1127
+ message = message.replace(regExp, (match, content) => {
1128
+ return match.replace(content, format(content));
1129
+ });
1130
+ }
1131
+ return message;
1075
1132
  }
1076
1133
  };
1077
1134
 
@@ -1128,7 +1185,15 @@ class DefaultStatsPrinterPlugin {
1128
1185
  }
1129
1186
  }
1130
1187
  if (start) {
1131
- context[color] = str => `${start}${str}\u001b[39m\u001b[22m`;
1188
+ context[color] = str =>
1189
+ `${start}${
1190
+ typeof str === "string"
1191
+ ? str.replace(
1192
+ /((\u001b\[39m|\u001b\[22m|\u001b\[0m)+)/g,
1193
+ `$1${start}`
1194
+ )
1195
+ : str
1196
+ }\u001b[39m\u001b[22m`;
1132
1197
  } else {
1133
1198
  context[color] = str => str;
1134
1199
  }
@@ -9,6 +9,12 @@ const { HookMap, SyncWaterfallHook, SyncBailHook } = require("tapable");
9
9
 
10
10
  /** @template T @typedef {import("tapable").AsArray<T>} AsArray<T> */
11
11
  /** @typedef {import("tapable").Hook} Hook */
12
+ /** @typedef {import("./DefaultStatsFactoryPlugin").StatsAsset} StatsAsset */
13
+ /** @typedef {import("./DefaultStatsFactoryPlugin").StatsChunk} StatsChunk */
14
+ /** @typedef {import("./DefaultStatsFactoryPlugin").StatsChunkGroup} StatsChunkGroup */
15
+ /** @typedef {import("./DefaultStatsFactoryPlugin").StatsCompilation} StatsCompilation */
16
+ /** @typedef {import("./DefaultStatsFactoryPlugin").StatsModule} StatsModule */
17
+ /** @typedef {import("./DefaultStatsFactoryPlugin").StatsModuleReason} StatsModuleReason */
12
18
 
13
19
  /**
14
20
  * @typedef {Object} PrintedElement
@@ -19,12 +25,12 @@ const { HookMap, SyncWaterfallHook, SyncBailHook } = require("tapable");
19
25
  /**
20
26
  * @typedef {Object} KnownStatsPrinterContext
21
27
  * @property {string=} type
22
- * @property {Object=} compilation
23
- * @property {Object=} chunkGroup
24
- * @property {Object=} asset
25
- * @property {Object=} module
26
- * @property {Object=} chunk
27
- * @property {Object=} moduleReason
28
+ * @property {StatsCompilation=} compilation
29
+ * @property {StatsChunkGroup=} chunkGroup
30
+ * @property {StatsAsset=} asset
31
+ * @property {StatsModule=} module
32
+ * @property {StatsChunk=} chunk
33
+ * @property {StatsModuleReason=} moduleReason
28
34
  * @property {(str: string) => string=} bold
29
35
  * @property {(str: string) => string=} yellow
30
36
  * @property {(str: string) => string=} red
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.20.1",
3
+ "version": "5.21.2",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",
@@ -3882,7 +3882,14 @@
3882
3882
  },
3883
3883
  "errorDetails": {
3884
3884
  "description": "Add details to errors (like resolving log).",
3885
- "type": "boolean"
3885
+ "anyOf": [
3886
+ {
3887
+ "enum": ["auto"]
3888
+ },
3889
+ {
3890
+ "type": "boolean"
3891
+ }
3892
+ ]
3886
3893
  },
3887
3894
  "errorStack": {
3888
3895
  "description": "Add internal stack trace to errors.",
package/types.d.ts CHANGED
@@ -3796,6 +3796,11 @@ declare interface GenerateContext {
3796
3796
  * which kind of code should be generated
3797
3797
  */
3798
3798
  type: string;
3799
+
3800
+ /**
3801
+ * get access to the code generation data
3802
+ */
3803
+ getData?: () => Map<string, any>;
3799
3804
  }
3800
3805
  declare class Generator {
3801
3806
  constructor();
@@ -5053,6 +5058,108 @@ declare interface KnownNormalizedStatsOptions {
5053
5058
  loggingDebug: Function[];
5054
5059
  loggingTrace: boolean;
5055
5060
  }
5061
+ declare interface KnownStatsAsset {
5062
+ type: string;
5063
+ name: string;
5064
+ info: AssetInfo;
5065
+ size: number;
5066
+ emitted: boolean;
5067
+ comparedForEmit: boolean;
5068
+ cached: boolean;
5069
+ related?: StatsAsset[];
5070
+ chunkNames?: (string | number)[];
5071
+ chunkIdHints?: (string | number)[];
5072
+ chunks?: (string | number)[];
5073
+ auxiliaryChunkNames?: (string | number)[];
5074
+ auxiliaryChunks?: (string | number)[];
5075
+ auxiliaryChunkIdHints?: (string | number)[];
5076
+ filteredRelated?: number;
5077
+ isOverSizeLimit?: boolean;
5078
+ }
5079
+ declare interface KnownStatsChunk {
5080
+ rendered: boolean;
5081
+ initial: boolean;
5082
+ entry: boolean;
5083
+ recorded: boolean;
5084
+ reason?: string;
5085
+ size: number;
5086
+ sizes?: Record<string, number>;
5087
+ names?: string[];
5088
+ idHints?: string[];
5089
+ runtime?: string[];
5090
+ files?: string[];
5091
+ auxiliaryFiles?: string[];
5092
+ hash: string;
5093
+ childrenByOrder?: Record<string, (string | number)[]>;
5094
+ id?: string | number;
5095
+ siblings?: (string | number)[];
5096
+ parents?: (string | number)[];
5097
+ children?: (string | number)[];
5098
+ modules?: StatsModule[];
5099
+ filteredModules?: number;
5100
+ origins?: StatsChunkOrigin[];
5101
+ }
5102
+ declare interface KnownStatsChunkGroup {
5103
+ name?: string;
5104
+ chunks?: (string | number)[];
5105
+ assets?: { name: string; size?: number }[];
5106
+ filteredAssets?: number;
5107
+ assetsSize?: number;
5108
+ auxiliaryAssets?: { name: string; size?: number }[];
5109
+ filteredAuxiliaryAssets?: number;
5110
+ auxiliaryAssetsSize?: number;
5111
+ children?: { [index: string]: StatsChunkGroup[] };
5112
+ childAssets?: { [index: string]: string[] };
5113
+ isOverSizeLimit?: boolean;
5114
+ }
5115
+ declare interface KnownStatsChunkOrigin {
5116
+ module?: string;
5117
+ moduleIdentifier?: string;
5118
+ moduleName?: string;
5119
+ loc?: string;
5120
+ request?: string;
5121
+ moduleId?: string | number;
5122
+ }
5123
+ declare interface KnownStatsCompilation {
5124
+ env?: any;
5125
+ name?: string;
5126
+ hash?: string;
5127
+ version?: string;
5128
+ time?: number;
5129
+ builtAt?: number;
5130
+ needAdditionalPass?: boolean;
5131
+ publicPath?: string;
5132
+ outputPath?: string;
5133
+ assetsByChunkName?: Record<string, string[]>;
5134
+ assets?: StatsAsset[];
5135
+ filteredAssets?: number;
5136
+ chunks?: StatsChunk[];
5137
+ modules?: StatsModule[];
5138
+ filteredModules?: number;
5139
+ entrypoints?: Record<string, StatsChunkGroup>;
5140
+ namedChunkGroups?: Record<string, StatsChunkGroup>;
5141
+ errors?: StatsError[];
5142
+ errorsCount?: number;
5143
+ warnings?: StatsError[];
5144
+ warningsCount?: number;
5145
+ children?: StatsCompilation[];
5146
+ logging?: Record<string, StatsLogging>;
5147
+ }
5148
+ declare interface KnownStatsError {
5149
+ message: string;
5150
+ chunkName?: string;
5151
+ chunkEntry?: boolean;
5152
+ chunkInitial?: boolean;
5153
+ file?: string;
5154
+ moduleIdentifier?: string;
5155
+ moduleName?: string;
5156
+ loc?: string;
5157
+ chunkId?: string | number;
5158
+ moduleId?: string | number;
5159
+ moduleTrace?: any;
5160
+ details?: any;
5161
+ stack?: any;
5162
+ }
5056
5163
  declare interface KnownStatsFactoryContext {
5057
5164
  type: string;
5058
5165
  makePathsRelative?: (arg0: string) => string;
@@ -5064,14 +5171,87 @@ declare interface KnownStatsFactoryContext {
5064
5171
  cachedGetErrors?: (arg0: Compilation) => WebpackError[];
5065
5172
  cachedGetWarnings?: (arg0: Compilation) => WebpackError[];
5066
5173
  }
5174
+ declare interface KnownStatsLogging {
5175
+ entries: StatsLoggingEntry[];
5176
+ filteredEntries: number;
5177
+ debug: boolean;
5178
+ }
5179
+ declare interface KnownStatsLoggingEntry {
5180
+ type: string;
5181
+ message: string;
5182
+ trace?: string[];
5183
+ children?: StatsLoggingEntry[];
5184
+ args?: any[];
5185
+ time?: number;
5186
+ }
5187
+ declare interface KnownStatsModule {
5188
+ type?: string;
5189
+ moduleType?: string;
5190
+ layer?: string;
5191
+ identifier?: string;
5192
+ name?: string;
5193
+ nameForCondition?: string;
5194
+ index?: number;
5195
+ preOrderIndex?: number;
5196
+ index2?: number;
5197
+ postOrderIndex?: number;
5198
+ size?: number;
5199
+ sizes?: { [index: string]: number };
5200
+ cacheable?: boolean;
5201
+ built?: boolean;
5202
+ codeGenerated?: boolean;
5203
+ cached?: boolean;
5204
+ optional?: boolean;
5205
+ orphan?: boolean;
5206
+ id?: string | number;
5207
+ issuerId?: string | number;
5208
+ chunks?: (string | number)[];
5209
+ assets?: (string | number)[];
5210
+ dependent?: boolean;
5211
+ issuer?: string;
5212
+ issuerName?: string;
5213
+ issuerPath?: StatsModuleIssuer[];
5214
+ failed?: boolean;
5215
+ errors?: number;
5216
+ warnings?: number;
5217
+ profile?: StatsProfile;
5218
+ reasons?: StatsModuleReason[];
5219
+ usedExports?: boolean | string[];
5220
+ providedExports?: string[];
5221
+ optimizationBailout?: string[];
5222
+ depth?: number;
5223
+ modules?: StatsModule[];
5224
+ filteredModules?: number;
5225
+ source?: string | Buffer;
5226
+ }
5227
+ declare interface KnownStatsModuleIssuer {
5228
+ identifier?: string;
5229
+ name?: string;
5230
+ id?: string | number;
5231
+ profile?: StatsProfile;
5232
+ }
5233
+ declare interface KnownStatsModuleReason {
5234
+ moduleIdentifier?: string;
5235
+ module?: string;
5236
+ moduleName?: string;
5237
+ resolvedModuleIdentifier?: string;
5238
+ resolvedModule?: string;
5239
+ type?: string;
5240
+ active: boolean;
5241
+ explanation?: string;
5242
+ userRequest?: string;
5243
+ loc?: string;
5244
+ moduleId?: string | number;
5245
+ resolvedModuleId?: string | number;
5246
+ }
5067
5247
  declare interface KnownStatsPrinterContext {
5068
5248
  type?: string;
5069
- compilation?: Object;
5070
- chunkGroup?: Object;
5071
- asset?: Object;
5072
- module?: Object;
5073
- chunk?: Object;
5074
- moduleReason?: Object;
5249
+ compilation?: StatsCompilation;
5250
+ chunkGroup?: StatsChunkGroup;
5251
+ asset?: StatsAsset;
5252
+ module?: StatsModule;
5253
+ chunk?: StatsChunk;
5254
+ moduleReason?: StatsModuleReason;
5075
5255
  bold?: (str: string) => string;
5076
5256
  yellow?: (str: string) => string;
5077
5257
  red?: (str: string) => string;
@@ -5090,6 +5270,18 @@ declare interface KnownStatsPrinterContext {
5090
5270
  formatTime?: (time: number, boldQuantity?: boolean) => string;
5091
5271
  chunkGroupKind?: string;
5092
5272
  }
5273
+ declare interface KnownStatsProfile {
5274
+ total: number;
5275
+ resolving: number;
5276
+ restoring: number;
5277
+ building: number;
5278
+ integration: number;
5279
+ storing: number;
5280
+ additionalResolving: number;
5281
+ additionalIntegration: number;
5282
+ factory: number;
5283
+ dependencies: number;
5284
+ }
5093
5285
  declare class LazySet<T> {
5094
5286
  constructor(iterable?: Iterable<T>);
5095
5287
  readonly size: number;
@@ -6081,17 +6273,7 @@ declare abstract class MultiStats {
6081
6273
  readonly hash: string;
6082
6274
  hasErrors(): boolean;
6083
6275
  hasWarnings(): boolean;
6084
- toJson(
6085
- options?: any
6086
- ): {
6087
- children: any[];
6088
- version: any;
6089
- hash: string;
6090
- errors: any[];
6091
- warnings: any[];
6092
- errorsCount: number;
6093
- warningsCount: number;
6094
- };
6276
+ toJson(options?: any): StatsCompilation;
6095
6277
  toString(options?: any): string;
6096
6278
  }
6097
6279
  declare abstract class MultiWatching {
@@ -9708,9 +9890,15 @@ declare class Stats {
9708
9890
  readonly endTime: any;
9709
9891
  hasWarnings(): boolean;
9710
9892
  hasErrors(): boolean;
9711
- toJson(options?: any): any;
9893
+ toJson(options?: string | StatsOptions): StatsCompilation;
9712
9894
  toString(options?: any): string;
9713
9895
  }
9896
+ type StatsAsset = KnownStatsAsset & Record<string, any>;
9897
+ type StatsChunk = KnownStatsChunk & Record<string, any>;
9898
+ type StatsChunkGroup = KnownStatsChunkGroup & Record<string, any>;
9899
+ type StatsChunkOrigin = KnownStatsChunkOrigin & Record<string, any>;
9900
+ type StatsCompilation = KnownStatsCompilation & Record<string, any>;
9901
+ type StatsError = KnownStatsError & Record<string, any>;
9714
9902
  declare abstract class StatsFactory {
9715
9903
  hooks: Readonly<{
9716
9904
  extract: HookMap<SyncBailHook<[Object, any, StatsFactoryContext], any>>;
@@ -9750,6 +9938,11 @@ declare abstract class StatsFactory {
9750
9938
  ): any;
9751
9939
  }
9752
9940
  type StatsFactoryContext = KnownStatsFactoryContext & Record<string, any>;
9941
+ type StatsLogging = KnownStatsLogging & Record<string, any>;
9942
+ type StatsLoggingEntry = KnownStatsLoggingEntry & Record<string, any>;
9943
+ type StatsModule = KnownStatsModule & Record<string, any>;
9944
+ type StatsModuleIssuer = KnownStatsModuleIssuer & Record<string, any>;
9945
+ type StatsModuleReason = KnownStatsModuleReason & Record<string, any>;
9753
9946
 
9754
9947
  /**
9755
9948
  * Stats options object.
@@ -9910,7 +10103,7 @@ declare interface StatsOptions {
9910
10103
  /**
9911
10104
  * Add details to errors (like resolving log).
9912
10105
  */
9913
- errorDetails?: boolean;
10106
+ errorDetails?: boolean | "auto";
9914
10107
 
9915
10108
  /**
9916
10109
  * Add internal stack trace to errors.
@@ -10180,6 +10373,7 @@ declare abstract class StatsPrinter {
10180
10373
  print(type: string, object: Object, baseContext?: Object): string;
10181
10374
  }
10182
10375
  type StatsPrinterContext = KnownStatsPrinterContext & Record<string, any>;
10376
+ type StatsProfile = KnownStatsProfile & Record<string, any>;
10183
10377
  type StatsValue =
10184
10378
  | boolean
10185
10379
  | "none"
@@ -11259,7 +11453,8 @@ declare namespace exports {
11259
11453
  WebpackPluginInstance,
11260
11454
  Asset,
11261
11455
  AssetInfo,
11262
- ParserState
11456
+ ParserState,
11457
+ StatsCompilation
11263
11458
  };
11264
11459
  }
11265
11460