webpack 5.105.2 → 5.105.3

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 (36) hide show
  1. package/lib/CleanPlugin.js +1 -0
  2. package/lib/Compilation.js +8 -6
  3. package/lib/ContextModule.js +14 -8
  4. package/lib/Dependency.js +1 -1
  5. package/lib/EnvironmentNotSupportAsyncWarning.js +1 -0
  6. package/lib/EvalDevToolModulePlugin.js +3 -0
  7. package/lib/EvalSourceMapDevToolPlugin.js +8 -1
  8. package/lib/ExportsInfo.js +0 -30
  9. package/lib/ExternalModule.js +2 -2
  10. package/lib/Module.js +30 -5
  11. package/lib/ModuleGraphConnection.js +0 -9
  12. package/lib/SourceMapDevToolModuleOptionsPlugin.js +1 -0
  13. package/lib/SourceMapDevToolPlugin.js +10 -2
  14. package/lib/WebpackOptionsApply.js +13 -3
  15. package/lib/asset/AssetModulesPlugin.js +16 -1
  16. package/lib/asset/RawDataUrlModule.js +5 -1
  17. package/lib/css/CssGenerator.js +3 -6
  18. package/lib/css/CssModulesPlugin.js +7 -0
  19. package/lib/dependencies/CommonJsExportRequireDependency.js +4 -0
  20. package/lib/dependencies/CommonJsImportsParserPlugin.js +314 -508
  21. package/lib/dependencies/CreateRequireParserPlugin.js +345 -0
  22. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -8
  23. package/lib/dependencies/HarmonyImportDependency.js +30 -0
  24. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +8 -20
  25. package/lib/dependencies/HarmonyModulesPlugin.js +4 -0
  26. package/lib/dependencies/ImportParserPlugin.js +1 -11
  27. package/lib/dependencies/ImportPhase.js +4 -0
  28. package/lib/javascript/JavascriptModulesPlugin.js +75 -22
  29. package/lib/javascript/JavascriptParser.js +2 -2
  30. package/lib/performance/AssetsOverSizeLimitWarning.js +1 -0
  31. package/lib/performance/EntrypointsOverSizeLimitWarning.js +1 -0
  32. package/lib/performance/SizeLimitsPlugin.js +1 -0
  33. package/lib/runtime/ToBinaryRuntimeModule.js +14 -6
  34. package/lib/util/findGraphRoots.js +79 -109
  35. package/package.json +12 -9
  36. package/types.d.ts +147 -62
package/types.d.ts CHANGED
@@ -266,6 +266,42 @@ type AliasOptionNewRequest = string | false | string[];
266
266
  declare interface AliasOptions {
267
267
  [index: string]: AliasOptionNewRequest;
268
268
  }
269
+ declare interface AllCodeGenerationSchemas {
270
+ /**
271
+ * top level declarations for javascript modules
272
+ */
273
+ topLevelDeclarations: Set<string>;
274
+
275
+ /**
276
+ * chunk init fragments for javascript modules
277
+ */
278
+ chunkInitFragments: InitFragment<any>[];
279
+
280
+ /**
281
+ * url for css and javascript modules
282
+ */
283
+ url: { javascript?: string; "css-url"?: string };
284
+
285
+ /**
286
+ * a filename for asset modules
287
+ */
288
+ filename: string;
289
+
290
+ /**
291
+ * an asset info for asset modules
292
+ */
293
+ assetInfo: AssetInfo;
294
+
295
+ /**
296
+ * a full content hash for asset modules
297
+ */
298
+ fullContentHash: string;
299
+
300
+ /**
301
+ * share-init for modules federation
302
+ */
303
+ "share-init": [{ shareScope: string; initStage: number; init: string }];
304
+ }
269
305
  type AnyLoaderContext = NormalModuleLoaderContext<any> &
270
306
  LoaderRunnerLoaderContext<any> &
271
307
  LoaderPluginLoaderContext &
@@ -1629,6 +1665,10 @@ declare abstract class ChunkGroup {
1629
1665
  getModuleIndex: (module: Module) => undefined | number;
1630
1666
  getModuleIndex2: (module: Module) => undefined | number;
1631
1667
  }
1668
+ declare interface ChunkGroupInfoWithName {
1669
+ name: string;
1670
+ chunkGroup: ChunkGroup;
1671
+ }
1632
1672
  type ChunkGroupOptions = RawChunkGroupOptions & { name?: null | string };
