webpack 5.39.0 → 5.39.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.

package/bin/webpack.js CHANGED
File without changes
@@ -337,6 +337,31 @@ const deprecatedNormalModuleLoaderHook = util.deprecate(
337
337
  "DEP_WEBPACK_COMPILATION_NORMAL_MODULE_LOADER_HOOK"
338
338
  );
339
339
 
340
+ // TODO webpack 6: remove
341
+ const defineRemovedModuleTemplates = moduleTemplates => {
342
+ Object.defineProperties(moduleTemplates, {
343
+ asset: {
344
+ enumerable: false,
345
+ configurable: false,
346
+ get: () => {
347
+ throw new WebpackError(
348
+ "Compilation.moduleTemplates.asset has been removed"
349
+ );
350
+ }
351
+ },
352
+ webassembly: {
353
+ enumerable: false,
354
+ configurable: false,
355
+ get: () => {
356
+ throw new WebpackError(
357
+ "Compilation.moduleTemplates.webassembly has been removed"
358
+ );
359
+ }
360
+ }
361
+ });
362
+ moduleTemplates = undefined;
363
+ };
364
+
340
365
  const byId = compareSelect(
341
366
  /**
342
367
  * @param {Chunk} c chunk
@@ -861,26 +886,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
861
886
  this.moduleTemplates = {
862
887
  javascript: new ModuleTemplate(this.runtimeTemplate, this)
863
888
  };
864
- Object.defineProperties(this.moduleTemplates, {
865
- asset: {
866
- enumerable: false,
867
- configurable: false,
868
- get() {
869
- throw new WebpackError(
870
- "Compilation.moduleTemplates.asset has been removed"
871
- );
872
- }
873
- },
874
- webassembly: {
875
- enumerable: false,
876
- configurable: false,
877
- get() {
878
- throw new WebpackError(
879
- "Compilation.moduleTemplates.webassembly has been removed"
880
- );
881
- }
882
- }
883
- });
889
+ defineRemovedModuleTemplates(this.moduleTemplates);
884
890
 
885
891
  this.moduleGraph = new ModuleGraph();
886
892
  /** @type {ChunkGraph} */
@@ -1999,6 +2005,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
1999
2005
  }
2000
2006
 
