webpack 5.20.1 → 5.20.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.

@@ -1872,6 +1872,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1872
1872
  });
1873
1873
  }
1874
1874
 
1875
+ this.processDependenciesQueue.invalidate(module);
1875
1876
  this.processModuleDependencies(module, err => {
1876
1877
  if (err) return callback(err);
1877
1878
  this.removeReasonsOfDependencyBlock(module, {
package/lib/Generator.js CHANGED
@@ -28,6 +28,7 @@
28
28
  * @property {RuntimeSpec} runtime the runtime
29
29
  * @property {ConcatenationScope=} concatenationScope when in concatenated module, information about other concatenated modules
30
30
  * @property {string} type which kind of code should be generated
31
+ * @property {function(): Map<string, any>=} getData get access to the code generation data
31
32
  */
32
33
 
33
34
  /**
@@ -993,6 +993,13 @@ class NormalModule extends Module {
993
993
  runtimeRequirements.add(RuntimeGlobals.thisAsExports);
994
994
  }
995
995
 
996
+ /** @type {Map<string, any>} */
997
+ let data;
998
+ const getData = () => {
999
+ if (data === undefined) data = new Map();
1000
+ return data;
1001
+ };
1002
+
996
1003
  const sources = new Map();
997
1004
  for (const type of this.generator.getTypes(this)) {
998
1005
  const source = this.error
@@ -1007,6 +1014,7 @@ class NormalModule extends Module {
1007
1014
  runtimeRequirements,
1008
1015
  runtime,
1009
1016
  concatenationScope,
1017
+ getData,
1010
1018
  type
1011
1019
  });
1012
1020
 
@@ -1018,7 +1026,8 @@ class NormalModule extends Module {
1018
1026
  /** @type {CodeGenerationResult} */
1019
1027
  const resultEntry = {
1020
1028
  sources,
1021
- runtimeRequirements
1029
+ runtimeRequirements,
1030
+ data
1022
1031
  };
1023
1032
  return resultEntry;
1024
1033
  }
@@ -47,7 +47,7 @@ class AssetGenerator extends Generator {
47
47
  */
48
48
  generate(
49
49
  module,
50
- { runtime, chunkGraph, runtimeTemplate, runtimeRequirements, type }
50
+ { runtime, chunkGraph, runtimeTemplate, runtimeRequirements, type, getData }
51
51
  ) {
52
52
  switch (type) {
53
53
  case "asset":
@@ -146,6 +146,15 @@ class AssetGenerator extends Generator {
146
146
  sourceFilename,
147
147
  ...info
148
148
  };
149
+ if (getData) {
150
+ // Due to code generation caching module.buildInfo.XXX can't used to store such information
151
+ // It need to be stored in the code generation results instead, where it's cached too
152
+ // TODO webpack 6 For back-compat reasons we also store in on module.buildInfo
153
+ const data = getData();
154
+ data.set("fullContentHash", fullHash);
155
+ data.set("filename", filename);
156
+ data.set("assetInfo", info);
157
+ }
149
158
 
150
159
  runtimeRequirements.add(RuntimeGlobals.publicPath); // add __webpack_require__.p
151
160
 
@@ -145,14 +145,23 @@ class AssetModulesPlugin {
145
145
  );
146
146
  if (modules) {
147
147
  for (const module of modules) {
148
+ const codeGenResult = codeGenerationResults.get(
149
+ module,
150
+ chunk.runtime
151
+ );
148
152
  result.push({
149
- render: () =>
150
- codeGenerationResults.getSource(module, chunk.runtime, type),
151
- filename: module.buildInfo.filename,
152
- info: module.buildInfo.assetInfo,
153
+ render: () => codeGenResult.sources.get(type),
154
+ filename:
155
+ module.buildInfo.filename ||
156
+ codeGenResult.data.get("filename"),
157
+ info:
158
+ module.buildInfo.assetInfo ||
159
+ codeGenResult.data.get("assetInfo"),
153
160
  auxiliary: true,
154
161
  identifier: `assetModule${chunkGraph.getModuleId(module)}`,
155
- hash: module.buildInfo.fullContentHash
162
+ hash:
163
+ module.buildInfo.fullContentHash ||
164
+ codeGenResult.data.get("fullContentHash")
156
165
  });
157
166
  }
158
167
  }
@@ -127,9 +127,15 @@ class IdleFileCachePlugin {
127
127
  });
128
128
  return;
129
129
  }
130
- currentIdlePromise = currentIdlePromise.then(() =>
131
- strategy.afterAllStored()
132
- );
130
+ currentIdlePromise = currentIdlePromise
131
+ .then(() => strategy.afterAllStored())
132
+ .catch(err => {
133
+ const logger = compiler.getInfrastructureLogger(
134
+ "IdleFileCachePlugin"
135
+ );
136
+ logger.warn(`Background tasks during idle failed: ${err.message}`);
137
+ logger.debug(err.stack);
138
+ });
133
139
  isInitialStore = false;
134
140
  }
135
141
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.20.1",
3
+ "version": "5.20.2",
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
@@ -3796,6 +3796,11 @@ declare interface GenerateContext {
3796
3796
  * which kind of code should be generated
3797
3797
  */
3798
3798
  type: string;
3799
+
3800
+ /**
3801
+ * get access to the code generation data
3802
+ */
3803
+ getData?: () => Map<string, any>;
3799
3804
  }
3800
3805
  declare class Generator {
3801
3806
  constructor();