webpack 5.18.0 → 5.20.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.

Files changed (51) hide show
  1. package/README.md +10 -47
  2. package/bin/webpack.js +0 -0
  3. package/lib/CleanPlugin.js +357 -0
  4. package/lib/CodeGenerationResults.js +28 -26
  5. package/lib/Compilation.js +192 -12
  6. package/lib/Dependency.js +1 -1
  7. package/lib/FlagDependencyUsagePlugin.js +8 -4
  8. package/lib/Generator.js +1 -0
  9. package/lib/ModuleGraph.js +8 -0
  10. package/lib/ModuleGraphConnection.js +3 -3
  11. package/lib/ModuleProfile.js +31 -4
  12. package/lib/NormalModule.js +17 -3
  13. package/lib/ProgressPlugin.js +12 -10
  14. package/lib/RuntimeGlobals.js +14 -0
  15. package/lib/RuntimePlugin.js +8 -0
  16. package/lib/RuntimeTemplate.js +1 -1
  17. package/lib/WebpackOptionsApply.js +16 -7
  18. package/lib/asset/AssetGenerator.js +10 -1
  19. package/lib/asset/AssetModulesPlugin.js +14 -5
  20. package/lib/async-modules/AwaitDependenciesInitFragment.js +12 -2
  21. package/lib/cache/IdleFileCachePlugin.js +9 -3
  22. package/lib/config/defaults.js +13 -2
  23. package/lib/config/normalization.js +1 -0
  24. package/lib/container/ContainerEntryModule.js +4 -1
  25. package/lib/container/ContainerPlugin.js +4 -2
  26. package/lib/dependencies/HarmonyCompatibilityDependency.js +5 -4
  27. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +1 -1
  28. package/lib/dependencies/HarmonyImportSideEffectDependency.js +1 -1
  29. package/lib/dependencies/HarmonyImportSpecifierDependency.js +13 -5
  30. package/lib/dependencies/URLDependency.js +9 -4
  31. package/lib/hmr/LazyCompilationPlugin.js +29 -3
  32. package/lib/hmr/lazyCompilationBackend.js +2 -3
  33. package/lib/index.js +4 -0
  34. package/lib/javascript/JavascriptModulesPlugin.js +2 -2
  35. package/lib/optimize/InnerGraph.js +28 -0
  36. package/lib/runtime/AsyncModuleRuntimeModule.js +137 -0
  37. package/lib/serialization/BinaryMiddleware.js +10 -2
  38. package/lib/sharing/ShareRuntimeModule.js +1 -1
  39. package/lib/util/ArrayQueue.js +103 -0
  40. package/lib/util/AsyncQueue.js +58 -27
  41. package/lib/util/ParallelismFactorCalculator.js +59 -0
  42. package/lib/util/fs.js +3 -0
  43. package/lib/util/runtime.js +135 -24
  44. package/lib/validateSchema.js +2 -2
  45. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +24 -22
  46. package/package.json +2 -3
  47. package/schemas/WebpackOptions.json +65 -0
  48. package/schemas/_container.json +4 -0
  49. package/schemas/plugins/container/ContainerPlugin.json +4 -0
  50. package/schemas/plugins/container/ModuleFederationPlugin.json +4 -0
  51. package/types.d.ts +111 -19
package/types.d.ts CHANGED
@@ -1025,6 +1025,48 @@ declare abstract class ChunkTemplate {
1025
1025
  }>;
1026
1026
  readonly outputOptions: Output;
1027
1027
  }
