webpack 5.54.0 → 5.56.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.

@@ -7,87 +7,20 @@
7
7
 
8
8
  const isWeakKey = thing => typeof thing === "object" && thing !== null;
9
9
 
10
- class WeakTupleNode {
11
- constructor() {
12
- this.f = 0;
13
- /** @type {any} */
14
- this.v = undefined;
15
- /** @type {Map<object, WeakTupleNode> | undefined} */
16
- this.m = undefined;
17
- /** @type {WeakMap<object, WeakTupleNode> | undefined} */
18
- this.w = undefined;
19
- }
20
-
21
- getValue() {
22
- return this.v;
23
- }
24
-
25
- hasValue() {
26
- return (this.f & 1) === 1;
27
- }
28
-
29
- setValue(v) {
30
- this.f |= 1;
31
- this.v = v;
32
- }
33
-
34
- deleteValue() {
35
- this.f &= 6;
36
- this.v = undefined;
37
- }
38
-
39
- peek(thing) {
40
- if (isWeakKey(thing)) {
41
- if ((this.f & 4) !== 4) return undefined;
42
- return this.w.get(thing);
43
- } else {
44
- if ((this.f & 2) !== 2) return undefined;
45
- return this.m.get(thing);
46
- }
47
- }
48
-
49
- get(thing) {
50
- if (isWeakKey(thing)) {
51
- if ((this.f & 4) !== 4) {
52
- const newMap = new WeakMap();
53
- this.f |= 4;
54
- const newNode = new WeakTupleNode();
55
- (this.w = newMap).set(thing, newNode);
56
- return newNode;
57
- }
58
- const entry = this.w.get(thing);
59
- if (entry !== undefined) {
60
- return entry;
61
- }
62
- const newNode = new WeakTupleNode();
63
- this.w.set(thing, newNode);
64
- return newNode;
65
- } else {
66
- if ((this.f & 2) !== 2) {
67
- const newMap = new Map();
68
- this.f |= 2;
69
- const newNode = new WeakTupleNode();
70
- (this.m = newMap).set(thing, newNode);
71
- return newNode;
72
- }
73
- const entry = this.m.get(thing);
74
- if (entry !== undefined) {
75
- return entry;
76
- }
77
- const newNode = new WeakTupleNode();
78
- this.m.set(thing, newNode);
79
- return newNode;
80
- }
81
- }
82
- }
83
-
84
10
  /**
85
11
  * @template {any[]} T
86
12
  * @template V
87
13
  */
