webpack 5.58.1 → 5.60.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.

package/types.d.ts CHANGED
@@ -80,6 +80,8 @@ import {
80
80
  WithStatement,
81
81
  YieldExpression
82
82
  } from "estree";
83
+ import { ServerOptions as ServerOptionsImport } from "http";
84
+ import { ListenOptions, Server } from "net";
83
85
  import { validate as validateFunction } from "schema-utils";
84
86
  import { default as ValidationError } from "schema-utils/declarations/ValidationError";
85
87
  import { ValidationErrorConfiguration } from "schema-utils/declarations/validate";
@@ -95,6 +97,7 @@ import {
95
97
  SyncHook,
96
98
  SyncWaterfallHook
97
99
  } from "tapable";
100
+ import { SecureContextOptions, TlsOptions } from "tls";
98
101
 
99
102
  declare class AbstractLibraryPlugin<T> {
100
103
  constructor(__0: {
@@ -383,6 +386,10 @@ declare class AutomaticPrefetchPlugin {
383
386
  apply(compiler: Compiler): void;
384
387
  }
385
388
  type AuxiliaryComment = string | LibraryCustomUmdCommentObject;
389
+ declare interface BackendApi {
390
+ dispose: (arg0?: Error) => void;
391
+ module: (arg0: Module) => { client: string; data: string; active: boolean };
392
+ }
386
393
  declare class BannerPlugin {
387
394
  constructor(options: BannerPluginArgument);
388
395
  options: BannerPluginOptions;
@@ -631,6 +638,7 @@ declare interface CacheGroupSource {
631
638
  chunksFilter?: (chunk: Chunk) => boolean;
632
639
  enforce?: boolean;
633
640
  minSize: SplitChunksSizes;
641
+ minSizeReduction: SplitChunksSizes;
634
642
  minRemainingSize: SplitChunksSizes;
635
643
  enforceSizeThreshold: SplitChunksSizes;
636
644
  maxAsyncSize: SplitChunksSizes;
@@ -1895,8 +1903,8 @@ declare class Compiler {
1895
1903
  recordsInputPath: null | string;
1896
1904
  recordsOutputPath: null | string;
1897
1905
  records: object;
1898
- managedPaths: Set<string>;
1899
- immutablePaths: Set<string>;
1906
+ managedPaths: Set<string | RegExp>;
1907
+ immutablePaths: Set<string | RegExp>;
1900
1908
  modifiedFiles: ReadonlySet<string>;
1901
1909
  removedFiles: ReadonlySet<string>;
1902
1910
  fileTimestamps: ReadonlyMap<string, null | FileSystemInfoEntry | "ignore">;
@@ -3289,11 +3297,12 @@ declare interface ExecuteModuleResult {
3289
3297
  missingDependencies: LazySet<string>;
3290
3298
  buildDependencies: LazySet<string>;
3291
3299
  }
3300
+ type Experiments = ExperimentsCommon & ExperimentsExtra;
3292
3301
 
3293
3302
  /**
3294
3303
  * Enables/Disables experiments (experimental features with relax SemVer compatibility).
3295
3304
  */
3296
- declare interface Experiments {
3305
+ declare interface ExperimentsCommon {
3297
3306
  /**
3298
3307
  * Allow module type 'asset' to generate assets.
3299
3308
  */
@@ -3304,11 +3313,6 @@ declare interface Experiments {
3304
3313
  */
3305
3314
  asyncWebAssembly?: boolean;
3306
3315
 
3307
- /**
3308
- * Build http(s): urls using a lockfile and resource content cache.
3309
- */
3310
- buildHttp?: boolean | HttpUriOptions;
3311
-
3312
3316
  /**
3313
3317
  * Enable additional in memory caching of modules that are unchanged and reference only unchanged modules.
3314
3318
  */
@@ -3324,40 +3328,6 @@ declare interface Experiments {
3324
3328
  */
3325
3329
  layers?: boolean;
3326
3330
 
3327
- /**
3328
- * Compile entrypoints and import()s only when they are accessed.
3329
- */
3330
- lazyCompilation?:
3331
- | boolean
3332
- | {
3333
- /**
3334
- * A custom backend.
3335
- */
3336
- backend?:
3337
- | ((
3338
- compiler: Compiler,
3339
- client: string,
3340
- callback: (err?: Error, api?: any) => void
3341
- ) => void)
3342
- | ((compiler: Compiler, client: string) => Promise<any>);
3343
- /**
3344
- * A custom client.
3345
- */
3346
- client?: string;
3347
- /**
3348
- * Enable/disable lazy compilation for entries.
3349
- */
3350
- entries?: boolean;
3351
- /**
3352
- * Enable/disable lazy compilation for import() modules.
3353
- */
3354
- imports?: boolean;
3355
- /**
3356
- * Specify which entrypoints or import()ed modules should be lazily compiled. This is matched with the imported module and not the entrypoint name.
3357
- */
3358
- test?: string | RegExp | ((module: Module) => boolean);
3359
- };
3360
-
3361
3331
  /**
3362
3332
  * Allow output javascript files as module source type.
3363
3333
  */
@@ -3373,6 +3343,37 @@ declare interface Experiments {
3373
3343
  */
3374
3344
  topLevelAwait?: boolean;
3375
3345
  }
3346
+
3347
+ /**
3348
+ * Enables/Disables experiments (experimental features with relax SemVer compatibility).
3349
+ */
3350
+ declare interface ExperimentsExtra {
3351
+ /**
3352
+ * Build http(s): urls using a lockfile and resource content cache.
3353
+ */
3354
+ buildHttp?: HttpUriOptions | (string | RegExp | ((uri: string) => boolean))[];
3355
+
3356
+ /**
3357
+ * Compile entrypoints and import()s only when they are accessed.
3358
+ */
3359
+ lazyCompilation?: boolean | LazyCompilationOptions;
3360
+ }
3361
+ type ExperimentsNormalized = ExperimentsCommon & ExperimentsNormalizedExtra;
3362
+
3363
+ /**
3364
+ * Enables/Disables experiments (experimental features with relax SemVer compatibility).
3365
+ */
3366
+ declare interface ExperimentsNormalizedExtra {
3367
+ /**
3368
+ * Build http(s): urls using a lockfile and resource content cache.
3369
+ */
3370
+ buildHttp?: HttpUriOptions;
3371
+
3372
+ /**
3373
+ * Compile entrypoints and import()s only when they are accessed.
3374
+ */
3375
+ lazyCompilation?: LazyCompilationOptions;
3376
+ }
3376
3377
  declare abstract class ExportInfo {
3377
3378
  name: string;
3378
3379
 
@@ -3933,12 +3934,12 @@ declare interface FileCacheOptions {
3933
3934
  /**
3934
3935
  * List of paths that are managed by a package manager and contain a version or hash in its path so all files are immutable.
3935
3936
  */
3936
- immutablePaths?: string[];
3937
+ immutablePaths?: (string | RegExp)[];
3937
3938
 
3938
3939
  /**
3939
3940
  * List of paths that are managed by a package manager and can be trusted to not be modified otherwise.
3940
3941
  */
3941
- managedPaths?: string[];
3942
+ managedPaths?: (string | RegExp)[];
3942
3943
 
3943
3944
  /**
3944
3945
  * Time for which unused cache entries stay in the filesystem cache at minimum (in milliseconds).
@@ -4051,10 +4052,12 @@ declare abstract class FileSystemInfo {
4051
4052
  contextTshQueue: AsyncQueue<string, string, null | ContextTimestampAndHash>;
4052
4053
  managedItemQueue: AsyncQueue<string, string, null | string>;
4053
4054
  managedItemDirectoryQueue: AsyncQueue<string, string, Set<string>>;
4054
- managedPaths: string[];
4055
+ managedPaths: (string | RegExp)[];
4055
4056
  managedPathsWithSlash: string[];
4056
- immutablePaths: string[];
4057
+ managedPathsRegExps: RegExp[];
4058
+ immutablePaths: (string | RegExp)[];
4057
4059
  immutablePathsWithSlash: string[];
4060
+ immutablePathsRegExps: RegExp[];
4058
4061
  logStatistics(): void;
4059
4062
  clear(): void;
4060
4063
  addFileTimestamps(
@@ -4380,6 +4383,11 @@ declare class HotUpdateChunk extends Chunk {
4380
4383
  * Options for building http resources.
4381
4384
  */
4382
4385
  declare interface HttpUriOptions {
4386
+ /**
4387
+ * List of allowed URIs (resp. the beginning of them).
4388
+ */
4389
+ allowedUris: (string | RegExp | ((uri: string) => boolean))[];
4390
+
4383
4391
  /**
4384
4392
  * Location where resource content is stored for lockfile entries. It's also possible to disable storing by passing false.
4385
4393
  */
@@ -4401,27 +4409,7 @@ declare interface HttpUriOptions {
4401
4409
  upgrade?: boolean;
4402
4410
  }
4403
4411
  declare class HttpUriPlugin {
4404
- constructor(options?: {
4405
- /**
4406
- * Location where resource content is stored for lockfile entries. It's also possible to disable storing by passing false.
4407
- */
4408
- cacheLocation?: string | false;
4409
- /**
4410
- * When set, anything that would lead to a modification of the lockfile or any resource content, will result in an error.
4411
- */
4412
- frozen?: boolean;
4413
- /**
4414
- * Location of the lockfile.
4415
- */
4416
- lockfileLocation?: string;
4417
- /**
4418
- * When set, resources of existing lockfile entries will be fetched and entries will be upgraded when resource content has changed.
4419
- */
4420
- upgrade?: boolean;
4421
- hashFunction?: string | typeof Hash;
4422
- hashDigest?: string;
4423
- hashDigestLength?: number;
4424
- });
4412
+ constructor(options: HttpUriOptions);
4425
4413
 
4426
4414
  /**
4427
4415
  * Apply the plugin
@@ -5812,6 +5800,62 @@ declare interface KnownStatsProfile {
5812
5800
  factory: number;
5813
5801
  dependencies: number;
5814
5802
  }
5803
+
5804
+ /**
5805
+ * Options for the default backend.
5806
+ */
5807
+ declare interface LazyCompilationDefaultBackendOptions {
5808
+ /**
5809
+ * A custom client.
5810
+ */
5811
+ client?: string;
5812
+
5813
+ /**
5814
+ * Specifies where to listen to from the server.
5815
+ */
5816
+ listen?: number | ListenOptions | ((server: typeof Server) => void);
5817
+
5818
+ /**
5819
+ * Specifies the protocol the client should use to connect to the server.
5820
+ */
5821
+ protocol?: "http" | "https";
5822
+
5823
+ /**
5824
+ * Specifies how to create the server handling the EventSource requests.
5825
+ */
5826
+ server?: ServerOptionsImport | ServerOptionsHttps | (() => typeof Server);
5827
+ }
5828
+
5829
+ /**
5830
+ * Options for compiling entrypoints and import()s only when they are accessed.
5831
+ */
5832
+ declare interface LazyCompilationOptions {
5833
+ /**
5834
+ * Specifies the backend that should be used for handling client keep alive.
5835
+ */
5836
+ backend?:
5837
+ | ((
5838
+ compiler: Compiler,
5839
+ callback: (err?: Error, api?: BackendApi) => void
5840
+ ) => void)
5841
+ | ((compiler: Compiler) => Promise<BackendApi>)
5842
+ | LazyCompilationDefaultBackendOptions;
5843
+
5844
+ /**
5845
+ * Enable/disable lazy compilation for entries.
5846
+ */
5847
+ entries?: boolean;
5848
+
5849
+ /**
5850
+ * Enable/disable lazy compilation for import() modules.
5851
+ */
5852
+ imports?: boolean;
5853
+
5854
+ /**
5855
+ * Specify which entrypoints or import()ed modules should be lazily compiled. This is matched with the imported module and not the entrypoint name.
5856
+ */
5857
+ test?: string | RegExp | ((module: Module) => boolean);
5858
+ }
5815
5859
  declare class LazySet<T> {
5816
5860
  constructor(iterable?: Iterable<T>);
5817
5861
  readonly size: number;
@@ -7352,12 +7396,6 @@ declare class NormalModule extends Module {
7352
7396
  sourceMap?: any,
7353
7397
  associatedObjectForCache?: Object
7354
7398
  ): Source;
7355
- createLoaderContext(
7356
- resolver: ResolverWithOptions,
7357
- options: WebpackOptionsNormalized,
7358
- compilation: Compilation,
7359
- fs: InputFileSystem
7360
- ): NormalModuleLoaderContext<any>;
7361
7399
  getCurrentLoader(loaderContext?: any, index?: any): null | LoaderItem;
7362
7400
  createSource(
7363
7401
  context: string,
@@ -7365,13 +7403,6 @@ declare class NormalModule extends Module {
7365
7403
  sourceMap?: any,
7366
7404
  associatedObjectForCache?: Object
7367
7405
  ): Source;
7368
- doBuild(
7369
- options: WebpackOptionsNormalized,
7370
- compilation: Compilation,
7371
- resolver: ResolverWithOptions,
7372
- fs: InputFileSystem,
7373
- callback: (arg0?: WebpackError) => void
7374
- ): void;
7375
7406
  markModuleAsErrored(error: WebpackError): void;
7376
7407
  applyNoParseRule(rule?: any, content?: any): any;
7377
7408
  shouldPreventParsing(noParseRule?: any, request?: any): any;
@@ -7383,6 +7414,8 @@ declare class NormalModule extends Module {
7383
7414
  declare interface NormalModuleCompilationHooks {
7384
7415
  loader: SyncHook<[object, NormalModule]>;
7385
7416
  beforeLoaders: SyncHook<[LoaderItem[], NormalModule, object]>;
7417
+ beforeParse: SyncHook<[NormalModule]>;
7418
+ beforeSnapshot: SyncHook<[NormalModule]>;
7386
7419
  readResourceForScheme: HookMap<
7387
7420
  AsyncSeriesBailHook<[string, NormalModule], string | Buffer>
7388
7421
  >;
@@ -7817,6 +7850,11 @@ declare interface OptimizationSplitChunksCacheGroup {
7817
7850
  */
7818
7851
  minSize?: number | { [index: string]: number };
7819
7852
 
7853
+ /**
7854
+ * Minimum size reduction due to the created chunk.
7855
+ */
7856
+ minSizeReduction?: number | { [index: string]: number };
7857
+
7820
7858
  /**
7821
7859
  * Give chunks for this cache group a name (chunks with equal name are merged).
7822
7860
  */
@@ -7908,6 +7946,10 @@ declare interface OptimizationSplitChunksOptions {
7908
7946
  * Minimal size for the created chunk.
7909
7947
  */
7910
7948
  minSize?: number | { [index: string]: number };
7949
+ /**
7950
+ * Minimum size reduction due to the created chunk.
7951
+ */
7952
+ minSizeReduction?: number | { [index: string]: number };
7911
7953
  };
7912
7954
 
7913
7955
  /**
@@ -7960,6 +8002,11 @@ declare interface OptimizationSplitChunksOptions {
7960
8002
  */
7961
8003
  minSize?: number | { [index: string]: number };
7962
8004
 
8005
+ /**
8006
+ * Minimum size reduction due to the created chunk.
8007
+ */
8008
+ minSizeReduction?: number | { [index: string]: number };
8009
+
7963
8010
  /**
7964
8011
  * Give chunks created a name (chunks with equal name are merged).
7965
8012
  */
@@ -10349,6 +10396,9 @@ declare abstract class Serializer {
10349
10396
  serialize(obj?: any, context?: any): any;
10350
10397
  deserialize(value?: any, context?: any): any;
10351
10398
  }
10399
+ type ServerOptionsHttps = SecureContextOptions &
10400
+ TlsOptions &
10401
+ ServerOptionsImport;
10352
10402
  declare class SharePlugin {
10353
10403
  constructor(options: SharePluginOptions);
10354
10404
 
@@ -10448,12 +10498,12 @@ declare class SizeOnlySource extends Source {
10448
10498
  }
10449
10499
  declare abstract class Snapshot {
10450
10500
  startTime?: number;
10451
- fileTimestamps?: Map<string, FileSystemInfoEntry>;
10452
- fileHashes?: Map<string, string>;
10453
- fileTshs?: Map<string, string | TimestampAndHash>;
10454
- contextTimestamps?: Map<string, ResolvedContextFileSystemInfoEntry>;
10455
- contextHashes?: Map<string, string>;
10456
- contextTshs?: Map<string, ResolvedContextTimestampAndHash>;
10501
+ fileTimestamps?: Map<string, null | FileSystemInfoEntry>;
10502
+ fileHashes?: Map<string, null | string>;
10503
+ fileTshs?: Map<string, null | string | TimestampAndHash>;
10504
+ contextTimestamps?: Map<string, null | ResolvedContextFileSystemInfoEntry>;
10505
+ contextHashes?: Map<string, null | string>;
10506
+ contextTshs?: Map<string, null | ResolvedContextTimestampAndHash>;
10457
10507
  missingExistence?: Map<string, boolean>;
10458
10508
  managedItemInfo?: Map<string, string>;
10459
10509
  managedFiles?: Set<string>;
@@ -10516,12 +10566,12 @@ declare interface SnapshotOptions {
10516
10566
  /**
10517
10567
  * List of paths that are managed by a package manager and contain a version or hash in its path so all files are immutable.
10518
10568
  */
10519
- immutablePaths?: string[];
10569
+ immutablePaths?: (string | RegExp)[];
10520
10570
 
10521
10571
  /**
10522
10572
  * List of paths that are managed by a package manager and can be trusted to not be modified otherwise.
10523
10573
  */
10524
- managedPaths?: string[];
10574
+ managedPaths?: (string | RegExp)[];
10525
10575
 
10526
10576
  /**
10527
10577
  * Options for snapshotting dependencies of modules to determine if they need to be built again.
@@ -10721,6 +10771,7 @@ declare interface SplitChunksOptions {
10721
10771
  chunksFilter: (chunk: Chunk) => boolean;
10722
10772
  defaultSizeTypes: string[];
10723
10773
  minSize: SplitChunksSizes;
10774
+ minSizeReduction: SplitChunksSizes;
10724
10775
  minRemainingSize: SplitChunksSizes;
10725
10776
  enforceSizeThreshold: SplitChunksSizes;
10726
10777
  maxInitialSize: SplitChunksSizes;
@@ -11846,7 +11897,7 @@ declare interface WebpackOptionsNormalized {
11846
11897
  /**
11847
11898
  * Enables/Disables experiments (experimental features with relax SemVer compatibility).
11848
11899
  */
11849
- experiments: Experiments;
11900
+ experiments: ExperimentsNormalized;
11850
11901
 
11851
11902
  /**
11852
11903
  * Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.