webpack 5.85.0 → 5.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

Files changed (48) hide show
  1. package/lib/APIPlugin.js +150 -99
  2. package/lib/Chunk.js +35 -17
  3. package/lib/ChunkGroup.js +10 -6
  4. package/lib/Compiler.js +1 -2
  5. package/lib/ContextModule.js +4 -2
  6. package/lib/ContextModuleFactory.js +1 -0
  7. package/lib/DependenciesBlock.js +1 -1
  8. package/lib/DllModule.js +6 -0
  9. package/lib/EvalSourceMapDevToolPlugin.js +2 -1
  10. package/lib/ExternalModule.js +15 -8
  11. package/lib/Module.js +7 -1
  12. package/lib/ProgressPlugin.js +71 -15
  13. package/lib/WebpackOptionsApply.js +3 -1
  14. package/lib/css/CssExportsGenerator.js +9 -0
  15. package/lib/css/CssGenerator.js +1 -1
  16. package/lib/css/CssLoadingRuntimeModule.js +13 -6
  17. package/lib/css/CssModulesPlugin.js +37 -12
  18. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +8 -10
  19. package/lib/dependencies/HarmonyImportSpecifierDependency.js +12 -12
  20. package/lib/dependencies/JsonExportsDependency.js +1 -1
  21. package/lib/javascript/BasicEvaluatedExpression.js +6 -5
  22. package/lib/javascript/JavascriptModulesPlugin.js +1 -0
  23. package/lib/javascript/JavascriptParser.js +23 -23
  24. package/lib/json/JsonData.js +2 -2
  25. package/lib/json/JsonParser.js +25 -12
  26. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -1
  27. package/lib/optimize/AggressiveMergingPlugin.js +8 -0
  28. package/lib/optimize/AggressiveSplittingPlugin.js +9 -2
  29. package/lib/optimize/EnsureChunkConditionsPlugin.js +3 -0
  30. package/lib/optimize/FlagIncludedChunksPlugin.js +11 -5
  31. package/lib/optimize/InnerGraph.js +4 -4
  32. package/lib/optimize/LimitChunkCountPlugin.js +29 -4
  33. package/lib/optimize/MangleExportsPlugin.js +1 -1
  34. package/lib/optimize/MinMaxSizeWarning.js +5 -0
  35. package/lib/optimize/ModuleConcatenationPlugin.js +59 -2
  36. package/lib/optimize/RealContentHashPlugin.js +80 -30
  37. package/lib/optimize/RemoveParentModulesPlugin.js +6 -0
  38. package/lib/optimize/RuntimeChunkPlugin.js +9 -1
  39. package/lib/optimize/SideEffectsFlagPlugin.js +10 -1
  40. package/lib/optimize/SplitChunksPlugin.js +71 -31
  41. package/lib/serialization/BinaryMiddleware.js +143 -1
  42. package/lib/serialization/ErrorObjectSerializer.js +3 -0
  43. package/lib/serialization/ObjectMiddleware.js +3 -0
  44. package/lib/serialization/types.js +1 -1
  45. package/package.json +1 -1
  46. package/schemas/WebpackOptions.check.js +1 -1
  47. package/schemas/WebpackOptions.json +12 -0
  48. package/types.d.ts +53 -41
@@ -2625,6 +2625,10 @@
2625
2625
  {
2626
2626
  "enum": ["initial", "async", "all"]
2627
2627
  },
