webpack 5.53.0 → 5.54.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.

Files changed (51) hide show
  1. package/lib/AsyncDependenciesBlock.js +9 -2
  2. package/lib/CacheFacade.js +10 -3
  3. package/lib/ChunkGraph.js +19 -8
  4. package/lib/CodeGenerationResults.js +7 -2
  5. package/lib/Compilation.js +207 -16
  6. package/lib/Compiler.js +9 -1
  7. package/lib/DependencyTemplates.js +8 -2
  8. package/lib/EvalDevToolModulePlugin.js +2 -1
  9. package/lib/EvalSourceMapDevToolPlugin.js +2 -1
  10. package/lib/ExternalModule.js +18 -9
  11. package/lib/FileSystemInfo.js +101 -170
  12. package/lib/FlagDependencyExportsPlugin.js +43 -16
  13. package/lib/JavascriptMetaInfoPlugin.js +6 -1
  14. package/lib/MemCache.js +45 -0
  15. package/lib/ModuleFilenameHelpers.js +21 -7
  16. package/lib/SourceMapDevToolPlugin.js +7 -3
  17. package/lib/WebpackOptionsApply.js +19 -1
  18. package/lib/cache/PackFileCacheStrategy.js +2 -1
  19. package/lib/cache/getLazyHashedEtag.js +35 -8
  20. package/lib/config/defaults.js +18 -7
  21. package/lib/dependencies/CachedConstDependency.js +4 -3
  22. package/lib/dependencies/ConstDependency.js +12 -4
  23. package/lib/dependencies/JsonExportsDependency.js +7 -1
  24. package/lib/dependencies/ModuleDecoratorDependency.js +5 -2
  25. package/lib/dependencies/ProvidedDependency.js +6 -2
  26. package/lib/dependencies/PureExpressionDependency.js +5 -1
  27. package/lib/dependencies/RuntimeRequirementsDependency.js +5 -1
  28. package/lib/ids/IdHelpers.js +21 -8
  29. package/lib/ids/NamedChunkIdsPlugin.js +3 -0
  30. package/lib/ids/NamedModuleIdsPlugin.js +3 -1
  31. package/lib/index.js +6 -0
  32. package/lib/javascript/BasicEvaluatedExpression.js +3 -0
  33. package/lib/javascript/JavascriptParser.js +22 -4
  34. package/lib/javascript/JavascriptParserHelpers.js +0 -2
  35. package/lib/optimize/ConcatenatedModule.js +25 -4
  36. package/lib/optimize/InnerGraph.js +22 -2
  37. package/lib/optimize/ModuleConcatenationPlugin.js +2 -1
  38. package/lib/schemes/HttpUriPlugin.js +1 -2
  39. package/lib/serialization/BinaryMiddleware.js +11 -2
  40. package/lib/serialization/FileMiddleware.js +24 -7
  41. package/lib/serialization/ObjectMiddleware.js +19 -8
  42. package/lib/util/createHash.js +10 -0
  43. package/lib/util/hash/BatchedHash.js +65 -0
  44. package/lib/util/hash/xxhash64.js +154 -0
  45. package/lib/util/serialization.js +4 -4
  46. package/package.json +10 -6
  47. package/schemas/WebpackOptions.check.js +1 -1
  48. package/schemas/WebpackOptions.json +12 -0
  49. package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
  50. package/schemas/plugins/HashedModuleIdsPlugin.json +20 -2
  51. package/types.d.ts +157 -10
@@ -699,6 +699,10 @@
699
699
  }
700
700
  ]
701
701
  },
702
+ "cacheUnaffected": {
703
+ "description": "Enable additional in memory caching of modules that are unchanged and reference only unchanged modules.",
704
+ "type": "boolean"
705
+ },
702
706
  "futureDefaults": {
703
707
  "description": "Apply defaults of next major version.",
704
708
  "type": "boolean"
@@ -1027,6 +1031,10 @@
1027
1031
  "type": "number",
1028
1032
  "minimum": 0
1029
1033
  },