88
14
  class WeakTupleMap {
89
15
  constructor() {
90
- this._node = new WeakTupleNode();
16
+ /** @private */
17
+ this.f = 0;
18
+ /** @private @type {any} */
19
+ this.v = undefined;
20
+ /** @private @type {Map<object, WeakTupleMap<T, V>> | undefined} */
21
+ this.m = undefined;
22
+ /** @private @type {WeakMap<object, WeakTupleMap<T, V>> | undefined} */
23
+ this.w = undefined;
91
24
  }
92
25
 
93
26
  /**
@@ -95,11 +28,12 @@ class WeakTupleMap {
95
28
  * @returns {void}
96
29
  */
97
30
  set(...args) {
98
- let node = this._node;
31
+ /** @type {WeakTupleMap<T, V>} */
32
+ let node = this;
99
33
  for (let i = 0; i < args.length - 1; i++) {
100
- node = node.get(args[i]);
34
+ node = node._get(args[i]);
101
35
  }
102
- node.setValue(args[args.length - 1]);
36
+ node._setValue(args[args.length - 1]);
103
37
  }
104
38
 
105
39
  /**
@@ -107,12 +41,13 @@ class WeakTupleMap {
107
41
  * @returns {boolean} true, if the tuple is in the Set
108
42
  */
109
43
  has(...args) {
110
- let node = this._node;
44
+ /** @type {WeakTupleMap<T, V>} */
45
+ let node = this;
111
46
  for (let i = 0; i < args.length; i++) {
112
- node = node.peek(args[i]);
47
+ node = node._peek(args[i]);
113
48
  if (node === undefined) return false;
114
49
  }
115
- return node.hasValue();
50
+ return node._hasValue();
116
51
  }
117
52
 
118
53
  /**
@@ -120,12 +55,13 @@ class WeakTupleMap {
120
55
  * @returns {V} the value
121
56
  */
122
57
  get(...args) {
123
- let node = this._node;
58
+ /** @type {WeakTupleMap<T, V>} */
59
+ let node = this;
124
60
  for (let i = 0; i < args.length; i++) {
125
- node = node.peek(args[i]);
61
+ node = node._peek(args[i]);
126
62
  if (node === undefined) return undefined;
127
63
  }
128
- return node.getValue();
64
+ return node._getValue();
129
65
  }
130
66
 
131
67
  /**
@@ -133,14 +69,15 @@ class WeakTupleMap {
133
69
  * @returns {V} the value
134
70
  */
135
71
  provide(...args) {
136
- let node = this._node;
72
+ /** @type {WeakTupleMap<T, V>} */
73
+ let node = this;
137
74
  for (let i = 0; i < args.length - 1; i++) {
138
- node = node.get(args[i]);
75
+ node = node._get(args[i]);
139
76
  }
140
- if (node.hasValue()) return node.getValue();
77
+ if (node._hasValue()) return node._getValue();
141
78
  const fn = args[args.length - 1];
142
79
  const newValue = fn(...args.slice(0, -1));
143
- node.setValue(newValue);
80
+ node._setValue(newValue);
144
81
  return newValue;
145
82
  }
146
83
 
@@ -149,19 +86,85 @@ class WeakTupleMap {
149
86
  * @returns {void}
150
87
  */
151
88
  delete(...args) {
152
- let node = this._node;
89
+ /** @type {WeakTupleMap<T, V>} */
90
+ let node = this;
153
91
  for (let i = 0; i < args.length; i++) {
154
- node = node.peek(args[i]);
92
+ node = node._peek(args[i]);
155
93
  if (node === undefined) return;
156
94
  }
157
- node.deleteValue();
95
+ node._deleteValue();
158
96
  }
159
97
 
160
98
  /**
161
99
  * @returns {void}
162
100
  */
163
101
  clear() {
164
- this._node = new WeakTupleNode();
102
+ this.f = 0;
103
+ this.v = undefined;
104
+ this.w = undefined;
105
+ this.m = undefined;
106
+ }
107
+
108
+ _getValue() {
109
+ return this.v;
110
+ }
111
+
112
+ _hasValue() {
113
+ return (this.f & 1) === 1;
114
+ }
115
+
116
+ _setValue(v) {
117
+ this.f |= 1;
118
+ this.v = v;
119
+ }
120
+
121
+ _deleteValue() {
122
+ this.f &= 6;
123
+ this.v = undefined;
124
+ }
125
+
126
+ _peek(thing) {
127
+ if (isWeakKey(thing)) {
128
+ if ((this.f & 4) !== 4) return undefined;
129
+ return this.w.get(thing);
130
+ } else {
131
+ if ((this.f & 2) !== 2) return undefined;
132
+ return this.m.get(thing);
133
+ }
134
+ }
135
+
136
+ _get(thing) {
137
+ if (isWeakKey(thing)) {
138
+ if ((this.f & 4) !== 4) {
139
+ const newMap = new WeakMap();
140
+ this.f |= 4;
141
+ const newNode = new WeakTupleMap();
142
+ (this.w = newMap).set(thing, newNode);
143
+ return newNode;
144
+ }
145
+ const entry = this.w.get(thing);
146
+ if (entry !== undefined) {
147
+ return entry;
148
+ }
149
+ const newNode = new WeakTupleMap();
150
+ this.w.set(thing, newNode);
151
+ return newNode;
152
+ } else {
153
+ if ((this.f & 2) !== 2) {
154
+ const newMap = new Map();
155
+ this.f |= 2;
156
+ const newNode = new WeakTupleMap();
157
+ (this.m = newMap).set(thing, newNode);
158
+ return newNode;
159
+ }
160
+ const entry = this.m.get(thing);
161
+ if (entry !== undefined) {
162
+ return entry;
163
+ }
164
+ const newNode = new WeakTupleMap();
165
+ this.m.set(thing, newNode);
166
+ return newNode;
167
+ }
165
168
  }
166
169
  }
167
170
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.54.0",
3
+ "version": "5.56.1",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",
package/types.d.ts CHANGED
@@ -1299,7 +1299,7 @@ declare class Compilation {
1299
1299
  /**
1300
1300
  * Creates an instance of Compilation.
1301
1301
  */
1302
- constructor(compiler: Compiler);
1302
+ constructor(compiler: Compiler, params: CompilationParams);
1303
1303
  hooks: Readonly<{
1304
1304
  buildModule: SyncHook<[Module]>;
1305
1305
  rebuildModule: SyncHook<[Module]>;
@@ -1455,18 +1455,22 @@ declare class Compilation {
1455
1455
  outputOptions: OutputNormalized;
1456
1456
  bail: boolean;
1457
1457
  profile: boolean;
1458
+ params: CompilationParams;
1458
1459
  mainTemplate: MainTemplate;
1459
1460
  chunkTemplate: ChunkTemplate;
1460
1461
  runtimeTemplate: RuntimeTemplate;
1461
1462
  moduleTemplates: { javascript: ModuleTemplate };
1462
- memCache?: MemCache;
1463
- moduleMemCaches?: WeakMap<Module, MemCache>;
1463
+ moduleMemCaches?: WeakMap<Module, WeakTupleMap<any, any>>;
1464
1464
  moduleGraph: ModuleGraph;
1465
1465
  chunkGraph: ChunkGraph;
1466
1466
  codeGenerationResults: CodeGenerationResults;
1467
1467
  processDependenciesQueue: AsyncQueue<Module, Module, Module>;
1468
1468
  addModuleQueue: AsyncQueue<Module, string, Module>;
1469
- factorizeQueue: AsyncQueue<FactorizeModuleOptions, string, Module>;
1469
+ factorizeQueue: AsyncQueue<
1470
+ FactorizeModuleOptions,
1471
+ string,
1472
+ Module | ModuleFactoryResult
1473
+ >;
1470
1474
  buildQueue: AsyncQueue<Module, Module, Module>;
1471
1475
  rebuildQueue: AsyncQueue<Module, Module, Module>;
1472
1476
 
@@ -1549,10 +1553,6 @@ declare class Compilation {
1549
1553
  __0: HandleModuleCreationOptions,
1550
1554
  callback: (err?: WebpackError, result?: Module) => void
1551
1555
  ): void;
1552
- factorizeModule(
1553
- options: FactorizeModuleOptions,
1554
- callback: (err?: WebpackError, result?: Module) => void
1555
- ): void;
1556
1556
  addModuleChain(
1557
1557
  context: string,
1558
1558
  dependency: Dependency,
@@ -1719,6 +1719,16 @@ declare class Compilation {
1719
1719
  callback: (err?: WebpackError, result?: ExecuteModuleResult) => void
1720
1720
  ): void;
1721
1721
  checkConstraints(): void;
1722
+ factorizeModule: {
1723
+ (
1724
+ options: FactorizeModuleOptions & { factoryResult?: false },
1725
+ callback: (err?: WebpackError, result?: Module) => void
1726
+ ): void;
1727
+ (
1728
+ options: FactorizeModuleOptions & { factoryResult: true },
1729
+ callback: (err?: WebpackError, result?: ModuleFactoryResult) => void
1730
+ ): void;
1731
+ };
1722
1732
 
1723
1733
  /**
1724
1734
  * Add additional assets to the compilation.
@@ -1897,7 +1907,14 @@ declare class Compiler {
1897
1907
  context: string;
1898
1908
  requestShortener: RequestShortener;
1899
1909
  cache: Cache;
1900
- moduleMemCaches?: WeakMap<Module, { hash: string; memCache: MemCache }>;
1910
+ moduleMemCaches?: WeakMap<
1911
+ Module,
1912
+ {
1913
+ hash: string;
1914
+ references: WeakMap<Dependency, Module>;
1915
+ memCache: WeakTupleMap<any, any>;
1916
+ }
1917
+ >;
1901
1918
  compilerPath: string;
1902
1919
  running: boolean;
1903
1920
  idle: boolean;
@@ -1921,7 +1938,7 @@ declare class Compiler {
1921
1938
  plugins?: WebpackPluginInstance[]
1922
1939
  ): Compiler;
1923
1940
  isChild(): boolean;
1924
- createCompilation(): Compilation;
1941
+ createCompilation(params?: any): Compilation;
1925
1942
  newCompilation(params: CompilationParams): Compilation;
1926
1943
  createNormalModuleFactory(): NormalModuleFactory;
1927
1944
  createContextModuleFactory(): ContextModuleFactory;
@@ -2241,6 +2258,7 @@ declare class ConstDependency extends NullDependency {
2241
2258
  static Template: typeof ConstDependencyTemplate;
2242
2259
  static NO_EXPORTS_REFERENCED: string[][];
2243
2260
  static EXPORTS_OBJECT_REFERENCED: string[][];
2261
+ static TRANSITIVE: typeof TRANSITIVE;
2244
2262
  }
2245
2263
  declare class ConstDependencyTemplate extends NullDependencyTemplate {
2246
2264
  constructor();
@@ -2554,6 +2572,7 @@ declare class Dependency {
2554
2572
  readonly category: string;
2555
2573
  loc: DependencyLocation;
2556
2574
  getResourceIdentifier(): null | string;
2575
+ couldAffectReferencingModule(): boolean | typeof TRANSITIVE;
2557
2576
 
2558
2577
  /**
2559
2578
  * Returns the referenced module and export
@@ -2608,6 +2627,7 @@ declare class Dependency {
2608
2627
  readonly disconnect: any;
2609
2628
  static NO_EXPORTS_REFERENCED: string[][];
2610
2629
  static EXPORTS_OBJECT_REFERENCED: string[][];
2630
+ static TRANSITIVE: typeof TRANSITIVE;
2611
2631
  }
2612
2632
  declare interface DependencyConstructor {
2613
2633
  new (...args: any[]): Dependency;
@@ -3819,6 +3839,11 @@ declare interface FactorizeModuleOptions {
3819
3839
  currentProfile: ModuleProfile;
3820
3840
  factory: ModuleFactory;
3821
3841
  dependencies: Dependency[];
3842
+
3843
+ /**
3844
+ * return full ModuleFactoryResult instead of only module
3845
+ */
3846
+ factoryResult?: boolean;
3822
3847
  originModule: null | Module;
3823
3848
  contextInfo?: Partial<ModuleFactoryCreateDataContextInfo>;
3824
3849
  context?: string;
@@ -6313,11 +6338,6 @@ declare interface MapOptions {
6313
6338
  columns?: boolean;
6314
6339
  module?: boolean;
6315
6340
  }
6316
- declare abstract class MemCache {
6317
- get<T extends any[], V>(...args: T): undefined | V;
6318
- set<T extends [any, ...any[]]>(...args: T): void;
6319
- provide<T extends [any, ...((...args: any[]) => V)[]], V>(...args: T): V;
6320
- }
6321
6341
 
6322
6342
  /**
6323
6343
  * Options object for in-memory caching.
@@ -6524,6 +6544,7 @@ declare class ModuleDependency extends Dependency {
6524
6544
  static Template: typeof DependencyTemplate;
6525
6545
  static NO_EXPORTS_REFERENCED: string[][];
6526
6546
  static EXPORTS_OBJECT_REFERENCED: string[][];
6547
+ static TRANSITIVE: typeof TRANSITIVE;
6527
6548
  }
6528
6549
  declare abstract class ModuleFactory {
6529
6550
  create(
@@ -6550,6 +6571,11 @@ declare interface ModuleFactoryResult {
6550
6571
  fileDependencies?: Set<string>;
6551
6572
  contextDependencies?: Set<string>;
6552
6573
  missingDependencies?: Set<string>;
6574
+
6575
+ /**
6576
+ * allow to use the unsafe cache
6577
+ */
6578
+ cacheable?: boolean;
6553
6579
  }
6554
6580
  declare class ModuleFederationPlugin {
6555
6581
  constructor(options: ModuleFederationPluginOptions);
@@ -6707,12 +6733,16 @@ declare class ModuleGraph {
6707
6733
  setAsync(module: Module): void;
6708
6734
  getMeta(thing?: any): Object;
6709
6735
  getMetaIfExisting(thing?: any): Object;
6710
- freeze(): void;
6736
+ freeze(cacheStage?: string): void;
6711
6737
  unfreeze(): void;
6712
6738
  cached<T extends any[], V>(
6713
6739
  fn: (moduleGraph: ModuleGraph, ...args: T) => V,
6714
6740
  ...args: T
6715
6741
  ): V;
6742
+ setModuleMemCaches(
6743
+ moduleMemCaches: WeakMap<Module, WeakTupleMap<any, any>>
6744
+ ): void;
6745
+ dependencyCacheProvide(dependency: Dependency, ...args: any[]): any;
6716
6746
  static getModuleGraphForModule(
6717
6747
  module: Module,
6718
6748
  deprecateMessage: string,
@@ -7366,8 +7396,6 @@ declare abstract class NormalModuleFactory extends ModuleFactory {
7366
7396
  }>;
7367
7397
  resolverFactory: ResolverFactory;
7368
7398
  ruleSet: RuleSet;
7369
- unsafeCache: boolean;
7370
- cachePredicate: Function;
7371
7399
  context: string;
7372
7400
  fs: InputFileSystem;
7373
7401
  parserCache: Map<string, WeakMap<Object, any>>;
@@ -7511,6 +7539,7 @@ declare class NullDependency extends Dependency {
7511
7539
  static Template: typeof NullDependencyTemplate;
7512
7540
  static NO_EXPORTS_REFERENCED: string[][];
7513
7541
  static EXPORTS_OBJECT_REFERENCED: string[][];
7542
+ static TRANSITIVE: typeof TRANSITIVE;
7514
7543
  }
7515
7544
  declare class NullDependencyTemplate extends DependencyTemplate {
7516
7545
  constructor();
@@ -11283,6 +11312,7 @@ declare interface SyntheticDependencyLocation {
11283
11312
  index?: number;
11284
11313
  }
11285
11314
  declare const TOMBSTONE: unique symbol;
11315
+ declare const TRANSITIVE: unique symbol;
11286
11316
  declare const TRANSITIVE_ONLY: unique symbol;
11287
11317
  declare interface TagInfo {
11288
11318
  tag: any;
@@ -11647,6 +11677,14 @@ declare abstract class Watching {
11647
11677
  resume(): void;
11648
11678
  close(callback: CallbackFunction<void>): void;
11649
11679
  }
11680
+ declare abstract class WeakTupleMap<T extends any[], V> {
11681
+ set(...args: [T, ...V[]]): void;
11682
+ has(...args: T): boolean;
11683
+ get(...args: T): V;
11684
+ provide(...args: [T, ...(() => V)[]]): V;
11685
+ delete(...args: T): void;
11686
+ clear(): void;
11687
+ }
11650
11688
  declare interface WebAssemblyRenderContext {
11651
11689
  /**
11652
11690
  * the chunk
package/lib/MemCache.js DELETED
@@ -1,45 +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 WeakTupleMap = require("./util/WeakTupleMap");
9
-
10
- class MemCache {
11
- constructor() {
12
- this._cache = new WeakTupleMap();
13
- }
14
-
15
- /**
16
- * @template {any[]} T
17
- * @template V
18
- * @param {T} args arguments
19
- * @returns {V | undefined} cached value
20
- */
21
- get(...args) {
22
- return this._cache.get(...args);
23
- }
24
-
25
- /**
26
- * @template {[...any[], any]} T
27
- * @param {T} args arguments
28
- * @returns {void}
29
- */
30
- set(...args) {
31
- this._cache.set(...args);
32
- }
33
-
34
- /**
35
- * @template {[...any[], (...args: any[]) => V]} T
36
- * @template V
37
- * @param {T} args arguments
38
- * @returns {V} computed value or cached
39
- */
40
- provide(...args) {
41
- return this._cache.provide(...args);
42
- }
43
- }
44
-
45
- module.exports = MemCache;