2628
+ {
2629
+ "instanceof": "RegExp",
2630
+ "tsType": "RegExp"
2631
+ },
2628
2632
  {
2629
2633
  "instanceof": "Function",
2630
2634
  "tsType": "((chunk: import('../lib/Chunk')) => boolean)"
@@ -2872,6 +2876,10 @@
2872
2876
  {
2873
2877
  "enum": ["initial", "async", "all"]
2874
2878
  },
2879
+ {
2880
+ "instanceof": "RegExp",
2881
+ "tsType": "RegExp"
2882
+ },
2875
2883
  {
2876
2884
  "instanceof": "Function",
2877
2885
  "tsType": "((chunk: import('../lib/Chunk')) => boolean)"
@@ -2911,6 +2919,10 @@
2911
2919
  {
2912
2920
  "enum": ["initial", "async", "all"]
2913
2921
  },
2922
+ {
2923
+ "instanceof": "RegExp",
2924
+ "tsType": "RegExp"
2925
+ },
2914
2926
  {
2915
2927
  "instanceof": "Function",
2916
2928
  "tsType": "((chunk: import('../lib/Chunk')) => boolean)"
package/types.d.ts CHANGED
@@ -167,14 +167,20 @@ declare interface AdditionalData {
167
167
  webpackAST: object;
168
168
  }
169
169
  declare class AggressiveMergingPlugin {
170
- constructor(options?: any);
171
- options: any;
170
+ constructor(options?: AggressiveMergingPluginOptions);
171
+ options: AggressiveMergingPluginOptions;
172
172
 
173
173
  /**
174
174
  * Apply the plugin
175
175
  */
176
176
  apply(compiler: Compiler): void;
177
177
  }
178
+ declare interface AggressiveMergingPluginOptions {
179
+ /**
180
+ * minimal size reduction to trigger merging
181
+ */
182
+ minSizeReduce?: number;
183
+ }
178
184
  declare class AggressiveSplittingPlugin {
179
185
  constructor(options?: AggressiveSplittingPluginOptions);
180
186
  options: AggressiveSplittingPluginOptions;
@@ -507,7 +513,7 @@ declare abstract class BasicEvaluatedExpression {
507
513
  rootInfo: string | VariableInfoInterface;
508
514
  getMembers: () => string[];
509
515
  getMembersOptionals: () => boolean[];
510
- getMemberRangeStarts: () => number[];
516
+ getMemberRanges: () => [number, number][];
511
517
  expression: NodeEstreeIndex;
512
518
  isUnknown(): boolean;
513
519
  isNull(): boolean;
@@ -593,7 +599,7 @@ declare abstract class BasicEvaluatedExpression {
593
599
  rootInfo: string | VariableInfoInterface,
594
600
  getMembers: () => string[],
595
601
  getMembersOptionals?: () => boolean[],
596
- getMemberRangeStarts?: () => number[]
602
+ getMemberRanges?: () => [number, number][]
597
603
  ): BasicEvaluatedExpression;
598
604
 
599
605
  /**
@@ -658,6 +664,9 @@ declare abstract class BasicEvaluatedExpression {
658
664
  */
659
665
  setExpression(expression: NodeEstreeIndex): BasicEvaluatedExpression;
660
666
  }
667
+ declare interface BuildInfo {
668
+ [index: string]: any;
669
+ }
661
670
  type BuildMeta = KnownBuildMeta & Record<string, any>;
662
671
  declare abstract class ByTypeGenerator extends Generator {
663
672
  map: any;
@@ -749,7 +758,7 @@ declare interface CacheGroupSource {
749
758
  chunks?: Chunk[],
750
759
  key?: string
751
760
  ) => undefined | string;
752
- chunksFilter?: (chunk: Chunk) => boolean;
761
+ chunksFilter?: (chunk: Chunk) => undefined | boolean;
753
762
  enforce?: boolean;
754
763
  minSize: SplitChunksSizes;
755
764
  minSizeReduction: SplitChunksSizes;
@@ -762,7 +771,7 @@ declare interface CacheGroupSource {
762
771
  maxInitialRequests?: number;
763
772
  filename?: string | ((arg0: PathData, arg1?: AssetInfo) => string);
764
773
  idHint?: string;
765
- automaticNameDelimiter: string;
774
+ automaticNameDelimiter?: string;
766
775
  reuseExistingChunk?: boolean;
767
776
  usedExports?: boolean;
768
777
  }
@@ -788,7 +797,7 @@ declare interface CallExpressionInfo {
788
797
  name: string;
789
798
  getMembers: () => string[];
790
799
  getMembersOptionals: () => boolean[];
791
- getMemberRangeStarts: () => number[];
800
+ getMemberRanges: () => [number, number][];
792
801
  }
793
802
  declare interface CallbackAsyncQueue<T> {
794
803
  (err?: null | WebpackError, result?: T): any;
@@ -809,19 +818,13 @@ type Cell<T> = undefined | T;
809
818
  declare class Chunk {
810
819
  constructor(name?: string, backCompat?: boolean);
811
820
  id: null | string | number;
812
- ids: null | (string | number)[];
821
+ ids: null | ChunkId[];
813
822
  debugId: number;
814
- name: string;
823
+ name?: string;
815
824
  idNameHints: SortableSet<string>;
816
825
  preventIntegration: boolean;
817
- filenameTemplate:
818
- | null
819
- | string
820
- | ((arg0: PathData, arg1?: AssetInfo) => string);
821
- cssFilenameTemplate:
822
- | null
823
- | string
824
- | ((arg0: PathData, arg1?: AssetInfo) => string);
826
+ filenameTemplate?: string | ((arg0: PathData, arg1?: AssetInfo) => string);
827
+ cssFilenameTemplate?: string | ((arg0: PathData, arg1?: AssetInfo) => string);
825
828
  runtime: RuntimeSpec;
826
829
  files: Set<string>;
827
830
  auxiliaryFiles: Set<string>;
@@ -878,7 +881,7 @@ declare class Chunk {
878
881
  getChildrenOfTypeInOrder(
879
882
  chunkGraph: ChunkGraph,
880
883
  type: string
881
- ): { onChunks: Chunk[]; chunks: Set<Chunk> }[];
884
+ ): undefined | { onChunks: Chunk[]; chunks: Set<Chunk> }[];
882
885
  getChildIdsByOrdersMap(
883
886
  chunkGraph: ChunkGraph,
884
887
  includeDirectChildren?: boolean,
@@ -1066,7 +1069,7 @@ declare abstract class ChunkGroup {
1066
1069
  options: ChunkGroupOptions;
1067
1070
  chunks: Chunk[];
1068
1071
  origins: OriginRecord[];
1069
- index: number;
1072
+ index?: number;
1070
1073
 
1071
1074
  /**
1072
1075
  * when a new chunk is added to a chunkGroup, addingOptions will occur.
@@ -1147,7 +1150,7 @@ declare abstract class ChunkGroup {
1147
1150
  /**
1148
1151
  * Gets the top-down index of a module in this ChunkGroup
1149
1152
  */
1150
- getModulePreOrderIndex(module: Module): number;
1153
+ getModulePreOrderIndex(module: Module): undefined | number;
1151
1154
 
1152
1155
  /**
1153
1156
  * Sets the bottom-up index of a module in this ChunkGroup
@@ -1157,10 +1160,10 @@ declare abstract class ChunkGroup {
1157
1160
  /**
1158
1161
  * Gets the bottom-up index of a module in this ChunkGroup
1159
1162
  */
1160
- getModulePostOrderIndex(module: Module): number;
1163
+ getModulePostOrderIndex(module: Module): undefined | number;
1161
1164
  checkConstraints(): void;
1162
- getModuleIndex: (module: Module) => number;
1163
- getModuleIndex2: (module: Module) => number;
1165
+ getModuleIndex: (module: Module) => undefined | number;
1166
+ getModuleIndex2: (module: Module) => undefined | number;
1164
1167
  }
1165
1168
  type ChunkGroupOptions = RawChunkGroupOptions & { name?: string };
1166
1169
  declare interface ChunkHashContext {
@@ -1184,6 +1187,7 @@ declare interface ChunkHashContext {
1184
1187
  */
1185
1188
  chunkGraph: ChunkGraph;
1186
1189
  }
1190
+ type ChunkId = string | number;
1187
1191
  declare interface ChunkMaps {
1188
1192
  hash: Record<string | number, string>;
1189
1193
  contentHash: Record<string | number, Record<string, string>>;
@@ -2682,6 +2686,7 @@ declare interface ContextModuleOptions {
2682
2686
  * exports referenced from modules (won't be mangled)
2683
2687
  */
2684
2688
  referencedExports?: string[][];
2689
+ layer?: string;
2685
2690
  resource: string | false | string[];
2686
2691
  resourceQuery?: string;
2687
2692
  resourceFragment?: string;
@@ -2757,7 +2762,7 @@ declare interface DepConstructor {
2757
2762
  declare abstract class DependenciesBlock {
2758
2763
  dependencies: Dependency[];
2759
2764
  blocks: AsyncDependenciesBlock[];
2760
- parent: DependenciesBlock;
2765
+ parent?: DependenciesBlock;
2761
2766
  getRootBlock(): DependenciesBlock;
2762
2767
 
2763
2768
  /**
@@ -3991,7 +3996,7 @@ declare interface ExpressionExpressionInfo {
3991
3996
  name: string;
3992
3997
  getMembers: () => string[];
3993
3998
  getMembersOptionals: () => boolean[];
3994
- getMemberRangeStarts: () => number[];
3999
+ getMemberRanges: () => [number, number][];
3995
4000
  }
3996
4001
  declare interface ExtensionAliasOption {
3997
4002
  alias: string | string[];
@@ -4190,7 +4195,7 @@ declare interface FactorizeModuleOptions {
4190
4195
  type FakeHook<T> = T & FakeHookMarker;
4191
4196
  declare interface FakeHookMarker {}
4192
4197
  declare interface FallbackCacheGroup {
4193
- chunksFilter: (chunk: Chunk) => boolean;
4198
+ chunksFilter: (chunk: Chunk) => undefined | boolean;
4194
4199
  minSize: SplitChunksSizes;
4195
4200
  maxAsyncSize: SplitChunksSizes;
4196
4201
  maxInitialSize: SplitChunksSizes;
@@ -5344,7 +5349,7 @@ declare class JavascriptParser extends Parser {
5344
5349
  call: HookMap<SyncBailHook<[BaseCallExpression], boolean | void>>;
5345
5350
  callMemberChain: HookMap<
5346
5351
  SyncBailHook<
5347
- [CallExpression, string[], boolean[], number[]],
5352
+ [CallExpression, string[], boolean[], [number, number][]],
5348
5353
  boolean | void
5349
5354
  >
5350
5355
  >;
@@ -5365,7 +5370,10 @@ declare class JavascriptParser extends Parser {
5365
5370
  binaryExpression: SyncBailHook<[BinaryExpression], boolean | void>;
5366
5371
  expression: HookMap<SyncBailHook<[Expression], boolean | void>>;
5367
5372
  expressionMemberChain: HookMap<
5368
- SyncBailHook<[Expression, string[], boolean[], number[]], boolean | void>
5373
+ SyncBailHook<
5374
+ [Expression, string[], boolean[], [number, number][]],
5375
+ boolean | void
5376
+ >
5369
5377
  >;
5370
5378
  unhandledExpressionMemberChain: HookMap<
5371
5379
  SyncBailHook<[Expression, string[]], boolean | void>
@@ -5954,7 +5962,7 @@ declare class JavascriptParser extends Parser {
5954
5962
  | YieldExpression
5955
5963
  | Super;
5956
5964
  membersOptionals: boolean[];
5957
- memberRangeStarts: number[];
5965
+ memberRanges: [number, number][];
5958
5966
  };
5959
5967
  getFreeInfoFromVariable(varName: string): {
5960
5968
  name: string;
@@ -7264,7 +7272,7 @@ declare class Module extends DependenciesBlock {
7264
7272
  useSourceMap: boolean;
7265
7273
  useSimpleSourceMap: boolean;
7266
7274
  buildMeta?: BuildMeta;
7267
- buildInfo?: Record<string, any>;
7275
+ buildInfo?: BuildInfo;
7268
7276
  presentationalDependencies?: Dependency[];
7269
7277
  codeGenerationDependencies?: Dependency[];
7270
7278
  id: string | number;
@@ -8683,7 +8691,7 @@ declare interface OptimizationSplitChunksCacheGroup {
8683
8691
  /**
8684
8692
  * Select chunks for determining cache group content (defaults to "initial", "initial" and "all" requires adding these chunks to the HTML).
8685
8693
  */
8686
- chunks?: "all" | "initial" | "async" | ((chunk: Chunk) => boolean);
8694
+ chunks?: RegExp | "all" | "initial" | "async" | ((chunk: Chunk) => boolean);
8687
8695
 
8688
8696
  /**
8689
8697
  * Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group.
@@ -8810,7 +8818,7 @@ declare interface OptimizationSplitChunksOptions {
8810
8818
  /**
8811
8819
  * Select chunks for determining shared modules (defaults to "async", "initial" and "all" requires adding these chunks to the HTML).
8812
8820
  */
8813
- chunks?: "all" | "initial" | "async" | ((chunk: Chunk) => boolean);
8821
+ chunks?: RegExp | "all" | "initial" | "async" | ((chunk: Chunk) => boolean);
8814
8822
 
8815
8823
  /**
8816
8824
  * Sets the size types which are used when a number is used for sizes.
@@ -8833,7 +8841,7 @@ declare interface OptimizationSplitChunksOptions {
8833
8841
  /**
8834
8842
  * Select chunks for determining shared modules (defaults to "async", "initial" and "all" requires adding these chunks to the HTML).
8835
8843
  */
8836
- chunks?: "all" | "initial" | "async" | ((chunk: Chunk) => boolean);
8844
+ chunks?: RegExp | "all" | "initial" | "async" | ((chunk: Chunk) => boolean);
8837
8845
  /**
8838
8846
  * Maximal size hint for the on-demand chunks.
8839
8847
  */
@@ -9760,7 +9768,7 @@ declare class ProgressPlugin {
9760
9768
  apply(compiler: Compiler | MultiCompiler): void;
9761
9769
  static getReporter(
9762
9770
  compiler: Compiler
9763
- ): (p: number, ...args: string[]) => void;
9771
+ ): undefined | ((p: number, ...args: string[]) => void);
9764
9772
  static defaultOptions: {
9765
9773
  profile: boolean;
9766
9774
  modulesCount: number;
@@ -9770,6 +9778,10 @@ declare class ProgressPlugin {
9770
9778
  activeModules: boolean;
9771
9779
  entries: boolean;
9772
9780
  };
9781
+ static createDefaultHandler: (
9782
+ profile: undefined | null | boolean,
9783
+ logger: WebpackLogger
9784
+ ) => (percentage: number, msg: string, ...args: string[]) => void;
9773
9785
  }
9774
9786
  type ProgressPluginArgument =
9775
9787
  | ProgressPluginOptions
@@ -11543,10 +11555,10 @@ declare class SideEffectsFlagPlugin {
11543
11555
  */
11544
11556
  apply(compiler: Compiler): void;
11545
11557
  static moduleHasSideEffects(
11546
- moduleName?: any,
11547
- flagValue?: any,
11548
- cache?: any
11549
- ): any;
11558
+ moduleName: string,
11559
+ flagValue: undefined | string | boolean | string[],
11560
+ cache: Map<string, RegExp>
11561
+ ): undefined | boolean;
11550
11562
  }
11551
11563
  declare class SizeOnlySource extends Source {
11552
11564
  constructor(size: number);
@@ -11829,7 +11841,7 @@ declare interface SourcePosition {
11829
11841
  column?: number;
11830
11842
  }
11831
11843
  declare interface SplitChunksOptions {
11832
- chunksFilter: (chunk: Chunk) => boolean;
11844
+ chunksFilter: (chunk: Chunk) => undefined | boolean;
11833
11845
  defaultSizeTypes: string[];
11834
11846
  minSize: SplitChunksSizes;
11835
11847
  minSizeReduction: SplitChunksSizes;
@@ -13465,7 +13477,7 @@ declare namespace exports {
13465
13477
  ) => void;
13466
13478
  export let setTopLevelSymbol: (
13467
13479
  state: ParserState,
13468
- symbol: TopLevelSymbol
13480
+ symbol?: TopLevelSymbol
13469
13481
  ) => void;
13470
13482
  export let getTopLevelSymbol: (
13471
13483
  state: ParserState
@@ -13473,7 +13485,7 @@ declare namespace exports {
13473
13485
  export let tagTopLevelSymbol: (
13474
13486
  parser: JavascriptParser,
13475
13487
  name: string
13476
- ) => TopLevelSymbol;
13488
+ ) => undefined | TopLevelSymbol;
13477
13489
  export let isDependencyUsedByExports: (
13478
13490
  dependency: Dependency,
13479
13491
  usedByExports: boolean | Set<string>,