webpack 5.56.0 → 5.58.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.

@@ -8,41 +8,47 @@
8
8
  class StringXor {
9
9
  constructor() {
10
10
  this._value = undefined;
11
- this._buffer = undefined;
12
11
  }
13
12
 
13
+ /**
14
+ * @param {string} str string
15
+ * @returns {void}
16
+ */
14
17
  add(str) {
15
- let buf = this._buffer;
16
- let value;
17
- if (buf === undefined) {
18
- buf = this._buffer = Buffer.from(str, "latin1");
19
- this._value = Buffer.from(buf);
18
+ const len = str.length;
19
+ const value = this._value;
20
+ if (value === undefined) {
21
+ const newValue = (this._value = Buffer.allocUnsafe(len));
22
+ for (let i = 0; i < len; i++) {
23
+ newValue[i] = str.charCodeAt(i);
24
+ }
20
25
  return;
21
- } else if (buf.length !== str.length) {
22
- value = this._value;
23
- buf = this._buffer = Buffer.from(str, "latin1");
24
- if (value.length < buf.length) {
25
- this._value = Buffer.allocUnsafe(buf.length);
26
- value.copy(this._value);
27
- this._value.fill(0, value.length);
28
- value = this._value;
26
+ }
27
+ const valueLen = value.length;
28
+ if (valueLen < len) {
29
+ const newValue = (this._value = Buffer.allocUnsafe(len));
30
+ let i;
31
+ for (i = 0; i < valueLen; i++) {
32
+ newValue[i] = value[i] ^ str.charCodeAt(i);
33
+ }
34
+ for (; i < len; i++) {
35
+ newValue[i] = str.charCodeAt(i);
29
36
  }
30
37
  } else {
31
- value = this._value;
32
- buf.write(str, "latin1");
33
- }
34
- const len = buf.length;
35
- for (let i = 0; i < len; i++) {
36
- value[i] = value[i] ^ buf[i];
38
+ for (let i = 0; i < len; i++) {
39
+ value[i] = value[i] ^ str.charCodeAt(i);
40
+ }
37
41
  }
38
42
  }
39
43
 
40
44
  toString() {
41
- return this._value === undefined ? "" : this._value.toString("latin1");
45
+ const value = this._value;
46
+ return value === undefined ? "" : value.toString("latin1");
42
47
  }
43
48
 
44
49
  updateHash(hash) {
45
- if (this._value !== undefined) hash.update(this._value);
50
+ const value = this._value;
51
+ if (value !== undefined) hash.update(value);
46
52
  }
47
53
  }
48
54
 
@@ -5,6 +5,7 @@
5
5
  "use strict";
6
6
 
7
7
  const WebpackError = require("../WebpackError");
8
+ const { someInIterable } = require("../util/IterableHelpers");
8
9
 
9
10
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
10
11
  /** @typedef {import("../Module")} Module */
@@ -42,7 +43,11 @@ const getInitialModuleChains = (
42
43
  for (const connection of moduleGraph.getIncomingConnections(head)) {
43
44
  const newHead = connection.originModule;
44
45
  if (newHead) {
45
- if (!chunkGraph.getModuleChunks(newHead).some(c => c.canBeInitial()))
46
+ if (
47
+ !someInIterable(chunkGraph.getModuleChunksIterable(newHead), c =>
48
+ c.canBeInitial()
49
+ )
50
+ )
46
51
  continue;
47
52
  final = false;
48
53
  if (alreadyReferencedModules.has(newHead)) continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.56.0",
3
+ "version": "5.58.0",
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
@@ -335,7 +335,6 @@ declare class AsyncDependenciesBlock extends DependenciesBlock {
335
335
  };
336
336
  loc?: SyntheticDependencyLocation | RealDependencyLocation;
337
337
  request?: string;
338
- parent: DependenciesBlock;
339
338
  chunkName: string;
340
339
  module: any;
341
340
  }
@@ -758,6 +757,17 @@ declare class Chunk {
758
757
  filterFn?: (c: Chunk, chunkGraph: ChunkGraph) => boolean
759
758
  ): Record<string | number, Record<string, (string | number)[]>>;
760
759
  }
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
+ }
761
771
  declare class ChunkGraph {
762
772
  constructor(moduleGraph: ModuleGraph, hashFunction?: string | typeof Hash);
763
773
  moduleGraph: ModuleGraph;
@@ -775,6 +785,7 @@ declare class ChunkGraph {
775
785
  isModuleInChunk(module: Module, chunk: Chunk): boolean;
776
786
  isModuleInChunkGroup(module: Module, chunkGroup: ChunkGroup): boolean;
777
787
  isEntryModule(module: Module): boolean;
788
+ getModuleChunkCombination(module: Module): ChunkCombination;
778
789
  getModuleChunksIterable(module: Module): Iterable<Chunk>;
779
790
  getOrderedModuleChunksIterable(
780
791
  module: Module,
@@ -1460,7 +1471,8 @@ declare class Compilation {
1460
1471
  chunkTemplate: ChunkTemplate;
1461
1472
  runtimeTemplate: RuntimeTemplate;
1462
1473
  moduleTemplates: { javascript: ModuleTemplate };
1463
- moduleMemCaches?: WeakMap<Module, WeakTupleMap<any, any>>;
1474
+ moduleMemCaches?: Map<Module, WeakTupleMap<any, any>>;
1475
+ moduleMemCaches2?: Map<Module, WeakTupleMap<any, any>>;
1464
1476
  moduleGraph: ModuleGraph;
1465
1477
  chunkGraph: ChunkGraph;
1466
1478
  codeGenerationResults: CodeGenerationResults;
@@ -1645,6 +1657,7 @@ declare class Compilation {
1645
1657
  */
1646
1658
  addChunk(name?: string): Chunk;
1647
1659
  assignDepth(module: Module): void;
1660
+ assignDepths(modules: Set<Module>): void;
1648
1661
  getDependencyReferencedExports(
1649
1662
  dependency: Dependency,
1650
1663
  runtime: RuntimeSpec
@@ -1907,10 +1920,10 @@ declare class Compiler {
1907
1920
  context: string;
1908
1921
  requestShortener: RequestShortener;
1909
1922
  cache: Cache;
1910
- moduleMemCaches?: WeakMap<
1923
+ moduleMemCaches?: Map<
1911
1924
  Module,
1912
1925
  {
1913
- hash: string;
1926
+ buildInfo: object;
1914
1927
  references: WeakMap<Dependency, Module>;
1915
1928
  memCache: WeakTupleMap<any, any>;
1916
1929
  }
@@ -2543,6 +2556,8 @@ declare interface DepConstructor {
2543
2556
  declare abstract class DependenciesBlock {
2544
2557
  dependencies: Dependency[];
2545
2558
  blocks: AsyncDependenciesBlock[];
2559
+ parent: DependenciesBlock;
2560
+ getRootBlock(): DependenciesBlock;
2546
2561
 
2547
2562
  /**
2548
2563
  * Adds a DependencyBlock to DependencyBlock relationship.
@@ -3741,6 +3756,10 @@ declare class ExternalModule extends Module {
3741
3756
  request: string | string[] | Record<string, string | string[]>;
3742
3757
  externalType: string;
3743
3758
  userRequest: string;
3759
+ restoreFromUnsafeCache(
3760
+ unsafeCacheData?: any,
3761
+ normalModuleFactory?: any
3762
+ ): void;
3744
3763
  }
3745
3764
  declare interface ExternalModuleInfo {
3746
3765
  index: number;
@@ -6495,6 +6514,7 @@ declare class Module extends DependenciesBlock {
6495
6514
  getSideEffectsConnectionState(moduleGraph: ModuleGraph): ConnectionState;
6496
6515
  codeGeneration(context: CodeGenerationContext): CodeGenerationResult;
6497
6516
  chunkCondition(chunk: Chunk, compilation: Compilation): boolean;
6517
+ hasChunkCondition(): boolean;
6498
6518
 
6499
6519
  /**
6500
6520
  * Assuming this module is in the cache. Update the (cached) module with
@@ -6664,10 +6684,12 @@ declare class ModuleGraph {
6664
6684
  setParents(
6665
6685
  dependency: Dependency,
6666
6686
  block: DependenciesBlock,
6667
- module: Module
6687
+ module: Module,
6688
+ indexInBlock?: number
6668
6689
  ): void;
6669
6690
  getParentModule(dependency: Dependency): Module;
6670
6691
  getParentBlock(dependency: Dependency): DependenciesBlock;
6692
+ getParentBlockIndex(dependency: Dependency): number;
6671
6693
  setResolvedModule(
6672
6694
  originModule: Module,
6673
6695
  dependency: Dependency,
@@ -6699,7 +6721,10 @@ declare class ModuleGraph {
6699
6721
  getOutgoingConnections(module: Module): Iterable<ModuleGraphConnection>;
6700
6722
  getIncomingConnectionsByOriginModule(
6701
6723
  module: Module
6702
- ): Map<Module, ReadonlyArray<ModuleGraphConnection>>;
6724
+ ): Map<undefined | Module, ReadonlyArray<ModuleGraphConnection>>;
6725
+ getOutgoingConnectionsByModule(
6726
+ module: Module
6727
+ ): undefined | Map<undefined | Module, ReadonlyArray<ModuleGraphConnection>>;
6703
6728
  getProfile(module: Module): null | ModuleProfile;
6704
6729
  setProfile(module: Module, profile: null | ModuleProfile): void;
6705
6730
  getIssuer(module: Module): null | Module;
@@ -6740,7 +6765,7 @@ declare class ModuleGraph {
6740
6765
  ...args: T
6741
6766
  ): V;
6742
6767
  setModuleMemCaches(
6743
- moduleMemCaches: WeakMap<Module, WeakTupleMap<any, any>>
6768
+ moduleMemCaches: Map<Module, WeakTupleMap<any, any>>
6744
6769
  ): void;
6745
6770
  dependencyCacheProvide(dependency: Dependency, ...args: any[]): any;
6746
6771
  static getModuleGraphForModule(
@@ -7373,6 +7398,7 @@ declare interface NormalModuleCompilationHooks {
7373
7398
  readResourceForScheme: HookMap<
7374
7399
  AsyncSeriesBailHook<[string, NormalModule], string | Buffer>
7375
7400
  >;
7401
+ readResource: HookMap<AsyncSeriesBailHook<[object], string | Buffer>>;
7376
7402
  needBuild: AsyncSeriesBailHook<[NormalModule, NeedBuildContext], boolean>;
7377
7403
  }
7378
7404
  declare abstract class NormalModuleFactory extends ModuleFactory {