1028
+
1029
+ /**
1030
+ * Advanced options for cleaning assets.
1031
+ */
1032
+ declare interface CleanOptions {
1033
+ /**
1034
+ * Log the assets that should be removed instead of deleting them.
1035
+ */
1036
+ dry?: boolean;
1037
+
1038
+ /**
1039
+ * Keep these assets.
1040
+ */
1041
+ keep?: string | RegExp | ((filename: string) => boolean);
1042
+ }
1043
+ declare class CleanPlugin {
1044
+ constructor(options?: CleanOptions);
1045
+ options: {
1046
+ /**
1047
+ * Log the assets that should be removed instead of deleting them.
1048
+ */
1049
+ dry: boolean;
1050
+ /**
1051
+ * Keep these assets.
1052
+ */
1053
+ keep?: string | RegExp | ((filename: string) => boolean);
1054
+ };
1055
+
1056
+ /**
1057
+ * Apply the plugin
1058
+ */
1059
+ apply(compiler: Compiler): void;
1060
+ static getCompilationHooks(
1061
+ compilation: Compilation
1062
+ ): CleanPluginCompilationHooks;
1063
+ }
1064
+ declare interface CleanPluginCompilationHooks {
1065
+ /**
1066
+ * when returning true the file/directory will be kept during cleaning, returning false will clean it and ignore the following plugins and config
1067
+ */
1068
+ keep: SyncBailHook<[string], boolean>;
1069
+ }
1028
1070
  declare interface CodeGenerationContext {
1029
1071
  /**
1030
1072
  * the dependency templates
@@ -1079,7 +1121,6 @@ declare interface CodeGenerationResult {
1079
1121
  }
1080
1122
  declare abstract class CodeGenerationResults {
1081
1123
  map: Map<Module, RuntimeSpecMap<CodeGenerationResult>>;
1082
- hashes: Map<Module, RuntimeSpecMap<string>>;
1083
1124
  get(module: Module, runtime: RuntimeSpec): CodeGenerationResult;
1084
1125
  has(module: Module, runtime: RuntimeSpec): boolean;
1085
1126
  getSource(module: Module, runtime: RuntimeSpec, sourceType: string): Source;
@@ -1284,11 +1325,11 @@ declare class Compilation {
1284
1325
  moduleGraph: ModuleGraph;
1285
1326
  chunkGraph?: ChunkGraph;
1286
1327
  codeGenerationResults: CodeGenerationResults;
1287
- factorizeQueue: AsyncQueue<FactorizeModuleOptions, string, Module>;
1328
+ processDependenciesQueue: AsyncQueue<Module, Module, Module>;
1288
1329
  addModuleQueue: AsyncQueue<Module, string, Module>;
1330
+ factorizeQueue: AsyncQueue<FactorizeModuleOptions, string, Module>;
1289
1331
  buildQueue: AsyncQueue<Module, Module, Module>;
1290
1332
  rebuildQueue: AsyncQueue<Module, Module, Module>;
1291
- processDependenciesQueue: AsyncQueue<Module, Module, Module>;
1292
1333
 
1293
1334
  /**
1294
1335
  * Modules in value are building during the build of Module in key.
@@ -2298,7 +2339,10 @@ declare class Dependency {
2298
2339
  ): (string[] | ReferencedExport)[];
2299
2340
  getCondition(
2300
2341
  moduleGraph: ModuleGraph
2301
- ): (arg0: ModuleGraphConnection, arg1: RuntimeSpec) => ConnectionState;
2342
+ ):
2343
+ | null
2344
+ | false
2345
+ | ((arg0: ModuleGraphConnection, arg1: RuntimeSpec) => ConnectionState);
2302
2346
 
2303
2347
  /**
2304
2348
  * Returns the exported names
@@ -3000,6 +3044,14 @@ declare interface Experiments {
3000
3044
  * Enable/disable lazy compilation for entries.
3001
3045
  */
3002
3046
  entries?: boolean;
3047
+ /**
3048
+ * Enable/disable lazy compilation for import() modules.
3049
+ */
3050
+ imports?: boolean;
3051
+ /**
3052
+ * Specify which entrypoints or import()ed modules should be lazily compiled. This is matched with the imported module and not the entrypoint name.
3053
+ */
3054
+ test?: string | RegExp | ((module: Module) => boolean);
3003
3055
  };
3004
3056
 