1034
+ "memoryCacheUnaffected": {
1035
+ "description": "Additionally cache computation of modules that are unchanged and reference only unchanged modules in memory.",
1036
+ "type": "boolean"
1037
+ },
1030
1038
  "name": {
1031
1039
  "description": "Name for the cache. Different names will lead to different coexisting caches.",
1032
1040
  "type": "string"
@@ -1655,6 +1663,10 @@
1655
1663
  "type": "object",
1656
1664
  "additionalProperties": false,
1657
1665
  "properties": {
1666
+ "cacheUnaffected": {
1667
+ "description": "Additionally cache computation of modules that are unchanged and reference only unchanged modules.",
1668
+ "type": "boolean"
1669
+ },
1658
1670
  "maxGenerations": {
1659
1671
  "description": "Number of generations unused cache entries stay in memory cache at minimum (1 = may be removed after unused for a single compilation, ..., Infinity: kept forever).",
1660
1672
  "type": "number",
@@ -3,4 +3,4 @@
3
3
  * DO NOT MODIFY BY HAND.
4
4
  * Run `yarn special-lint-fix` to update
5
5
  */
6
- const r=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;function t(e,{instancePath:s="",parentData:i,parentDataProperty:n,rootData:a=e}={}){if(!e||"object"!=typeof e||Array.isArray(e))return t.errors=[{params:{type:"object"}}],!1;{const s=0;for(const r in e)if("context"!==r&&"hashDigest"!==r&&"hashDigestLength"!==r&&"hashFunction"!==r)return t.errors=[{params:{additionalProperty:r}}],!1;if(0===s){if(void 0!==e.context){let s=e.context;const i=0;if(0===i){if("string"!=typeof s)return t.errors=[{params:{type:"string"}}],!1;if(s.includes("!")||!0!==r.test(s))return t.errors=[{params:{}}],!1}var o=0===i}else o=!0;if(o){if(void 0!==e.hashDigest){let r=e.hashDigest;const s=0;if("hex"!==r&&"latin1"!==r&&"base64"!==r)return t.errors=[{params:{}}],!1;o=0===s}else o=!0;if(o){if(void 0!==e.hashDigestLength){let r=e.hashDigestLength;const s=0;if(0===s){if("number"!=typeof r||!isFinite(r))return t.errors=[{params:{type:"number"}}],!1;if(r<1||isNaN(r))return t.errors=[{params:{comparison:">=",limit:1}}],!1}o=0===s}else o=!0;if(o)if(void 0!==e.hashFunction){let r=e.hashFunction;const s=0;if(0===s){if("string"!=typeof r)return t.errors=[{params:{type:"string"}}],!1;if(r.length<1)return t.errors=[{params:{}}],!1}o=0===s}else o=!0}}}}return t.errors=null,!0}module.exports=t,module.exports.default=t;
6
+ const t=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;function e(r,{instancePath:s="",parentData:n,parentDataProperty:i,rootData:a=r}={}){let o=null,l=0;if(0===l){if(!r||"object"!=typeof r||Array.isArray(r))return e.errors=[{params:{type:"object"}}],!1;{const s=l;for(const t in r)if("context"!==t&&"hashDigest"!==t&&"hashDigestLength"!==t&&"hashFunction"!==t)return e.errors=[{params:{additionalProperty:t}}],!1;if(s===l){if(void 0!==r.context){let s=r.context;const n=l;if(l===n){if("string"!=typeof s)return e.errors=[{params:{type:"string"}}],!1;if(s.includes("!")||!0!==t.test(s))return e.errors=[{params:{}}],!1}var u=n===l}else u=!0;if(u){if(void 0!==r.hashDigest){let t=r.hashDigest;const s=l;if("hex"!==t&&"latin1"!==t&&"base64"!==t)return e.errors=[{params:{}}],!1;u=s===l}else u=!0;if(u){if(void 0!==r.hashDigestLength){let t=r.hashDigestLength;const s=l;if(l===s){if("number"!=typeof t||!isFinite(t))return e.errors=[{params:{type:"number"}}],!1;if(t<1||isNaN(t))return e.errors=[{params:{comparison:">=",limit:1}}],!1}u=s===l}else u=!0;if(u)if(void 0!==r.hashFunction){let t=r.hashFunction;const s=l,n=l;let i=!1,a=null;const p=l,h=l;let c=!1;const m=l;if(l===m)if("string"==typeof t){if(t.length<1){const t={params:{}};null===o?o=[t]:o.push(t),l++}}else{const t={params:{type:"string"}};null===o?o=[t]:o.push(t),l++}var f=m===l;if(c=c||f,!c){const e=l;if(!(t instanceof Function)){const t={params:{}};null===o?o=[t]:o.push(t),l++}f=e===l,c=c||f}if(c)l=h,null!==o&&(h?o.length=h:o=null);else{const t={params:{}};null===o?o=[t]:o.push(t),l++}if(p===l&&(i=!0,a=0),!i){const t={params:{passingSchemas:a}};return null===o?o=[t]:o.push(t),l++,e.errors=o,!1}l=n,null!==o&&(n?o.length=n:o=null),u=s===l}else u=!0}}}}}return e.errors=o,0===l}module.exports=e,module.exports.default=e;
@@ -1,4 +1,19 @@
1
1
  {
2
+ "definitions": {
3
+ "HashFunction": {
4
+ "description": "Algorithm used for generation the hash (see node.js crypto package).",
5
+ "anyOf": [
6
+ {
7
+ "type": "string",
8
+ "minLength": 1
9
+ },
10
+ {
11
+ "instanceof": "Function",
12
+ "tsType": "typeof import('../../lib/util/Hash')"
13
+ }
14
+ ]
15
+ }
16
+ },
2
17
  "title": "HashedModuleIdsPluginOptions",
3
18
  "type": "object",
4
19
  "additionalProperties": false,
@@ -19,8 +34,11 @@
19
34
  },
20
35
  "hashFunction": {
21
36
  "description": "The hashing algorithm to use, defaults to 'md4'. All functions from Node.JS' crypto.createHash are supported.",
22
- "type": "string",
23
- "minLength": 1
37
+ "oneOf": [
38
+ {
39
+ "$ref": "#/definitions/HashFunction"
40
+ }
41
+ ]
24
42
  }
25
43
  }
26
44
  }
package/types.d.ts CHANGED
@@ -759,7 +759,7 @@ declare class Chunk {
759
759
  ): Record<string | number, Record<string, (string | number)[]>>;
760
760
  }