2001
2007
  finish(callback) {
2008
+ this.factorizeQueue.clear();
2002
2009
  if (this.profile) {
2003
2010
  this.logger.time("finish module profiles");
2004
2011
  const ParallelismFactorCalculator = require("./util/ParallelismFactorCalculator");
@@ -2233,6 +2240,14 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2233
2240
  * @returns {void}
2234
2241
  */
2235
2242
  seal(callback) {
2243
+ const finalCallback = err => {
2244
+ this.factorizeQueue.clear();
2245
+ this.buildQueue.clear();
2246
+ this.rebuildQueue.clear();
2247
+ this.processDependenciesQueue.clear();
2248
+ this.addModuleQueue.clear();
2249
+ return callback(err);
2250
+ };
2236
2251
  const chunkGraph = new ChunkGraph(this.moduleGraph);
2237
2252
  this.chunkGraph = chunkGraph;
2238
2253
 
@@ -2397,7 +2412,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
2397
2412
 
2398
2413
  this.hooks.optimizeTree.callAsync(this.chunks, this.modules, err => {
2399
2414
  if (err) {
2400
- return callback(
2415
+ return finalCallback(
2401
2416
  makeWebpackError(err, "Compilation.hooks.optimizeTree")
2402
2417
  );
2403
2418
  }
@@ -2409,7 +2424,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
2409
2424
  this.modules,
2410
2425
  err => {
2411
2426
  if (err) {
2412
- return callback(
2427
+ return finalCallback(
2413
2428
  makeWebpackError(err, "Compilation.hooks.optimizeChunkModules")
2414
2429
  );
2415
2430
  }
@@ -2452,7 +2467,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
2452
2467
  this.hooks.beforeCodeGeneration.call();
2453
2468
  this.codeGeneration(err => {
2454
2469
  if (err) {
2455
- return callback(err);
2470
+ return finalCallback(err);
2456
2471
  }
2457
2472
  this.hooks.afterCodeGeneration.call();
2458
2473
  this.logger.timeEnd("code generation");
@@ -2471,7 +2486,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
2471
2486
 
2472
2487
  this._runCodeGenerationJobs(codeGenerationJobs, err => {
2473
2488
  if (err) {
2474
- return callback(err);
2489
+ return finalCallback(err);
2475
2490
  }
2476
2491
 
2477
2492
  if (shouldRecord) {
@@ -2491,7 +2506,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
2491
2506
  this.logger.time("process assets");
2492
2507
  this.hooks.processAssets.callAsync(this.assets, err => {
2493
2508
  if (err) {
2494
- return callback(
2509
+ return finalCallback(
2495
2510
  makeWebpackError(err, "Compilation.hooks.processAssets")
2496
2511
  );
2497
2512
  }
@@ -2517,12 +2532,12 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
2517
2532
  }
2518
2533
  return this.hooks.afterSeal.callAsync(err => {
2519
2534
  if (err) {
2520
- return callback(
2535
+ return finalCallback(
2521
2536
  makeWebpackError(err, "Compilation.hooks.afterSeal")
2522
2537
  );
2523
2538
  }
2524
2539
  this.fileSystemInfo.logStatistics();
2525
- callback();
2540
+ finalCallback();
2526
2541
  });
2527
2542
  });
2528
2543
  };
@@ -2533,7 +2548,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
2533
2548
  this.createChunkAssets(err => {
2534
2549
  this.logger.timeEnd("create chunk assets");
2535
2550
  if (err) {
2536
- return callback(err);
2551
+ return finalCallback(err);
2537
2552
  }
2538
2553
  cont();
2539
2554
  });
@@ -8,6 +8,7 @@
8
8
  const FileSystemInfo = require("../FileSystemInfo");
9
9
  const ProgressPlugin = require("../ProgressPlugin");
10
10
  const { formatSize } = require("../SizeFormatHelpers");
11
+ const SerializerMiddleware = require("../serialization/SerializerMiddleware");
11
12
  const LazySet = require("../util/LazySet");
12
13
  const makeSerializable = require("../util/makeSerializable");
13
14
  const memoize = require("../util/memoize");
@@ -715,6 +716,7 @@ class PackContent {
715
716
  this.logger.timeEnd(timeMessage);
716
717
  }
717
718
  this.content = map;
719
+ this.lazy = SerializerMiddleware.unMemoizeLazy(this.lazy);
718
720
  return map.get(identifier);
719
721
  });
720
722
  } else {
@@ -723,6 +725,7 @@ class PackContent {
723
725
  this.logger.timeEnd(timeMessage);
724
726
  }
725
727
  this.content = map;
728
+ this.lazy = SerializerMiddleware.unMemoizeLazy(this.lazy);
726
729
  return map.get(identifier);
727
730
  }
728
731
  }
@@ -126,6 +126,25 @@ class SerializerMiddleware {
126
126
  fn[LAZY_SERIALIZED_VALUE] = lazy;
127
127
  return fn;
128
128
  }
129
+
130
+ /**
131
+ * @param {function(): Promise<any> | any} lazy lazy function
132
+ * @returns {function(): Promise<any> | any} new lazy
133
+ */
134
+ static unMemoizeLazy(lazy) {
135
+ if (!SerializerMiddleware.isLazy(lazy)) return lazy;
136
+ const fn = () => {
137
+ throw new Error(
138
+ "A lazy value that has been unmemorized can't be called again"
139
+ );
140
+ };
141
+ fn[LAZY_SERIALIZED_VALUE] = SerializerMiddleware.unMemoizeLazy(
142
+ lazy[LAZY_SERIALIZED_VALUE]
143
+ );
144
+ fn[LAZY_TARGET] = lazy[LAZY_TARGET];
145
+ fn.options = /** @type {any} */ (lazy).options;
146
+ return fn;
147
+ }
129
148
  }
130
149
 
131
150
  module.exports = SerializerMiddleware;
@@ -27,6 +27,14 @@ class ArrayQueue {
27
27
  return this._list.length + this._listReversed.length;
28
28
  }
29
29
 
30
+ /**
31
+ * Empties the queue.
32
+ */
33
+ clear() {
34
+ this._list.length = 0;
35
+ this._listReversed.length = 0;
36
+ }
37
+
30
38
  /**
31
39
  * Appends the specified element to this queue.
32
40
  * @param {T} item The element to add.
@@ -359,6 +359,15 @@ class AsyncQueue {
359
359
  inHandleResult--;
360
360
  });
361
361
  }
362
+
363
+ clear() {
364
+ this._entries.clear();
365
+ this._queued.clear();
366
+ this._activeTasks = 0;
367
+ this._willEnsureProcessing = false;
368
+ this._needProcessing = false;
369
+ this._stopped = false;
370
+ }
362
371
  }
363
372
 
364
373
  module.exports = AsyncQueue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.39.0",
3
+ "version": "5.39.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
@@ -358,6 +358,7 @@ declare abstract class AsyncQueue<T, K, R> {
358
358
  isProcessing(item: T): boolean;
359
359
  isQueued(item: T): boolean;
360
360
  isDone(item: T): boolean;
361
+ clear(): void;
361
362
  }
362
363
  declare class AsyncWebAssemblyModulesPlugin {
363
364
  constructor(options?: any);