webpack 5.85.1 → 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 (44) 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/JsonExportsDependency.js +1 -1
  19. package/lib/javascript/JavascriptModulesPlugin.js +1 -0
  20. package/lib/json/JsonData.js +2 -2
  21. package/lib/json/JsonParser.js +25 -12
  22. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -1
  23. package/lib/optimize/AggressiveMergingPlugin.js +8 -0
  24. package/lib/optimize/AggressiveSplittingPlugin.js +9 -2
  25. package/lib/optimize/EnsureChunkConditionsPlugin.js +3 -0
  26. package/lib/optimize/FlagIncludedChunksPlugin.js +11 -5
  27. package/lib/optimize/InnerGraph.js +4 -4
  28. package/lib/optimize/LimitChunkCountPlugin.js +29 -4
  29. package/lib/optimize/MangleExportsPlugin.js +1 -1
  30. package/lib/optimize/MinMaxSizeWarning.js +5 -0
  31. package/lib/optimize/ModuleConcatenationPlugin.js +59 -2
  32. package/lib/optimize/RealContentHashPlugin.js +80 -30
  33. package/lib/optimize/RemoveParentModulesPlugin.js +6 -0
  34. package/lib/optimize/RuntimeChunkPlugin.js +9 -1
  35. package/lib/optimize/SideEffectsFlagPlugin.js +10 -1
  36. package/lib/optimize/SplitChunksPlugin.js +71 -31
  37. package/lib/serialization/BinaryMiddleware.js +143 -1
  38. package/lib/serialization/ErrorObjectSerializer.js +3 -0
  39. package/lib/serialization/ObjectMiddleware.js +3 -0
  40. package/lib/serialization/types.js +1 -1
  41. package/package.json +1 -1
  42. package/schemas/WebpackOptions.check.js +1 -1
  43. package/schemas/WebpackOptions.json +12 -0
  44. package/types.d.ts +43 -34
@@ -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;
@@ -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
  }
@@ -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
  /**
@@ -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;
@@ -7267,7 +7272,7 @@ declare class Module extends DependenciesBlock {
7267
7272
  useSourceMap: boolean;
7268
7273
  useSimpleSourceMap: boolean;
7269
7274
  buildMeta?: BuildMeta;
7270
- buildInfo?: Record<string, any>;
7275
+ buildInfo?: BuildInfo;
7271
7276
  presentationalDependencies?: Dependency[];
7272
7277
  codeGenerationDependencies?: Dependency[];
7273
7278
  id: string | number;
@@ -8686,7 +8691,7 @@ declare interface OptimizationSplitChunksCacheGroup {
8686
8691
  /**
8687
8692
  * Select chunks for determining cache group content (defaults to "initial", "initial" and "all" requires adding these chunks to the HTML).
8688
8693
  */
8689
- chunks?: "all" | "initial" | "async" | ((chunk: Chunk) => boolean);
8694
+ chunks?: RegExp | "all" | "initial" | "async" | ((chunk: Chunk) => boolean);
8690
8695
 
8691
8696
  /**
8692
8697
  * Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group.
@@ -8813,7 +8818,7 @@ declare interface OptimizationSplitChunksOptions {
8813
8818
  /**
8814
8819
  * Select chunks for determining shared modules (defaults to "async", "initial" and "all" requires adding these chunks to the HTML).
8815
8820
  */
8816
- chunks?: "all" | "initial" | "async" | ((chunk: Chunk) => boolean);
8821
+ chunks?: RegExp | "all" | "initial" | "async" | ((chunk: Chunk) => boolean);
8817
8822
 
8818
8823
  /**
8819
8824
  * Sets the size types which are used when a number is used for sizes.
@@ -8836,7 +8841,7 @@ declare interface OptimizationSplitChunksOptions {
8836
8841
  /**
8837
8842
  * Select chunks for determining shared modules (defaults to "async", "initial" and "all" requires adding these chunks to the HTML).
8838
8843
  */
8839
- chunks?: "all" | "initial" | "async" | ((chunk: Chunk) => boolean);
8844
+ chunks?: RegExp | "all" | "initial" | "async" | ((chunk: Chunk) => boolean);
8840
8845
  /**
8841
8846
  * Maximal size hint for the on-demand chunks.
8842
8847
  */
@@ -9763,7 +9768,7 @@ declare class ProgressPlugin {
9763
9768
  apply(compiler: Compiler | MultiCompiler): void;
9764
9769
  static getReporter(
9765
9770
  compiler: Compiler
9766
- ): (p: number, ...args: string[]) => void;
9771
+ ): undefined | ((p: number, ...args: string[]) => void);
9767
9772
  static defaultOptions: {
9768
9773
  profile: boolean;
9769
9774
  modulesCount: number;
@@ -9773,6 +9778,10 @@ declare class ProgressPlugin {
9773
9778
  activeModules: boolean;
9774
9779
  entries: boolean;
9775
9780
  };
9781
+ static createDefaultHandler: (
9782
+ profile: undefined | null | boolean,
9783
+ logger: WebpackLogger
9784
+ ) => (percentage: number, msg: string, ...args: string[]) => void;
9776
9785
  }
9777
9786
  type ProgressPluginArgument =
9778
9787
  | ProgressPluginOptions
@@ -11546,10 +11555,10 @@ declare class SideEffectsFlagPlugin {
11546
11555
  */
11547
11556
  apply(compiler: Compiler): void;
11548
11557
  static moduleHasSideEffects(
11549
- moduleName?: any,
11550
- flagValue?: any,
11551
- cache?: any
11552
- ): any;
11558
+ moduleName: string,
11559
+ flagValue: undefined | string | boolean | string[],
11560
+ cache: Map<string, RegExp>
11561
+ ): undefined | boolean;
11553
11562
  }
11554
11563
  declare class SizeOnlySource extends Source {
11555
11564
  constructor(size: number);
@@ -11832,7 +11841,7 @@ declare interface SourcePosition {
11832
11841
  column?: number;
11833
11842
  }
11834
11843
  declare interface SplitChunksOptions {
11835
- chunksFilter: (chunk: Chunk) => boolean;
11844
+ chunksFilter: (chunk: Chunk) => undefined | boolean;
11836
11845
  defaultSizeTypes: string[];
11837
11846
  minSize: SplitChunksSizes;
11838
11847
  minSizeReduction: SplitChunksSizes;
@@ -13468,7 +13477,7 @@ declare namespace exports {
13468
13477
  ) => void;
13469
13478
  export let setTopLevelSymbol: (
13470
13479
  state: ParserState,
13471
- symbol: TopLevelSymbol
13480
+ symbol?: TopLevelSymbol
13472
13481
  ) => void;
13473
13482
  export let getTopLevelSymbol: (
13474
13483
  state: ParserState
@@ -13476,7 +13485,7 @@ declare namespace exports {
13476
13485
  export let tagTopLevelSymbol: (
13477
13486
  parser: JavascriptParser,
13478
13487
  name: string
13479
- ) => TopLevelSymbol;
13488
+ ) => undefined | TopLevelSymbol;
13480
13489
  export let isDependencyUsedByExports: (
13481
13490
  dependency: Dependency,
13482
13491
  usedByExports: boolean | Set<string>,