1633
1673
  declare interface ChunkHashContext {
1634
1674
  /**
@@ -1904,16 +1944,7 @@ declare interface CleanOptions {
1904
1944
  }
1905
1945
  declare class CleanPlugin {
1906
1946
  constructor(options?: CleanOptions);
1907
- options: {
1908
- /**
1909
- * Log the assets that should be removed instead of deleting them.
1910
- */
1911
- dry: boolean;
1912
- /**
1913
- * Keep these assets.
1914
- */
1915
- keep?: string | RegExp | ((path: string) => undefined | boolean);
1916
- };
1947
+ options: CleanOptions & { dry: boolean };
1917
1948
 
1918
1949
  /**
1919
1950
  * Apply the plugin
@@ -1929,6 +1960,25 @@ declare interface CleanPluginCompilationHooks {
1929
1960
  */
1930
1961
  keep: SyncBailHook<[string], boolean | void>;
1931
1962
  }
1963
+ declare interface CodeGenMapOverloads {
1964
+ get: <K extends string>(key: K) => undefined | CodeGenValue<K>;
1965
+ set: <K extends string>(
1966
+ key: K,
1967
+ value: CodeGenValue<K>
1968
+ ) => CodeGenerationResultData;
1969
+ has: <K extends string>(key: K) => boolean;
1970
+ delete: <K extends string>(key: K) => boolean;
1971
+ }
1972
+ type CodeGenValue<K extends string> = K extends
1973
+ | "filename"
1974
+ | "assetInfo"
1975
+ | "share-init"
1976
+ | "topLevelDeclarations"
1977
+ | "chunkInitFragments"
1978
+ | "url"
1979
+ | "fullContentHash"
1980
+ ? AllCodeGenerationSchemas[K]
1981
+ : any;
1932
1982
  declare interface CodeGenerationContext {
1933
1983
  /**
1934
1984
  * the dependency templates
@@ -2007,15 +2057,11 @@ declare interface CodeGenerationResult {
2007
2057
  */
2008
2058
  hash?: string;
2009
2059
  }
