webpack 5.58.0 → 5.59.1

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
@@ -631,6 +631,7 @@ declare interface CacheGroupSource {
631
631
  chunksFilter?: (chunk: Chunk) => boolean;
632
632
  enforce?: boolean;
633
633
  minSize: SplitChunksSizes;
634
+ minSizeReduction: SplitChunksSizes;
634
635
  minRemainingSize: SplitChunksSizes;
635
636
  enforceSizeThreshold: SplitChunksSizes;
636
637
  maxAsyncSize: SplitChunksSizes;
@@ -757,17 +758,6 @@ declare class Chunk {
757
758
  filterFn?: (c: Chunk, chunkGraph: ChunkGraph) => boolean
758
759
  ): Record<string | number, Record<string, (string | number)[]>>;
759
760
  }
760
- declare abstract class ChunkCombination {
761
- debugId: number;
762
- size: number;
763
- readonly chunksIterable: Iterable<Chunk>;
764
- with(chunk: Chunk): ChunkCombination;
765
- without(chunk: Chunk): ChunkCombination;
766
- withAll(other?: any): any;
767
- hasSharedChunks(other?: any): boolean;
768
- isSubset(other: ChunkCombination): boolean;
769
- getChunks(): Chunk[];
770
- }
771
761
  declare class ChunkGraph {
772
762
  constructor(moduleGraph: ModuleGraph, hashFunction?: string | typeof Hash);
773
763
  moduleGraph: ModuleGraph;
@@ -785,7 +775,6 @@ declare class ChunkGraph {
785
775
  isModuleInChunk(module: Module, chunk: Chunk): boolean;
786
776
  isModuleInChunkGroup(module: Module, chunkGroup: ChunkGroup): boolean;
787
777
  isEntryModule(module: Module): boolean;
788
- getModuleChunkCombination(module: Module): ChunkCombination;
789
778
  getModuleChunksIterable(module: Module): Iterable<Chunk>;
790
779
  getOrderedModuleChunksIterable(
791
780
  module: Module,
@@ -1907,8 +1896,8 @@ declare class Compiler {
1907
1896
  recordsInputPath: null | string;
1908
1897
  recordsOutputPath: null | string;
1909
1898
  records: object;
1910
- managedPaths: Set<string>;
1911
- immutablePaths: Set<string>;
1899
+ managedPaths: Set<string | RegExp>;
1900
+ immutablePaths: Set<string | RegExp>;
1912
1901
  modifiedFiles: ReadonlySet<string>;
1913
1902
  removedFiles: ReadonlySet<string>;
1914
1903
  fileTimestamps: ReadonlyMap<string, null | FileSystemInfoEntry | "ignore">;
@@ -3301,11 +3290,12 @@ declare interface ExecuteModuleResult {
3301
3290
  missingDependencies: LazySet<string>;
3302
3291
  buildDependencies: LazySet<string>;
3303
3292
  }
3293
+ type Experiments = ExperimentsCommon & ExperimentsExtra;
3304
3294
 
3305
3295
  /**
3306
3296
  * Enables/Disables experiments (experimental features with relax SemVer compatibility).
3307
3297
  */
3308
- declare interface Experiments {
3298
+ declare interface ExperimentsCommon {
3309
3299
  /**
3310
3300
  * Allow module type 'asset' to generate assets.
3311
3301
  */
@@ -3316,11 +3306,6 @@ declare interface Experiments {
3316
3306
  */
3317
3307
  asyncWebAssembly?: boolean;
3318
3308
 
3319
- /**
3320
- * Build http(s): urls using a lockfile and resource content cache.
3321
- */
3322
- buildHttp?: boolean | HttpUriOptions;
3323
-
3324
3309
  /**
3325
3310
  * Enable additional in memory caching of modules that are unchanged and reference only unchanged modules.
3326
3311
  */
@@ -3336,40 +3321,6 @@ declare interface Experiments {
3336
3321
  */
3337
3322
  layers?: boolean;
3338
3323
 
3339
- /**
3340
- * Compile entrypoints and import()s only when they are accessed.
3341
- */
3342
- lazyCompilation?:
3343
- | boolean
3344
- | {
3345
- /**
3346
- * A custom backend.
3347
- */
3348
- backend?:
3349
- | ((
3350
- compiler: Compiler,
3351
- client: string,
3352
- callback: (err?: Error, api?: any) => void
3353
- ) => void)
3354
- | ((compiler: Compiler, client: string) => Promise<any>);
3355
- /**
3356
- * A custom client.
3357
- */
3358
- client?: string;
3359
- /**
3360
- * Enable/disable lazy compilation for entries.
3361
- */
3362
- entries?: boolean;
3363
- /**
3364
- * Enable/disable lazy compilation for import() modules.
3365
- */
3366
- imports?: boolean;
3367
- /**
3368
- * Specify which entrypoints or import()ed modules should be lazily compiled. This is matched with the imported module and not the entrypoint name.
3369
- */
3370
- test?: string | RegExp | ((module: Module) => boolean);
3371
- };
3372
-
3373
3324
  /**
3374
3325
  * Allow output javascript files as module source type.
3375
3326
  */
@@ -3385,6 +3336,37 @@ declare interface Experiments {
3385
3336
  */
3386
3337
  topLevelAwait?: boolean;
3387
3338
  }
3339
+
3340
+ /**
3341
+ * Enables/Disables experiments (experimental features with relax SemVer compatibility).
3342
+ */
3343
+ declare interface ExperimentsExtra {
3344
+ /**
3345
+ * Build http(s): urls using a lockfile and resource content cache.
3346
+ */
3347
+ buildHttp?: HttpUriOptions | (string | RegExp | ((uri: string) => boolean))[];
3348
+
3349
+ /**
3350
+ * Compile entrypoints and import()s only when they are accessed.
3351
+ */
3352
+ lazyCompilation?: boolean | LazyCompilationOptions;
3353
+ }
3354
+ type ExperimentsNormalized = ExperimentsCommon & ExperimentsNormalizedExtra;
3355
+
3356
+ /**
3357
+ * Enables/Disables experiments (experimental features with relax SemVer compatibility).
3358
+ */
3359
+ declare interface ExperimentsNormalizedExtra {
3360
+ /**
3361
+ * Build http(s): urls using a lockfile and resource content cache.
3362
+ */
3363
+ buildHttp?: HttpUriOptions;
3364
+
3365
+ /**
3366
+ * Compile entrypoints and import()s only when they are accessed.
3367
+ */
3368
+ lazyCompilation?: LazyCompilationOptions;
3369
+ }
3388
3370
  declare abstract class ExportInfo {
3389
3371
  name: string;
3390
3372
 
@@ -3945,12 +3927,12 @@ declare interface FileCacheOptions {
3945
3927
  /**
3946
3928
  * List of paths that are managed by a package manager and contain a version or hash in its path so all files are immutable.
3947
3929
  */
3948
- immutablePaths?: string[];
3930
+ immutablePaths?: (string | RegExp)[];
3949
3931
 
3950
3932
  /**
3951
3933
  * List of paths that are managed by a package manager and can be trusted to not be modified otherwise.
3952
3934
  */
3953
- managedPaths?: string[];
3935
+ managedPaths?: (string | RegExp)[];
3954
3936
 
3955
3937
  /**
3956
3938
  * Time for which unused cache entries stay in the filesystem cache at minimum (in milliseconds).
@@ -4063,10 +4045,12 @@ declare abstract class FileSystemInfo {
4063
4045
  contextTshQueue: AsyncQueue<string, string, null | ContextTimestampAndHash>;
4064
4046
  managedItemQueue: AsyncQueue<string, string, null | string>;
4065
4047
  managedItemDirectoryQueue: AsyncQueue<string, string, Set<string>>;
4066
- managedPaths: string[];
4048
+ managedPaths: (string | RegExp)[];
4067
4049
  managedPathsWithSlash: string[];
4068
- immutablePaths: string[];
4050
+ managedPathsRegExps: RegExp[];
4051
+ immutablePaths: (string | RegExp)[];
4069
4052
  immutablePathsWithSlash: string[];
4053
+ immutablePathsRegExps: RegExp[];
4070
4054
  logStatistics(): void;
4071
4055
  clear(): void;
4072
4056
  addFileTimestamps(
@@ -4392,6 +4376,11 @@ declare class HotUpdateChunk extends Chunk {
4392
4376
  * Options for building http resources.
4393
4377
  */
4394
4378
  declare interface HttpUriOptions {
4379
+ /**
4380
+ * List of allowed URIs (resp. the beginning of them).
4381
+ */
4382
+ allowedUris: (string | RegExp | ((uri: string) => boolean))[];
4383
+
4395
4384
  /**
4396
4385
  * Location where resource content is stored for lockfile entries. It's also possible to disable storing by passing false.
4397
4386
  */
@@ -4413,27 +4402,7 @@ declare interface HttpUriOptions {
4413
4402
  upgrade?: boolean;
4414
4403
  }
4415
4404
  declare class HttpUriPlugin {
4416
- constructor(options?: {
4417
- /**
4418
- * Location where resource content is stored for lockfile entries. It's also possible to disable storing by passing false.
4419
- */
4420
- cacheLocation?: string | false;
4421
- /**
4422
- * When set, anything that would lead to a modification of the lockfile or any resource content, will result in an error.
4423
- */
4424
- frozen?: boolean;
4425
- /**
4426
- * Location of the lockfile.
4427
- */
4428
- lockfileLocation?: string;
4429
- /**
4430
- * When set, resources of existing lockfile entries will be fetched and entries will be upgraded when resource content has changed.
4431
- */
4432
- upgrade?: boolean;
4433
- hashFunction?: string | typeof Hash;
4434
- hashDigest?: string;
4435
- hashDigestLength?: number;
4436
- });
4405
+ constructor(options: HttpUriOptions);
4437
4406
 
4438
4407
  /**
4439
4408
  * Apply the plugin
@@ -5824,6 +5793,42 @@ declare interface KnownStatsProfile {
5824
5793
  factory: number;
5825
5794
  dependencies: number;
5826
5795
  }
5796
+
5797
+ /**
5798
+ * Options for compiling entrypoints and import()s only when they are accessed.
5799
+ */
5800
+ declare interface LazyCompilationOptions {
5801
+ /**
5802
+ * A custom backend.
5803
+ */
5804
+ backend?:
5805
+ | ((
5806
+ compiler: Compiler,
5807
+ client: string,
5808
+ callback: (err?: Error, api?: any) => void
5809
+ ) => void)
5810
+ | ((compiler: Compiler, client: string) => Promise<any>);
5811
+
5812
+ /**
5813
+ * A custom client.
5814
+ */
5815
+ client?: string;
5816
+
5817
+ /**
5818
+ * Enable/disable lazy compilation for entries.
5819
+ */
5820
+ entries?: boolean;
5821
+
5822
+ /**
5823
+ * Enable/disable lazy compilation for import() modules.
5824
+ */
5825
+ imports?: boolean;
5826
+
5827
+ /**
5828
+ * Specify which entrypoints or import()ed modules should be lazily compiled. This is matched with the imported module and not the entrypoint name.
5829
+ */
5830
+ test?: string | RegExp | ((module: Module) => boolean);
5831
+ }
5827
5832
  declare class LazySet<T> {
5828
5833
  constructor(iterable?: Iterable<T>);
5829
5834
  readonly size: number;
@@ -7364,12 +7369,6 @@ declare class NormalModule extends Module {
7364
7369
  sourceMap?: any,
7365
7370
  associatedObjectForCache?: Object
7366
7371
  ): Source;
7367
- createLoaderContext(
7368
- resolver: ResolverWithOptions,
7369
- options: WebpackOptionsNormalized,
7370
- compilation: Compilation,
7371
- fs: InputFileSystem
7372
- ): NormalModuleLoaderContext<any>;
7373
7372
  getCurrentLoader(loaderContext?: any, index?: any): null | LoaderItem;
7374
7373
  createSource(
7375
7374
  context: string,
@@ -7377,13 +7376,6 @@ declare class NormalModule extends Module {
7377
7376
  sourceMap?: any,
7378
7377
  associatedObjectForCache?: Object
7379
7378
  ): Source;
7380
- doBuild(
7381
- options: WebpackOptionsNormalized,
7382
- compilation: Compilation,
7383
- resolver: ResolverWithOptions,
7384
- fs: InputFileSystem,
7385
- callback: (arg0?: WebpackError) => void
7386
- ): void;
7387
7379
  markModuleAsErrored(error: WebpackError): void;
7388
7380
  applyNoParseRule(rule?: any, content?: any): any;
7389
7381
  shouldPreventParsing(noParseRule?: any, request?: any): any;
@@ -7395,6 +7387,8 @@ declare class NormalModule extends Module {
7395
7387
  declare interface NormalModuleCompilationHooks {
7396
7388
  loader: SyncHook<[object, NormalModule]>;
7397
7389
  beforeLoaders: SyncHook<[LoaderItem[], NormalModule, object]>;
7390
+ beforeParse: SyncHook<[NormalModule]>;
7391
+ beforeSnapshot: SyncHook<[NormalModule]>;
7398
7392
  readResourceForScheme: HookMap<
7399
7393
  AsyncSeriesBailHook<[string, NormalModule], string | Buffer>
7400
7394
  >;
@@ -7829,6 +7823,11 @@ declare interface OptimizationSplitChunksCacheGroup {
7829
7823
  */
7830
7824
  minSize?: number | { [index: string]: number };
7831
7825
 
7826
+ /**
7827
+ * Minimum size reduction due to the created chunk.
7828
+ */
7829
+ minSizeReduction?: number | { [index: string]: number };
7830
+
7832
7831
  /**
7833
7832
  * Give chunks for this cache group a name (chunks with equal name are merged).
7834
7833
  */
@@ -7920,6 +7919,10 @@ declare interface OptimizationSplitChunksOptions {
7920
7919
  * Minimal size for the created chunk.
7921
7920
  */
7922
7921
  minSize?: number | { [index: string]: number };
7922
+ /**
7923
+ * Minimum size reduction due to the created chunk.
7924
+ */
7925
+ minSizeReduction?: number | { [index: string]: number };
7923
7926
  };
7924
7927
 
7925
7928
  /**
@@ -7972,6 +7975,11 @@ declare interface OptimizationSplitChunksOptions {
7972
7975
  */
7973
7976
  minSize?: number | { [index: string]: number };
7974
7977
 
7978
+ /**
7979
+ * Minimum size reduction due to the created chunk.
7980
+ */
7981
+ minSizeReduction?: number | { [index: string]: number };
7982
+
7975
7983
  /**
7976
7984
  * Give chunks created a name (chunks with equal name are merged).
7977
7985
  */
@@ -10460,12 +10468,12 @@ declare class SizeOnlySource extends Source {
10460
10468
  }
10461
10469
  declare abstract class Snapshot {
10462
10470
  startTime?: number;
10463
- fileTimestamps?: Map<string, FileSystemInfoEntry>;
10464
- fileHashes?: Map<string, string>;
10465
- fileTshs?: Map<string, string | TimestampAndHash>;
10466
- contextTimestamps?: Map<string, ResolvedContextFileSystemInfoEntry>;
10467
- contextHashes?: Map<string, string>;
10468
- contextTshs?: Map<string, ResolvedContextTimestampAndHash>;
10471
+ fileTimestamps?: Map<string, null | FileSystemInfoEntry>;
10472
+ fileHashes?: Map<string, null | string>;
10473
+ fileTshs?: Map<string, null | string | TimestampAndHash>;
10474
+ contextTimestamps?: Map<string, null | ResolvedContextFileSystemInfoEntry>;
10475
+ contextHashes?: Map<string, null | string>;
10476
+ contextTshs?: Map<string, null | ResolvedContextTimestampAndHash>;
10469
10477
  missingExistence?: Map<string, boolean>;
10470
10478
  managedItemInfo?: Map<string, string>;
10471
10479
  managedFiles?: Set<string>;
@@ -10528,12 +10536,12 @@ declare interface SnapshotOptions {
10528
10536
  /**
10529
10537
  * List of paths that are managed by a package manager and contain a version or hash in its path so all files are immutable.
10530
10538
  */
10531
- immutablePaths?: string[];
10539
+ immutablePaths?: (string | RegExp)[];
10532
10540
 
10533
10541
  /**
10534
10542
  * List of paths that are managed by a package manager and can be trusted to not be modified otherwise.
10535
10543
  */
10536
- managedPaths?: string[];
10544
+ managedPaths?: (string | RegExp)[];
10537
10545
 
10538
10546
  /**
10539
10547
  * Options for snapshotting dependencies of modules to determine if they need to be built again.
@@ -10733,6 +10741,7 @@ declare interface SplitChunksOptions {
10733
10741
  chunksFilter: (chunk: Chunk) => boolean;
10734
10742
  defaultSizeTypes: string[];
10735
10743
  minSize: SplitChunksSizes;
10744
+ minSizeReduction: SplitChunksSizes;
10736
10745
  minRemainingSize: SplitChunksSizes;
10737
10746
  enforceSizeThreshold: SplitChunksSizes;
10738
10747
  maxInitialSize: SplitChunksSizes;
@@ -11858,7 +11867,7 @@ declare interface WebpackOptionsNormalized {
11858
11867
  /**
11859
11868
  * Enables/Disables experiments (experimental features with relax SemVer compatibility).
11860
11869
  */
11861
- experiments: Experiments;
11870
+ experiments: ExperimentsNormalized;
11862
11871
 
11863
11872
  /**
11864
11873
  * 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`.
@@ -1,187 +0,0 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
-
6
- "use strict";
7
-
8
- const SortableSet = require("./util/SortableSet");
9
-
10
- /** @typedef {import("./Chunk")} Chunk */
11
-
12
- /**
13
- * @template T
14
- * @param {SortableSet<T>} set the set
15
- * @returns {T[]} set as array
16
- */
17
- const getArray = set => {
18
- return Array.from(set);
19
- };
20
-
21
- let debugId = 1;
22
-
23
- class ChunkCombination {
24
- constructor() {
25
- this.debugId = debugId++;
26
- this.size = 0;
27
- /**
28
- * (do not modify)
29
- * @type {SortableSet<Chunk>}
30
- */
31
- this._chunks = new SortableSet();
32
- /** @type {ChunkCombination} */
33
- this._parent = undefined;
34
- this._lastChunk = undefined;
35
- /** @type {WeakMap<Chunk, ChunkCombination>} */
36
- this._addMap = new WeakMap();
37
- /** @type {WeakMap<Chunk, ChunkCombination>} */
38
- this._removeCache = new WeakMap();
39
- }
40
-
41
- /**
42
- * @returns {Iterable<Chunk>} iterable of chunks
43
- */
44
- get chunksIterable() {
45
- return this._chunks;
46
- }
47
-
48
- /**
49
- * @param {Chunk} chunk chunk to add
50
- * @returns {ChunkCombination} new chunk combination
51
- */
52
- with(chunk) {
53
- if (this._chunks.has(chunk)) return this;
54
- let next = this._addMap.get(chunk);
55
- if (next !== undefined) return next;
56
- // must insert chunks in order to maintain order-independent identity of ChunkCombination
57
- if (!this._parent || this._lastChunk.debugId < chunk.debugId) {
58
- next = new ChunkCombination();
59
- for (const chunk of this._chunks) {
60
- next._chunks.add(chunk);
61
- }
62
- next._chunks.add(chunk);
63
- next._removeCache.set(chunk, this);
64
- next.size = this.size + 1;
65
- next._parent = this;
66
- next._lastChunk = chunk;
67
- } else {
68
- next = this._parent.with(chunk).with(this._lastChunk);
69
- }
70
- this._addMap.set(chunk, next);
71
- return next;
72
- }
73
-
74
- /**
75
- * @param {Chunk} chunk chunk to remove
76
- * @returns {ChunkCombination} new chunk combination
77
- */
78
- without(chunk) {
79
- if (!this._chunks.has(chunk)) return this;
80
- let next = this._removeCache.get(chunk);
81
- if (next !== undefined) return next;
82
- const stack = [this._lastChunk];
83
- let current = this._parent;
84
- while (current._lastChunk !== chunk) {
85
- stack.push(current._lastChunk);
86
- current = current._parent;
87
- }
88
- next = current._parent;
89
- while (stack.length) next = next.with(stack.pop());
90
- this._removeCache.set(chunk, next);
91
- return next;
92
- }
93
-
94
- withAll(other) {
95
- if (other.size === 0) return this;
96
- if (this.size === 0) return other;
97
- const stack = [];
98
- /** @type {ChunkCombination} */
99
- let current = this;
100
- for (;;) {
101
- if (current._lastChunk.debugId < other._lastChunk.debugId) {
102
- stack.push(other._lastChunk);
103
- other = other._parent;
104
- if (other.size === 0) {
105
- while (stack.length) current = current.with(stack.pop());
106
- return current;
107
- }
108
- } else {
109
- stack.push(current._lastChunk);
110
- current = current._parent;
111
- if (current.size === 0) {
112
- while (stack.length) other = other.with(stack.pop());
113
- return other;
114
- }
115
- }
116
- }
117
- }
118
-
119
- hasSharedChunks(other) {
120
- if (this.size > other.size) {
121
- const chunks = this._chunks;
122
- for (const chunk of other._chunks) {
123
- if (chunks.has(chunk)) return true;
124
- }
125
- } else {
126
- const chunks = other._chunks;
127
- for (const chunk of this._chunks) {
128
- if (chunks.has(chunk)) return true;
129
- }
130
- }
131
- return false;
132
- }
133
-
134
- /**
135
- * @param {ChunkCombination} other other combination
136
- * @returns {boolean} true, when other is a subset of this combination
137
- */
138
- isSubset(other) {
139
- // TODO: This could be more efficient when using the debugId order of the combinations
140
- /** @type {ChunkCombination} */
141
- let current = this;
142
- let otherSize = other.size;
143
- let currentSize = current.size;
144
- if (otherSize === 0) return true;
145
- for (;;) {
146
- if (currentSize === 0) return false;
147
- if (otherSize === 1) {
148
- if (currentSize === 1) {
149
- return current._lastChunk === other._lastChunk;
150
- } else {
151
- return current._chunks.has(other._lastChunk);
152
- }
153
- }
154
- if (otherSize * 8 < currentSize) {
155
- // go for the Set access when current >> other
156
- const chunks = current._chunks;
157
- for (const item of other._chunks) {
158
- if (!chunks.has(item)) return false;
159
- }
160
- return true;
161
- }
162
- const otherId = other._lastChunk.debugId;
163
- // skip over nodes in current that have higher ids
164
- while (otherId < current._lastChunk.debugId) {
165
- current = current._parent;
166
- currentSize--;
167
- if (currentSize === 0) return false;
168
- }
169
- if (otherId > current._lastChunk.debugId) {
170
- return false;
171
- }
172
- other = other._parent;
173
- otherSize--;
174
- if (otherSize === 0) return true;
175
- current = current._parent;
176
- currentSize--;
177
- }
178
- }
179
-
180
- getChunks() {
181
- return this._chunks.getFromUnorderedCache(getArray);
182
- }
183
- }
184
-
185
- ChunkCombination.empty = new ChunkCombination();
186
-
187
- module.exports = ChunkCombination;