761
761
  declare class ChunkGraph {
762
- constructor(moduleGraph: ModuleGraph);
762
+ constructor(moduleGraph: ModuleGraph, hashFunction?: string | typeof Hash);
763
763
  moduleGraph: ModuleGraph;
764
764
  connectChunkAndModule(chunk: Chunk, module: Module): void;
765
765
  disconnectChunkAndModule(chunk: Chunk, module: Module): void;
@@ -891,7 +891,8 @@ declare class ChunkGraph {
891
891
  addModuleRuntimeRequirements(
892
892
  module: Module,
893
893
  runtime: RuntimeSpec,
894
- items: Set<string>
894
+ items: Set<string>,
895
+ transferOwnership?: boolean
895
896
  ): void;
896
897
  addChunkRuntimeRequirements(chunk: Chunk, items: Set<string>): void;
897
898
  addTreeRuntimeRequirements(chunk: Chunk, items: Iterable<string>): void;
@@ -1458,6 +1459,8 @@ declare class Compilation {
1458
1459
  chunkTemplate: ChunkTemplate;
1459
1460
  runtimeTemplate: RuntimeTemplate;
1460
1461
  moduleTemplates: { javascript: ModuleTemplate };
1462
+ memCache?: MemCache;
1463
+ moduleMemCaches?: WeakMap<Module, MemCache>;
1461
1464
  moduleGraph: ModuleGraph;
1462
1465
  chunkGraph: ChunkGraph;
1463
1466
  codeGenerationResults: CodeGenerationResults;
@@ -1594,7 +1597,7 @@ declare class Compilation {
1594
1597
  reportDependencyErrorsAndWarnings(
1595
1598
  module: Module,
1596
1599
  blocks: DependenciesBlock[]
1597
- ): void;
1600
+ ): boolean;
1598
1601
  codeGeneration(callback?: any): void;
1599
1602
  processRuntimeRequirements(__0?: {
1600
1603
  /**
@@ -1894,6 +1897,7 @@ declare class Compiler {
1894
1897
  context: string;
1895
1898
  requestShortener: RequestShortener;
1896
1899
  cache: Cache;
1900
+ moduleMemCaches?: WeakMap<Module, { hash: string; memCache: MemCache }>;
1897
1901
  compilerPath: string;
1898
1902
  running: boolean;
1899
1903
  idle: boolean;
@@ -3282,6 +3286,11 @@ declare interface Experiments {
3282
3286
  */
3283
3287
  buildHttp?: boolean | HttpUriOptions;
3284
3288
 
3289
+ /**
3290
+ * Enable additional in memory caching of modules that are unchanged and reference only unchanged modules.
3291
+ */
3292
+ cacheUnaffected?: boolean;
3293
+
3285
3294
  /**
3286
3295
  * Apply defaults of next major version.
3287
3296
  */
@@ -3909,6 +3918,11 @@ declare interface FileCacheOptions {
3909
3918
  */
3910
3919
  maxMemoryGenerations?: number;
3911
3920
 
3921
+ /**
3922
+ * Additionally cache computation of modules that are unchanged and reference only unchanged modules in memory.
3923
+ */
3924
+ memoryCacheUnaffected?: boolean;
3925
+
3912
3926
  /**
3913
3927
  * Name for the cache. Different names will lead to different coexisting caches.
3914
3928
  */
@@ -4306,7 +4320,7 @@ declare interface HashedModuleIdsPluginOptions {
4306
4320
  /**
4307
4321
  * The hashing algorithm to use, defaults to 'md4'. All functions from Node.JS' crypto.createHash are supported.
4308
4322
  */
4309
- hashFunction?: string;
4323
+ hashFunction?: string | typeof Hash;
4310
4324
  }
4311
4325
  declare abstract class HelperRuntimeModule extends RuntimeModule {}
4312
4326
  declare class HotModuleReplacementPlugin {
@@ -6299,11 +6313,21 @@ declare interface MapOptions {
6299
6313
  columns?: boolean;
6300
6314
  module?: boolean;
6301
6315
  }
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
+ }
6302
6321
 
6303
6322
  /**
6304
6323
  * Options object for in-memory caching.
6305
6324
  */
6306
6325
  declare interface MemoryCacheOptions {
6326
+ /**
6327
+ * Additionally cache computation of modules that are unchanged and reference only unchanged modules.
6328
+ */
6329
+ cacheUnaffected?: boolean;
6330
+
6307
6331
  /**
6308
6332
  * Number of generations unused cache entries stay in memory cache at minimum (1 = may be removed after unused for a single compilation, ..., Infinity: kept forever).
6309
6333
  */
@@ -9783,6 +9807,7 @@ declare class RuntimeChunkPlugin {
9783
9807
  */
9784
9808
  apply(compiler: Compiler): void;
9785
9809
  }
9810
+ type RuntimeCondition = undefined | string | boolean | SortableSet<string>;
9786
9811
  declare class RuntimeModule extends Module {
9787
9812
  constructor(name: string, stage?: number);
9788
9813
  name: string;
@@ -9829,7 +9854,8 @@ declare interface RuntimeRequirementsContext {
9829
9854
  codeGenerationResults: CodeGenerationResults;
9830
9855
  }
9831
9856
  type RuntimeSpec = undefined | string | SortableSet<string>;
9832
- declare abstract class RuntimeSpecMap<T> {
9857
+ declare class RuntimeSpecMap<T> {
9858
+ constructor(clone?: RuntimeSpecMap<T>);
9833
9859
  get(runtime: RuntimeSpec): T;
9834
9860
  has(runtime: RuntimeSpec): boolean;
9835
9861
  set(runtime?: any, value?: any): void;
@@ -9840,7 +9866,8 @@ declare abstract class RuntimeSpecMap<T> {
9840
9866
  values(): IterableIterator<T>;
9841
9867
  readonly size?: number;
9842
9868
  }
9843
- declare abstract class RuntimeSpecSet {
9869
+ declare class RuntimeSpecSet {
9870
+ constructor(iterable?: any);
9844
9871
  add(runtime?: any): void;
9845
9872
  has(runtime?: any): boolean;
9846
9873
  [Symbol.iterator](): IterableIterator<RuntimeSpec>;
@@ -11299,6 +11326,10 @@ declare interface TimestampAndHash {
11299
11326
  timestamp?: number;
11300
11327
  hash: string;
11301
11328
  }
11329
+ declare class TopLevelSymbol {
11330
+ constructor(name: string);
11331
+ name: string;
11332
+ }
11302
11333
 
11303
11334
  /**
11304
11335
  * Use a Trusted Types policy to create urls for chunks.
@@ -12022,10 +12053,23 @@ declare namespace exports {
12022
12053
  export let NAMESPACE: string;
12023
12054
  export let REGEXP_NAMESPACE: RegExp;
12024
12055
  export let createFilename: (
12025
- module: any,
12056
+ module: string | Module,
12026
12057
  options: any,
12027
- __2: { requestShortener: any; chunkGraph: any }
12028
- ) => any;
12058
+ __2: {
12059
+ /**
12060
+ * requestShortener
12061
+ */
12062
+ requestShortener: RequestShortener;
12063
+ /**
12064
+ * chunk graph
12065
+ */
12066
+ chunkGraph: ChunkGraph;
12067
+ /**
12068
+ * the hash function to use
12069
+ */
12070
+ hashFunction: string | typeof Hash;
12071
+ }
12072
+ ) => string;
12029
12073
  export let replaceDuplicates: (
12030
12074
  array?: any,
12031
12075
  fn?: any,
@@ -12142,6 +12186,52 @@ declare namespace exports {
12142
12186
  };
12143
12187
  }
12144
12188
  export namespace optimize {
12189
+ export namespace InnerGraph {
12190
+ export let bailout: (parserState: ParserState) => void;
12191
+ export let enable: (parserState: ParserState) => void;
12192
+ export let isEnabled: (parserState: ParserState) => boolean;
12193
+ export let addUsage: (
12194
+ state: ParserState,
12195
+ symbol: null | TopLevelSymbol,
12196
+ usage: string | true | TopLevelSymbol
12197
+ ) => void;
12198
+ export let addVariableUsage: (
12199
+ parser: JavascriptParser,
12200
+ name: string,
12201
+ usage: string | true | TopLevelSymbol
12202
+ ) => void;
12203
+ export let inferDependencyUsage: (state: ParserState) => void;
12204
+ export let onUsage: (
12205
+ state: ParserState,
12206
+ onUsageCallback: (arg0?: boolean | Set<string>) => void
12207
+ ) => void;
12208
+ export let setTopLevelSymbol: (
12209
+ state: ParserState,
12210
+ symbol: TopLevelSymbol
12211
+ ) => void;
12212
+ export let getTopLevelSymbol: (
12213
+ state: ParserState
12214
+ ) => void | TopLevelSymbol;
12215
+ export let tagTopLevelSymbol: (
12216
+ parser: JavascriptParser,
12217
+ name: string
12218
+ ) => TopLevelSymbol;
12219
+ export let isDependencyUsedByExports: (
12220
+ dependency: Dependency,
12221
+ usedByExports: boolean | Set<string>,
12222
+ moduleGraph: ModuleGraph,
12223
+ runtime: RuntimeSpec
12224
+ ) => boolean;
12225
+ export let getDependencyUsedByExportsCondition: (
12226
+ dependency: Dependency,
12227
+ usedByExports: boolean | Set<string>,
12228
+ moduleGraph: ModuleGraph
12229
+ ) =>
12230
+ | null
12231
+ | false
12232
+ | ((arg0: ModuleGraphConnection, arg1: RuntimeSpec) => ConnectionState);
12233
+ export { TopLevelSymbol, topLevelSymbolTag };
12234
+ }
12145
12235
  export {
12146
12236
  AggressiveMergingPlugin,
12147
12237
  AggressiveSplittingPlugin,
@@ -12267,6 +12357,59 @@ declare namespace exports {
12267
12357
  b: DependencyLocation
12268
12358
  ) => 0 | 1 | -1;
12269
12359
  }
12360
+ export namespace runtime {
12361
+ export let getEntryRuntime: (
12362
+ compilation: Compilation,
12363
+ name: string,
12364
+ options?: EntryOptions
12365
+ ) => RuntimeSpec;
12366
+ export let forEachRuntime: (
12367
+ runtime: RuntimeSpec,
12368
+ fn: (arg0: string) => void,
12369
+ deterministicOrder?: boolean
12370
+ ) => void;
12371
+ export let getRuntimeKey: (runtime: RuntimeSpec) => string;
12372
+ export let keyToRuntime: (key: string) => RuntimeSpec;
12373
+ export let runtimeToString: (runtime: RuntimeSpec) => string;
12374
+ export let runtimeConditionToString: (
12375
+ runtimeCondition: RuntimeCondition
12376
+ ) => string;
12377
+ export let runtimeEqual: (a: RuntimeSpec, b: RuntimeSpec) => boolean;
12378
+ export let compareRuntime: (a: RuntimeSpec, b: RuntimeSpec) => 0 | 1 | -1;
12379
+ export let mergeRuntime: (a: RuntimeSpec, b: RuntimeSpec) => RuntimeSpec;
12380
+ export let mergeRuntimeCondition: (
12381
+ a: RuntimeCondition,
12382
+ b: RuntimeCondition,
12383
+ runtime: RuntimeSpec
12384
+ ) => RuntimeCondition;
12385
+ export let mergeRuntimeConditionNonFalse: (
12386
+ a: undefined | string | true | SortableSet<string>,
12387
+ b: undefined | string | true | SortableSet<string>,
12388
+ runtime: RuntimeSpec
12389
+ ) => undefined | string | true | SortableSet<string>;
12390
+ export let mergeRuntimeOwned: (
12391
+ a: RuntimeSpec,
12392
+ b: RuntimeSpec
12393
+ ) => RuntimeSpec;
12394
+ export let intersectRuntime: (
12395
+ a: RuntimeSpec,
12396
+ b: RuntimeSpec
12397
+ ) => RuntimeSpec;
12398
+ export let subtractRuntime: (
12399
+ a: RuntimeSpec,
12400
+ b: RuntimeSpec
12401
+ ) => RuntimeSpec;
12402
+ export let subtractRuntimeCondition: (
12403
+ a: RuntimeCondition,
12404
+ b: RuntimeCondition,
12405
+ runtime: RuntimeSpec
12406
+ ) => RuntimeCondition;
12407
+ export let filterRuntime: (
12408
+ runtime: RuntimeSpec,
12409
+ filter: (arg0: RuntimeSpec) => boolean
12410
+ ) => undefined | string | boolean | SortableSet<string>;
12411
+ export { RuntimeSpecMap, RuntimeSpecSet };
12412
+ }
12270
12413
  export namespace serialization {
12271
12414
  export const register: (
12272
12415
  Constructor: Constructor,
@@ -12281,7 +12424,10 @@ declare namespace exports {
12281
12424
  export const registerNotSerializable: (Constructor: Constructor) => void;
12282
12425
  export const NOT_SERIALIZABLE: object;
12283
12426
  export const buffersSerializer: Serializer;
12284
- export let createFileSerializer: (fs?: any) => Serializer;
12427
+ export let createFileSerializer: (
12428
+ fs?: any,
12429
+ hashFunction?: any
12430
+ ) => Serializer;
12285
12431
  export { MEASURE_START_OPERATION, MEASURE_END_OPERATION };
12286
12432
  }
12287
12433
  export const cleverMerge: <T, O>(first: T, second: O) => T | O | (T & O);
@@ -12409,5 +12555,6 @@ declare namespace exports {
12409
12555
  LoaderContext
12410
12556
  };
12411
12557
  }
12558
+ declare const topLevelSymbolTag: unique symbol;
12412
12559
 
12413
12560
  export = exports;