2010
- type CodeGenerationResultData = Map<"topLevelDeclarations", Set<string>> &
2011
- Map<"chunkInitFragments", InitFragment<any>[]> &
2012
- Map<"url", { "css-url": string }> &
2013
- Map<"filename", string> &
2014
- Map<"assetInfo", AssetInfo> &
2015
- Map<"fullContentHash", string> &
2016
- Map<"url", { javascript: string }> &
2017
- Map<"share-init", [{ shareScope: string; initStage: number; init: string }]> &
2018
- Map<string, any>;
2060
+ type CodeGenerationResultData = Omit<
2061
+ Map<string, any>,
2062
+ "get" | "set" | "has" | "delete"
2063
+ > &
2064
+ CodeGenMapOverloads;
2019
2065
  declare abstract class CodeGenerationResults {
2020
2066
  map: Map<Module, RuntimeSpecMap<CodeGenerationResult, CodeGenerationResult>>;
2021
2067
  get(module: Module, runtime: RuntimeSpec): CodeGenerationResult;
@@ -3616,7 +3662,11 @@ type CreateWriteStreamFSImplementation = FSImplementation & {
3616
3662
  write: (...args: any[]) => any;
3617
3663
  close?: (...args: any[]) => any;
3618
3664
  };
3619
- declare interface CreatedObject<T, F> {}
3665
+ type CreatedObject<T, F> = T extends ChunkGroupInfoWithName[]
3666
+ ? Record<string, StatsChunkGroup>
3667
+ : T extends (infer V)[]
3668
+ ? StatsObject<V, F>[]
3669
+ : StatsObject<T, F>;
3620
3670
  declare interface CssData {
3621
3671
  /**
3622
3672
  * whether export __esModule
@@ -4233,6 +4283,9 @@ declare interface DeterministicModuleIdsPluginOptions {
4233
4283
  */
4234
4284
  failOnConflict?: boolean;
4235
4285
  }
4286
+ type DevtoolFallbackModuleFilenameTemplate =
4287
+ | string
4288
+ | ((context: ModuleFilenameTemplateContext) => string);
4236
4289
  type DevtoolModuleFilenameTemplate =
4237
4290
  | string
4238
4291
  | ((context: ModuleFilenameTemplateContext) => string);
@@ -5021,9 +5074,7 @@ declare interface EvalDevToolModulePluginOptions {
5021
5074
  declare class EvalSourceMapDevToolPlugin {
5022
5075
  constructor(inputOptions?: string | SourceMapDevToolPluginOptions);
5023
5076
  sourceMapComment: string;
5024
- moduleFilenameTemplate:
5025
- | string
5026
- | ((context: ModuleFilenameTemplateContext) => string);
5077
+ moduleFilenameTemplate: DevtoolModuleFilenameTemplate;
5027
5078
  namespace: string;
5028
5079
  options: SourceMapDevToolPluginOptions;
5029
5080
 
@@ -6475,7 +6526,18 @@ declare class HarmonyImportDependency extends ModuleDependency {
6475
6526
  AUTO: ExportPresenceMode;
6476
6527
  ERROR: ExportPresenceMode;
6477
6528
  fromUserOption(str: string | false): ExportPresenceMode;
6529
+ /**
6530
+ * Resolve export presence mode from parser options with a specific key and shared fallbacks.
6531
+ */
6532
+ resolveFromOptions(
6533
+ specificValue: undefined | string | false,
6534
+ options: JavascriptParserOptions
6535
+ ): ExportPresenceMode;
6478
6536
  };
6537
+ static getNonOptionalPart: (
6538
+ members: string[],
6539
+ membersOptionals: boolean[]
6540
+ ) => string[];
6479
6541
  static NO_EXPORTS_REFERENCED: string[][];
6480
6542
  static EXPORTS_OBJECT_REFERENCED: string[][];
6481
6543
  static isLowPriorityDependency(dependency: Dependency): boolean;
@@ -10069,6 +10131,7 @@ declare interface LogEntry {
10069
10131
  | "info"
10070
10132
  | "log"
10071
10133
  | "debug"
10134
+ | "clear"
10072
10135
  | "profile"
10073
10136
  | "trace"
10074
10137
  | "group"
@@ -10076,7 +10139,6 @@ declare interface LogEntry {
10076
10139
  | "groupEnd"
10077
10140
  | "profileEnd"
10078
10141
  | "time"
10079
- | "clear"
10080
10142
  | "status";
10081
10143
  args?: any[];
10082
10144
  time: number;
@@ -10088,6 +10150,7 @@ type LogTypeEnum =
10088
10150
  | "info"
10089
10151
  | "log"
10090
10152
  | "debug"
10153
+ | "clear"
10091
10154
  | "profile"
10092
10155
  | "trace"
10093
10156
  | "group"
@@ -10095,7 +10158,6 @@ type LogTypeEnum =
10095
10158
  | "groupEnd"
10096
10159
  | "profileEnd"
10097
10160
  | "time"
10098
- | "clear"
10099
10161
  | "status";
10100
10162
  declare const MEASURE_END_OPERATION: unique symbol;
10101
10163
  declare const MEASURE_START_OPERATION: unique symbol;
@@ -11064,7 +11126,6 @@ declare class ModuleGraphConnection {
11064
11126
  isTargetActive(runtime: RuntimeSpec): boolean;
11065
11127
  getActiveState(runtime: RuntimeSpec): ConnectionState;
11066
11128
  setActive(value: boolean): void;
11067
- active: void;
11068
11129
  static CIRCULAR_CONNECTION: typeof CIRCULAR_CONNECTION;
11069
11130
  static TRANSITIVE_ONLY: typeof TRANSITIVE_ONLY;
11070
11131
  static addConnectionStates: (
@@ -11461,6 +11522,10 @@ declare abstract class ModuleTemplate {
11461
11522
  declare interface ModuleTemplates {
11462
11523
  javascript: ModuleTemplate;
11463
11524
  }
11525
+ declare interface ModuleTrace {
11526
+ origin: Module;
11527
+ module: Module;
11528
+ }
11464
11529
  declare class MultiCompiler {
11465
11530
  constructor(
11466
11531
  compilers: Compiler[] | Record<string, Compiler>,
@@ -13706,34 +13771,7 @@ declare interface ParameterizedComparator<TArg extends object, T> {
13706
13771
  }
13707
13772
  declare interface ParseOptions {
13708
13773
  sourceType: "module" | "script";
13709
- ecmaVersion?:
13710
- | 3
13711
- | 5
13712
- | 6
13713
- | 7
13714
- | 8
13715
- | 9
13716
- | 10
13717
- | 11
13718
- | 12
13719
- | 13
13720
- | 14
13721
- | 15
13722
- | 16
13723
- | 17
13724
- | 2015
13725
- | 2016
13726
- | 2017
13727
- | 2018
13728
- | 2019
13729
- | 2020
13730
- | 2021
13731
- | 2022
13732
- | 2023
13733
- | 2024
13734
- | 2025
13735
- | 2026
13736
- | "latest";
13774
+ ecmaVersion: ecmaVersion;
13737
13775
  locations?: boolean;
13738
13776
  comments?: boolean;
13739
13777
  ranges?: boolean;
@@ -17321,17 +17359,13 @@ declare interface SourceLike {
17321
17359
  }
17322
17360
  declare class SourceMapDevToolPlugin {
17323
17361
  constructor(options?: SourceMapDevToolPluginOptions);
17324
- sourceMapFilename: string | false;
17362
+ sourceMapFilename?: null | string | false;
17325
17363
  sourceMappingURLComment:
17326
17364
  | string
17327
17365
  | false
17328
17366
  | ((pathData: PathData, assetInfo?: AssetInfo) => string);
17329
- moduleFilenameTemplate:
17330
- | string
17331
- | ((context: ModuleFilenameTemplateContext) => string);
17332
- fallbackModuleFilenameTemplate:
17333
- | string
17334
- | ((context: ModuleFilenameTemplateContext) => string);
17367
+ moduleFilenameTemplate: DevtoolModuleFilenameTemplate;
17368
+ fallbackModuleFilenameTemplate: DevtoolFallbackModuleFilenameTemplate;
17335
17369
  namespace: string;
17336
17370
  options: SourceMapDevToolPluginOptions;
17337
17371
 
@@ -17435,7 +17469,7 @@ declare class SourceMapSource extends Source {
17435
17469
  name: string,
17436
17470
  sourceMap?: string | Buffer | RawSourceMap,
17437
17471
  originalSource?: string | Buffer,
17438
- innerSourceMap?: string | Buffer | RawSourceMap,
17472
+ innerSourceMap?: null | string | Buffer | RawSourceMap,
17439
17473
  removeOriginalSource?: boolean
17440
17474
  );
17441
17475
  getArgsAsBuffers(): [
@@ -17793,6 +17827,29 @@ type StatsModuleReason = KnownStatsModuleReason & Record<string, any>;
17793
17827
  type StatsModuleTraceDependency = KnownStatsModuleTraceDependency &
17794
17828
  Record<string, any>;
17795
17829
  type StatsModuleTraceItem = KnownStatsModuleTraceItem & Record<string, any>;
17830
+ type StatsObject<T, F> = T extends Compilation
17831
+ ? StatsCompilation
17832
+ : T extends ChunkGroupInfoWithName
17833
+ ? StatsChunkGroup
17834
+ : T extends Chunk
17835
+ ? StatsChunk
17836
+ : T extends OriginRecord
17837
+ ? StatsChunkOrigin
17838
+ : T extends Module
17839
+ ? StatsModule
17840
+ : T extends ModuleGraphConnection
17841
+ ? StatsModuleReason
17842
+ : T extends Asset
17843
+ ? StatsAsset
17844
+ : T extends ModuleTrace
17845
+ ? StatsModuleTraceItem
17846
+ : T extends Dependency
17847
+ ? StatsModuleTraceDependency
17848
+ : T extends Error
17849
+ ? StatsError
17850
+ : T extends ModuleProfile
17851
+ ? StatsProfile
17852
+ : F;
17796
17853
 
17797
17854
  /**
17798
17855
  * Stats options object.
@@ -19292,6 +19349,34 @@ declare interface chunkModuleHashMap {
19292
19349
  [index: number]: string;
19293
19350
  [index: string]: string;
19294
19351
  }
19352
+ type ecmaVersion =
19353
+ | 3
19354
+ | 5
19355
+ | 6
19356
+ | 7
19357
+ | 8
19358
+ | 9
19359
+ | 10
19360
+ | 11
19361
+ | 12
19362
+ | 13
19363
+ | 14
19364
+ | 15
19365
+ | 16
19366
+ | 17
19367
+ | 2015
19368
+ | 2016
19369
+ | 2017
19370
+ | 2018
19371
+ | 2019
19372
+ | 2020
19373
+ | 2021
19374
+ | 2022
19375
+ | 2023
19376
+ | 2024
19377
+ | 2025
19378
+ | 2026
19379
+ | "latest";
19295
19380
  declare function exports(
19296
19381
  options: Configuration,
19297
19382
  callback: CallbackWebpackFunction_2<Stats, void>