webpack 5.88.0 → 5.88.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.
- package/lib/BannerPlugin.js +2 -1
- package/lib/Compiler.js +6 -6
- package/lib/ConstPlugin.js +16 -3
- package/lib/DependencyTemplates.js +1 -1
- package/lib/ExportsInfo.js +5 -1
- package/lib/FileSystemInfo.js +52 -24
- package/lib/Generator.js +7 -0
- package/lib/Watching.js +62 -25
- package/lib/buildChunkGraph.js +37 -21
- package/lib/cache/PackFileCacheStrategy.js +19 -9
- package/lib/dependencies/CssLocalIdentifierDependency.js +3 -0
- package/lib/javascript/JavascriptModulesPlugin.js +24 -5
- package/lib/library/AmdLibraryPlugin.js +2 -2
- package/lib/library/AssignLibraryPlugin.js +13 -1
- package/lib/library/EnableLibraryPlugin.js +4 -0
- package/lib/library/SystemLibraryPlugin.js +1 -1
- package/lib/library/UmdLibraryPlugin.js +20 -2
- package/lib/util/StackedCacheMap.js +1 -1
- package/lib/util/URLAbsoluteSpecifier.js +1 -1
- package/lib/util/runtime.js +70 -20
- package/lib/util/semver.js +1 -0
- package/package.json +1 -1
- package/schemas/WebpackOptions.json +1 -1
- package/types.d.ts +36 -31
package/lib/util/runtime.js
CHANGED
@@ -53,7 +53,7 @@ exports.getEntryRuntime = (compilation, name, options) => {
|
|
53
53
|
|
54
54
|
/**
|
55
55
|
* @param {RuntimeSpec} runtime runtime
|
56
|
-
* @param {function(string): void} fn functor
|
56
|
+
* @param {function(string | undefined): void} fn functor
|
57
57
|
* @param {boolean} deterministicOrder enforce a deterministic order
|
58
58
|
* @returns {void}
|
59
59
|
*/
|
@@ -70,6 +70,11 @@ exports.forEachRuntime = (runtime, fn, deterministicOrder = false) => {
|
|
70
70
|
}
|
71
71
|
};
|
72
72
|
|
73
|
+
/**
|
74
|
+
* @template T
|
75
|
+
* @param {SortableSet<T>} set set
|
76
|
+
* @returns {string} runtime key
|
77
|
+
*/
|
73
78
|
const getRuntimesKey = set => {
|
74
79
|
set.sort();
|
75
80
|
return Array.from(set).join("\n");
|
@@ -98,6 +103,11 @@ const keyToRuntime = key => {
|
|
98
103
|
};
|
99
104
|
exports.keyToRuntime = keyToRuntime;
|
100
105
|
|
106
|
+
/**
|
107
|
+
* @template T
|
108
|
+
* @param {SortableSet<T>} set set
|
109
|
+
* @returns {string} runtime string
|
110
|
+
*/
|
101
111
|
const getRuntimesString = set => {
|
102
112
|
set.sort();
|
103
113
|
return Array.from(set).join("+");
|
@@ -415,6 +425,11 @@ exports.filterRuntime = (runtime, filter) => {
|
|
415
425
|
return result;
|
416
426
|
};
|
417
427
|
|
428
|
+
/**
|
429
|
+
* @template T
|
430
|
+
* @typedef {Map<string, T>} RuntimeSpecMapInnerMap
|
431
|
+
* */
|
432
|
+
|
418
433
|
/**
|
419
434
|
* @template T
|
420
435
|
*/
|
@@ -426,9 +441,9 @@ class RuntimeSpecMap {
|
|
426
441
|
this._mode = clone ? clone._mode : 0; // 0 = empty, 1 = single entry, 2 = map
|
427
442
|
/** @type {RuntimeSpec} */
|
428
443
|
this._singleRuntime = clone ? clone._singleRuntime : undefined;
|
429
|
-
/** @type {T} */
|
444
|
+
/** @type {T | undefined} */
|
430
445
|
this._singleValue = clone ? clone._singleValue : undefined;
|
431
|
-
/** @type {
|
446
|
+
/** @type {RuntimeSpecMapInnerMap<T> | undefined} */
|
432
447
|
this._map = clone && clone._map ? new Map(clone._map) : undefined;
|
433
448
|
}
|
434
449
|
|
@@ -445,7 +460,9 @@ class RuntimeSpecMap {
|
|
445
460
|
? this._singleValue
|
446
461
|
: undefined;
|
447
462
|
default:
|
448
|
-
return this._map.get(
|
463
|
+
return /** @type {RuntimeSpecMapInnerMap<T>} */ (this._map).get(
|
464
|
+
getRuntimeKey(runtime)
|
465
|
+
);
|
449
466
|
}
|
450
467
|
}
|
451
468
|
|
@@ -460,10 +477,16 @@ class RuntimeSpecMap {
|
|
460
477
|
case 1:
|
461
478
|
return runtimeEqual(this._singleRuntime, runtime);
|
462
479
|
default:
|
463
|
-
return this._map.has(
|
480
|
+
return /** @type {RuntimeSpecMapInnerMap<T>} */ (this._map).has(
|
481
|
+
getRuntimeKey(runtime)
|
482
|
+
);
|
464
483
|
}
|
465
484
|
}
|
466
485
|
|
486
|
+
/**
|
487
|
+
* @param {RuntimeSpec} runtime the runtimes
|
488
|
+
* @param {T} value the value
|
489
|
+
*/
|
467
490
|
set(runtime, value) {
|
468
491
|
switch (this._mode) {
|
469
492
|
case 0:
|
@@ -478,15 +501,24 @@ class RuntimeSpecMap {
|
|
478
501
|
}
|
479
502
|
this._mode = 2;
|
480
503
|
this._map = new Map();
|
481
|
-
this._map.set(
|
504
|
+
this._map.set(
|
505
|
+
getRuntimeKey(this._singleRuntime),
|
506
|
+
/** @type {T} */ (this._singleValue)
|
507
|
+
);
|
482
508
|
this._singleRuntime = undefined;
|
483
509
|
this._singleValue = undefined;
|
484
510
|
/* falls through */
|
485
511
|
default:
|
486
|
-
|
512
|
+
/** @type {RuntimeSpecMapInnerMap<T>} */
|
513
|
+
(this._map).set(getRuntimeKey(runtime), value);
|
487
514
|
}
|
488
515
|
}
|
489
516
|
|
517
|
+
/**
|
518
|
+
* @param {RuntimeSpec} runtime the runtimes
|
519
|
+
* @param {() => TODO} computer function to compute the value
|
520
|
+
* @returns {TODO} true, when the runtime was deleted
|
521
|
+
*/
|
490
522
|
provide(runtime, computer) {
|
491
523
|
switch (this._mode) {
|
492
524
|
case 0:
|
@@ -495,11 +527,14 @@ class RuntimeSpecMap {
|
|
495
527
|
return (this._singleValue = computer());
|
496
528
|
case 1: {
|
497
529
|
if (runtimeEqual(this._singleRuntime, runtime)) {
|
498
|
-
return this._singleValue;
|
530
|
+
return /** @type {T} */ (this._singleValue);
|
499
531
|
}
|
500
532
|
this._mode = 2;
|
501
533
|
this._map = new Map();
|
502
|
-
this._map.set(
|
534
|
+
this._map.set(
|
535
|
+
getRuntimeKey(this._singleRuntime),
|
536
|
+
/** @type {T} */ (this._singleValue)
|
537
|
+
);
|
503
538
|
this._singleRuntime = undefined;
|
504
539
|
this._singleValue = undefined;
|
505
540
|
const newValue = computer();
|
@@ -508,10 +543,11 @@ class RuntimeSpecMap {
|
|
508
543
|
}
|
509
544
|
default: {
|
510
545
|
const key = getRuntimeKey(runtime);
|
511
|
-
const value = this._map.get(key);
|
546
|
+
const value = /** @type {Map<string, T>} */ (this._map).get(key);
|
512
547
|
if (value !== undefined) return value;
|
513
548
|
const newValue = computer();
|
514
|
-
|
549
|
+
/** @type {Map<string, T>} */
|
550
|
+
(this._map).set(key, newValue);
|
515
551
|
return newValue;
|
516
552
|
}
|
517
553
|
}
|
@@ -532,10 +568,15 @@ class RuntimeSpecMap {
|
|
532
568
|
}
|
533
569
|
return;
|
534
570
|
default:
|
535
|
-
|
571
|
+
/** @type {RuntimeSpecMapInnerMap<T>} */
|
572
|
+
(this._map).delete(getRuntimeKey(runtime));
|
536
573
|
}
|
537
574
|
}
|
538
575
|
|
576
|
+
/**
|
577
|
+
* @param {RuntimeSpec} runtime the runtimes
|
578
|
+
* @param {function(T | undefined): T} fn function to update the value
|
579
|
+
*/
|
539
580
|
update(runtime, fn) {
|
540
581
|
switch (this._mode) {
|
541
582
|
case 0:
|
@@ -549,7 +590,10 @@ class RuntimeSpecMap {
|
|
549
590
|
if (newValue !== undefined) {
|
550
591
|
this._mode = 2;
|
551
592
|
this._map = new Map();
|
552
|
-
this._map.set(
|
593
|
+
this._map.set(
|
594
|
+
getRuntimeKey(this._singleRuntime),
|
595
|
+
/** @type {T} */ (this._singleValue)
|
596
|
+
);
|
553
597
|
this._singleRuntime = undefined;
|
554
598
|
this._singleValue = undefined;
|
555
599
|
this._map.set(getRuntimeKey(runtime), newValue);
|
@@ -558,9 +602,11 @@ class RuntimeSpecMap {
|
|
558
602
|
}
|
559
603
|
default: {
|
560
604
|
const key = getRuntimeKey(runtime);
|
561
|
-
const oldValue = this._map.get(key);
|
605
|
+
const oldValue = /** @type {Map<string, T>} */ (this._map).get(key);
|
562
606
|
const newValue = fn(oldValue);
|
563
|
-
if (newValue !== oldValue)
|
607
|
+
if (newValue !== oldValue)
|
608
|
+
/** @type {RuntimeSpecMapInnerMap<T>} */
|
609
|
+
(this._map).set(key, newValue);
|
564
610
|
}
|
565
611
|
}
|
566
612
|
}
|
@@ -572,7 +618,11 @@ class RuntimeSpecMap {
|
|
572
618
|
case 1:
|
573
619
|
return [this._singleRuntime];
|
574
620
|
default:
|
575
|
-
return Array.from(
|
621
|
+
return Array.from(
|
622
|
+
/** @type {RuntimeSpecMapInnerMap<T>} */
|
623
|
+
(this._map).keys(),
|
624
|
+
keyToRuntime
|
625
|
+
);
|
576
626
|
}
|
577
627
|
}
|
578
628
|
|
@@ -581,15 +631,15 @@ class RuntimeSpecMap {
|
|
581
631
|
case 0:
|
582
632
|
return [][Symbol.iterator]();
|
583
633
|
case 1:
|
584
|
-
return [this._singleValue][Symbol.iterator]();
|
634
|
+
return [/** @type {T} */ (this._singleValue)][Symbol.iterator]();
|
585
635
|
default:
|
586
|
-
return this._map.values();
|
636
|
+
return /** @type {Map<string, T>} */ (this._map).values();
|
587
637
|
}
|
588
638
|
}
|
589
639
|
|
590
640
|
get size() {
|
591
|
-
if (this._mode <= 1) return this._mode;
|
592
|
-
return this._map.size;
|
641
|
+
if (/** @type {number} */ (this._mode) <= 1) return this._mode;
|
642
|
+
return /** @type {Map<string, T>} */ (this._map).size;
|
593
643
|
}
|
594
644
|
}
|
595
645
|
|
package/lib/util/semver.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.88.
|
3
|
+
"version": "5.88.2",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
6
6
|
"license": "MIT",
|
@@ -1009,7 +1009,7 @@
|
|
1009
1009
|
{
|
1010
1010
|
"description": "The function is called on each dependency (`function(context, request, callback(err, result))`).",
|
1011
1011
|
"instanceof": "Function",
|
1012
|
-
"tsType": "(((data: ExternalItemFunctionData, callback: (err?: Error, result?: ExternalItemValue) => void) => void) | ((data: ExternalItemFunctionData) => Promise<ExternalItemValue>))"
|
1012
|
+
"tsType": "(((data: ExternalItemFunctionData, callback: (err?: (Error | null), result?: ExternalItemValue) => void) => void) | ((data: ExternalItemFunctionData) => Promise<ExternalItemValue>))"
|
1013
1013
|
}
|
1014
1014
|
]
|
1015
1015
|
},
|
package/types.d.ts
CHANGED
@@ -821,7 +821,7 @@ declare interface BuildInfo {
|
|
821
821
|
}
|
822
822
|
type BuildMeta = KnownBuildMeta & Record<string, any>;
|
823
823
|
declare abstract class ByTypeGenerator extends Generator {
|
824
|
-
map:
|
824
|
+
map: Record<string, Generator>;
|
825
825
|
}
|
826
826
|
declare const CIRCULAR_CONNECTION: unique symbol;
|
827
827
|
declare class Cache {
|
@@ -2233,7 +2233,7 @@ declare class Compiler {
|
|
2233
2233
|
parentCompilation?: Compilation;
|
2234
2234
|
root: Compiler;
|
2235
2235
|
outputPath: string;
|
2236
|
-
watching
|
2236
|
+
watching?: Watching;
|
2237
2237
|
outputFileSystem: OutputFileSystem;
|
2238
2238
|
intermediateFileSystem: IntermediateFileSystem;
|
2239
2239
|
inputFileSystem: InputFileSystem;
|
@@ -2243,11 +2243,14 @@ declare class Compiler {
|
|
2243
2243
|
records: object;
|
2244
2244
|
managedPaths: Set<string | RegExp>;
|
2245
2245
|
immutablePaths: Set<string | RegExp>;
|
2246
|
-
modifiedFiles
|
2247
|
-
removedFiles
|
2248
|
-
fileTimestamps
|
2249
|
-
contextTimestamps
|
2250
|
-
|
2246
|
+
modifiedFiles?: ReadonlySet<string>;
|
2247
|
+
removedFiles?: ReadonlySet<string>;
|
2248
|
+
fileTimestamps?: ReadonlyMap<string, null | FileSystemInfoEntry | "ignore">;
|
2249
|
+
contextTimestamps?: ReadonlyMap<
|
2250
|
+
string,
|
2251
|
+
null | FileSystemInfoEntry | "ignore"
|
2252
|
+
>;
|
2253
|
+
fsStartTime?: number;
|
2251
2254
|
resolverFactory: ResolverFactory;
|
2252
2255
|
infrastructureLogger: any;
|
2253
2256
|
options: WebpackOptionsNormalized;
|
@@ -2417,7 +2420,7 @@ declare interface Configuration {
|
|
2417
2420
|
| ((
|
2418
2421
|
data: ExternalItemFunctionData,
|
2419
2422
|
callback: (
|
2420
|
-
err?: Error,
|
2423
|
+
err?: null | Error,
|
2421
2424
|
result?: string | boolean | string[] | { [index: string]: any }
|
2422
2425
|
) => void
|
2423
2426
|
) => void)
|
@@ -2572,7 +2575,7 @@ declare interface Configuration {
|
|
2572
2575
|
/**
|
2573
2576
|
* Options affecting how file system snapshots are created and validated.
|
2574
2577
|
*/
|
2575
|
-
snapshot?:
|
2578
|
+
snapshot?: SnapshotOptionsWebpackOptions;
|
2576
2579
|
|
2577
2580
|
/**
|
2578
2581
|
* Stats options object or preset name.
|
@@ -3082,7 +3085,7 @@ declare interface DependencyTemplateContext {
|
|
3082
3085
|
codeGenerationResults: CodeGenerationResults;
|
3083
3086
|
}
|
3084
3087
|
declare abstract class DependencyTemplates {
|
3085
|
-
get(dependency: DependencyConstructor): DependencyTemplate;
|
3088
|
+
get(dependency: DependencyConstructor): undefined | DependencyTemplate;
|
3086
3089
|
set(
|
3087
3090
|
dependency: DependencyConstructor,
|
3088
3091
|
dependencyTemplate: DependencyTemplate
|
@@ -4177,7 +4180,7 @@ type ExternalItem =
|
|
4177
4180
|
| ((
|
4178
4181
|
data: ExternalItemFunctionData,
|
4179
4182
|
callback: (
|
4180
|
-
err?: Error,
|
4183
|
+
err?: null | Error,
|
4181
4184
|
result?: string | boolean | string[] | { [index: string]: any }
|
4182
4185
|
) => void
|
4183
4186
|
) => void)
|
@@ -4266,7 +4269,7 @@ type Externals =
|
|
4266
4269
|
| ((
|
4267
4270
|
data: ExternalItemFunctionData,
|
4268
4271
|
callback: (
|
4269
|
-
err?: Error,
|
4272
|
+
err?: null | Error,
|
4270
4273
|
result?: string | boolean | string[] | { [index: string]: any }
|
4271
4274
|
) => void
|
4272
4275
|
) => void)
|
@@ -4614,7 +4617,7 @@ declare abstract class FileSystemInfo {
|
|
4614
4617
|
): void;
|
4615
4618
|
getFileHash(
|
4616
4619
|
path: string,
|
4617
|
-
callback: (arg0?: null | WebpackError, arg1?: string) => void
|
4620
|
+
callback: (arg0?: null | WebpackError, arg1?: null | string) => void
|
4618
4621
|
): void;
|
4619
4622
|
getContextHash(
|
4620
4623
|
path: string,
|
@@ -4640,20 +4643,11 @@ declare abstract class FileSystemInfo {
|
|
4640
4643
|
callback: (arg0?: null | Error, arg1?: boolean) => void
|
4641
4644
|
): void;
|
4642
4645
|
createSnapshot(
|
4643
|
-
startTime: number,
|
4646
|
+
startTime: undefined | null | number,
|
4644
4647
|
files: Iterable<string>,
|
4645
4648
|
directories: Iterable<string>,
|
4646
4649
|
missing: Iterable<string>,
|
4647
|
-
options:
|
4648
|
-
/**
|
4649
|
-
* Use hashes of the content of the files/directories to determine invalidation.
|
4650
|
-
*/
|
4651
|
-
hash?: boolean;
|
4652
|
-
/**
|
4653
|
-
* Use timestamps of the files/directories to determine invalidation.
|
4654
|
-
*/
|
4655
|
-
timestamp?: boolean;
|
4656
|
-
},
|
4650
|
+
options: undefined | null | SnapshotOptionsFileSystemInfo,
|
4657
4651
|
callback: (arg0?: null | WebpackError, arg1?: null | Snapshot) => void
|
4658
4652
|
): void;
|
4659
4653
|
mergeSnapshots(snapshot1: Snapshot, snapshot2: Snapshot): Snapshot;
|
@@ -4734,7 +4728,7 @@ declare class Generator {
|
|
4734
4728
|
context: ConcatenationBailoutReasonContext
|
4735
4729
|
): undefined | string;
|
4736
4730
|
updateHash(hash: Hash, __1: UpdateHashContextGenerator): void;
|
4737
|
-
static byType(map
|
4731
|
+
static byType(map: Record<string, Generator>): ByTypeGenerator;
|
4738
4732
|
}
|
4739
4733
|
type GeneratorOptionsByModuleType = GeneratorOptionsByModuleTypeKnown &
|
4740
4734
|
GeneratorOptionsByModuleTypeUnknown;
|
@@ -11238,10 +11232,10 @@ declare class RuntimeSpecMap<T> {
|
|
11238
11232
|
constructor(clone?: RuntimeSpecMap<T>);
|
11239
11233
|
get(runtime: RuntimeSpec): undefined | T;
|
11240
11234
|
has(runtime: RuntimeSpec): boolean;
|
11241
|
-
set(runtime
|
11242
|
-
provide(runtime
|
11235
|
+
set(runtime: RuntimeSpec, value: T): void;
|
11236
|
+
provide(runtime: RuntimeSpec, computer: () => any): any;
|
11243
11237
|
delete(runtime: RuntimeSpec): void;
|
11244
|
-
update(runtime
|
11238
|
+
update(runtime: RuntimeSpec, fn: (arg0?: T) => T): void;
|
11245
11239
|
keys(): RuntimeSpec[];
|
11246
11240
|
values(): IterableIterator<T>;
|
11247
11241
|
get size(): number;
|
@@ -11864,11 +11858,22 @@ declare abstract class Snapshot {
|
|
11864
11858
|
getContextIterable(): Iterable<string>;
|
11865
11859
|
getMissingIterable(): Iterable<string>;
|
11866
11860
|
}
|
11861
|
+
declare interface SnapshotOptionsFileSystemInfo {
|
11862
|
+
/**
|
11863
|
+
* should use hash to snapshot
|
11864
|
+
*/
|
11865
|
+
hash?: boolean;
|
11866
|
+
|
11867
|
+
/**
|
11868
|
+
* should use timestamp to snapshot
|
11869
|
+
*/
|
11870
|
+
timestamp?: boolean;
|
11871
|
+
}
|
11867
11872
|
|
11868
11873
|
/**
|
11869
11874
|
* Options affecting how file system snapshots are created and validated.
|
11870
11875
|
*/
|
11871
|
-
declare interface
|
11876
|
+
declare interface SnapshotOptionsWebpackOptions {
|
11872
11877
|
/**
|
11873
11878
|
* Options for snapshotting build dependencies to determine if the whole cache need to be invalidated.
|
11874
11879
|
*/
|
@@ -13439,7 +13444,7 @@ declare interface WebpackOptionsNormalized {
|
|
13439
13444
|
/**
|
13440
13445
|
* Options affecting how file system snapshots are created and validated.
|
13441
13446
|
*/
|
13442
|
-
snapshot:
|
13447
|
+
snapshot: SnapshotOptionsWebpackOptions;
|
13443
13448
|
|
13444
13449
|
/**
|
13445
13450
|
* Stats options object or preset name.
|
@@ -13932,7 +13937,7 @@ declare namespace exports {
|
|
13932
13937
|
) => RuntimeSpec;
|
13933
13938
|
export let forEachRuntime: (
|
13934
13939
|
runtime: RuntimeSpec,
|
13935
|
-
fn: (arg0
|
13940
|
+
fn: (arg0?: string) => void,
|
13936
13941
|
deterministicOrder?: boolean
|
13937
13942
|
) => void;
|
13938
13943
|
export let getRuntimeKey: (runtime: RuntimeSpec) => string;
|