3005
3057
  /**
@@ -3249,6 +3301,11 @@ declare interface ExposesConfig {
3249
3301
  * Request to a module that should be exposed by this container.
3250
3302
  */
3251
3303
  import: string | string[];
3304
+
3305
+ /**
3306
+ * Custom chunk name for the exposed module.
3307
+ */
3308
+ name?: string;
3252
3309
  }
3253
3310
 
3254
3311
  /**
@@ -3739,6 +3796,11 @@ declare interface GenerateContext {
3739
3796
  * which kind of code should be generated
3740
3797
  */
3741
3798
  type: string;
3799
+
3800
+ /**
3801
+ * get access to the code generation data
3802
+ */
3803
+ getData?: () => Map<string, any>;
3742
3804
  }
3743
3805
  declare class Generator {
3744
3806
  constructor();
@@ -5713,6 +5775,7 @@ declare class ModuleGraph {
5713
5775
  isAsync(module: Module): boolean;
5714
5776
  setAsync(module: Module): void;
5715
5777
  getMeta(thing?: any): Object;
5778
+ getMetaIfExisting(thing?: any): Object;
5716
5779
  static getModuleGraphForModule(
5717
5780
  module: Module,
5718
5781
  deprecateMessage: string,
@@ -5731,10 +5794,9 @@ declare class ModuleGraphConnection {
5731
5794
  module: Module,
5732
5795
  explanation?: string,
5733
5796
  weak?: boolean,
5734
- condition?: (
5735
- arg0: ModuleGraphConnection,
5736
- arg1: RuntimeSpec
5737
- ) => ConnectionState
5797
+ condition?:
5798
+ | false
5799
+ | ((arg0: ModuleGraphConnection, arg1: RuntimeSpec) => ConnectionState)
5738
5800
  );
5739
5801
  originModule?: Module;
5740
5802
  resolvedOriginModule?: Module;
@@ -5912,33 +5974,40 @@ declare interface ModulePathData {
5912
5974
  }
5913
5975
  declare abstract class ModuleProfile {
5914
5976
  startTime: number;
5977
+ factoryStartTime: number;
5978
+ factoryEndTime: number;
5915
5979
  factory: number;
5980
+ factoryParallelismFactor: number;
5981
+ restoringStartTime: number;
5982
+ restoringEndTime: number;
5916
5983
  restoring: number;
5984
+ restoringParallelismFactor: number;
5985
+ integrationStartTime: number;
5986
+ integrationEndTime: number;
5917
5987
  integration: number;
5988
+ integrationParallelismFactor: number;
5989
+ buildingStartTime: number;
5990
+ buildingEndTime: number;
5918
5991
  building: number;
5992
+ buildingParallelismFactor: number;
5993
+ storingStartTime: number;
5994
+ storingEndTime: number;
5919
5995
  storing: number;
5996
+ storingParallelismFactor: number;
5997
+ additionalFactoryTimes: any;
5920
5998
  additionalFactories: number;
5999
+ additionalFactoriesParallelismFactor: number;
5921
6000
  additionalIntegration: number;
5922
6001
  markFactoryStart(): void;
5923
- factoryStartTime?: number;
5924
6002
  markFactoryEnd(): void;
5925
- factoryEndTime?: number;
5926
6003
  markRestoringStart(): void;
5927
- restoringStartTime?: number;
5928
6004
  markRestoringEnd(): void;
5929
- restoringEndTime?: number;
5930
6005
  markIntegrationStart(): void;
5931
- integrationStartTime?: number;
5932
6006
  markIntegrationEnd(): void;
5933
- integrationEndTime?: number;
5934
6007
  markBuildingStart(): void;
5935
- buildingStartTime?: number;
5936
6008
  markBuildingEnd(): void;
5937
- buildingEndTime?: number;
5938
6009
  markStoringStart(): void;
5939
- storingStartTime?: number;
5940
6010
  markStoringEnd(): void;
5941
- storingEndTime?: number;
5942
6011
 
5943
6012
  /**
5944
6013
  * Merge this profile into another one
@@ -6838,6 +6907,11 @@ declare interface Output {
6838
6907
  */
6839
6908
  chunkLoadingGlobal?: string;
6840
6909
 
6910
+ /**
6911
+ * Clean the output directory before emit.
6912
+ */
6913
+ clean?: boolean | CleanOptions;
6914
+
6841
6915
  /**
6842
6916
  * Check if to be emitted file already exists and have the same content before writing to output filesystem.
6843
6917
  */
@@ -7035,6 +7109,15 @@ declare interface OutputFileSystem {
7035
7109
  arg2: (arg0?: NodeJS.ErrnoException) => void
7036
7110
  ) => void;
7037
7111
  mkdir: (arg0: string, arg1: (arg0?: NodeJS.ErrnoException) => void) => void;
7112
+ readdir?: (
7113
+ arg0: string,
7114
+ arg1: (
7115
+ arg0?: NodeJS.ErrnoException,
7116
+ arg1?: (string | Buffer)[] | IDirent[]
7117
+ ) => void
7118
+ ) => void;
7119
+ rmdir?: (arg0: string, arg1: (arg0?: NodeJS.ErrnoException) => void) => void;
7120
+ unlink?: (arg0: string, arg1: (arg0?: NodeJS.ErrnoException) => void) => void;
7038
7121
  stat: (
7039
7122
  arg0: string,
7040
7123
  arg1: (arg0?: NodeJS.ErrnoException, arg1?: IStats) => void
@@ -7091,6 +7174,11 @@ declare interface OutputNormalized {
7091
7174
  */
7092
7175
  chunkLoadingGlobal?: string;
7093
7176
 
7177
+ /**
7178
+ * Clean the output directory before emit.
7179
+ */
7180
+ clean?: boolean | CleanOptions;
7181
+
7094
7182
  /**
7095
7183
  * Check if to be emitted file already exists and have the same content before writing to output filesystem.
7096
7184
  */
@@ -7461,7 +7549,7 @@ declare interface ProfilingPluginOptions {
7461
7549
  outputPath?: string;
7462
7550
  }
7463
7551
  declare class ProgressPlugin {
7464
- constructor(options: ProgressPluginArgument);
7552
+ constructor(options?: ProgressPluginArgument);
7465
7553
  profile?: null | boolean;
7466
7554
  handler?: (percentage: number, msg: string, ...args: string[]) => void;
7467
7555
  modulesCount?: number;
@@ -8754,6 +8842,7 @@ declare abstract class RuntimeSpecMap<T> {
8754
8842
  update(runtime?: any, fn?: any): void;
8755
8843
  keys(): RuntimeSpec[];
8756
8844
  values(): IterableIterator<T>;
8845
+ readonly size?: number;
8757
8846
  }
8758
8847
  declare abstract class RuntimeSpecSet {
8759
8848
  add(runtime?: any): void;
@@ -10894,6 +10983,7 @@ declare namespace exports {
10894
10983
  export let hasOwnProperty: string;
10895
10984
  export let systemContext: string;
10896
10985
  export let baseURI: string;
10986
+ export let asyncModule: string;
10897
10987
  }
10898
10988
  export const UsageState: Readonly<{
10899
10989
  Unused: 0;
@@ -11110,6 +11200,7 @@ declare namespace exports {
11110
11200
  Cache,
11111
11201
  Chunk,
11112
11202
  ChunkGraph,
11203
+ CleanPlugin,
11113
11204
  Compilation,
11114
11205
  Compiler,
11115
11206
  ConcatenationScope,
@@ -11159,6 +11250,7 @@ declare namespace exports {
11159
11250
  WebpackOptionsDefaulter,
11160
11251
  Entry,
11161
11252
  EntryNormalized,
11253
+ EntryObject,
11162
11254
  LibraryOptions,
11163
11255
  ModuleOptions,
11164
11256
  ResolveOptionsWebpackOptions as ResolveOptions,