webpack 5.24.1 → 5.24.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.

@@ -350,6 +350,12 @@ module.exports = class MultiCompiler {
350
350
  let errored = false;
351
351
  let running = 0;
352
352
  const parallelism = this._options.parallelism;
353
+ /**
354
+ * @param {Node} node node
355
+ * @param {Error=} err error
356
+ * @param {Stats=} stats result
357
+ * @returns {void}
358
+ */
353
359
  const nodeDone = (node, err, stats) => {
354
360
  if (errored) return;
355
361
  if (err) {
@@ -367,27 +373,35 @@ module.exports = class MultiCompiler {
367
373
  );
368
374
  }
369
375
  node.result = stats;
376
+ running--;
370
377
  if (node.state === "running") {
371
- running--;
372
378
  node.state = "done";
373
- for (const child of node.children) {
374
- if (child.state !== "blocked") continue;
375
- if (child.parents.every(p => p.state === "done")) {
376
- child.state = "queued";
377
- queue.enqueue(child);
378
- }
379
+ }
380
+ for (const child of node.children) {
381
+ if (child.state !== "blocked") continue;
382
+ if (child.parents.every(p => p.state === "done")) {
383
+ child.state = "queued";
384
+ queue.enqueue(child);
379
385
  }
380
- process.nextTick(processQueue);
381
386
  }
387
+ process.nextTick(processQueue);
382
388
  };
389
+ /**
390
+ * @param {Node} node node
391
+ * @returns {void}
392
+ */
383
393
  const nodeInvalid = node => {
384
- if (node.state === "done") {
394
+ if (node.state === "done" || node.state === "running") {
385
395
  node.state = "blocked";
386
- for (const child of node.children) {
387
- nodeInvalid(child);
388
- }
396
+ }
397
+ for (const child of node.children) {
398
+ nodeInvalid(child);
389
399
  }
390
400
  };
401
+ /**
402
+ * @param {Node} node node
403
+ * @returns {void}
404
+ */
391
405
  const nodeChange = node => {
392
406
  nodeInvalid(node);
393
407
  if (
@@ -415,6 +429,7 @@ module.exports = class MultiCompiler {
415
429
  const processQueue = () => {
416
430
  while (running < parallelism && queue.length > 0 && !errored) {
417
431
  const node = queue.dequeue();
432
+ if (node.state !== "queued") continue;
418
433
  running++;
419
434
  node.state = "running";
420
435
  run(node.compiler, nodeDone.bind(null, node));
@@ -446,6 +461,7 @@ module.exports = class MultiCompiler {
446
461
  if (this.running) {
447
462
  return handler(new ConcurrentCompilationError());
448
463
  }
464
+ this.running = true;
449
465
 
450
466
  if (this.validateDependencies(handler)) {
451
467
  const watchings = this._runGraph(
@@ -480,6 +496,7 @@ module.exports = class MultiCompiler {
480
496
  if (this.running) {
481
497
  return callback(new ConcurrentCompilationError());
482
498
  }
499
+ this.running = true;
483
500
 
484
501
  if (this.validateDependencies(callback)) {
485
502
  this._runGraph(
package/lib/Watching.js CHANGED
@@ -54,7 +54,6 @@ class Watching {
54
54
  this.running = false;
55
55
  this._initial = true;
56
56
  this._needRecords = true;
57
- this._needWatcherInfo = false;
58
57
  this.watcher = undefined;
59
58
  this.pausedWatcher = undefined;
60
59
  this._done = this._done.bind(this);
@@ -84,21 +83,6 @@ class Watching {
84
83
  });
85
84
  }
86
85
  this.invalid = false;
87
- if (this._needWatcherInfo) {
88
- this._needWatcherInfo = false;
89
- const watcher = this.pausedWatcher;
90
- if (watcher) {
91
- this.compiler.modifiedFiles = watcher.aggregatedChanges;
92
- this.compiler.removedFiles = watcher.aggregatedRemovals;
93
- this.compiler.fileTimestamps = watcher.getFileTimeInfoEntries();
94
- this.compiler.contextTimestamps = watcher.getContextTimeInfoEntries();
95
- } else {
96
- this.compiler.modifiedFiles = undefined;
97
- this.compiler.removedFiles = undefined;
98
- this.compiler.fileTimestamps = undefined;
99
- this.compiler.contextTimestamps = undefined;
100
- }
101
- }
102
86
  this.compiler.hooks.watchRun.callAsync(this.compiler, err => {
103
87
  if (err) return this._done(err);
104
88
  const onCompiled = (err, compilation) => {
@@ -277,6 +261,11 @@ class Watching {
277
261
  this.compiler.contextTimestamps = contextTimeInfoEntries;
278
262
  this.compiler.removedFiles = removedFiles;
279
263
  this.compiler.modifiedFiles = changedFiles;
264
+ if (this.watcher) {
265
+ this.pausedWatcher = this.watcher;
266
+ this.watcher.pause();
267
+ this.watcher = null;
268
+ }
280
269
  this._invalidate();
281
270
  this._onChange();
282
271
  },
@@ -297,7 +286,6 @@ class Watching {
297
286
  }
298
287
  if (!this._initial) {
299
288
  this.compiler.hooks.invalid.call(null, Date.now());
300
- this._needWatcherInfo = true;
301
289
  }
302
290
  this._invalidate();
303
291
  }
@@ -309,6 +297,14 @@ class Watching {
309
297
  return;
310
298
  }
311
299
  if (this.watcher) {
300
+ this.compiler.modifiedFiles =
301
+ this.watcher.getAggregatedChanges &&
302
+ this.watcher.getAggregatedChanges();
303
+ this.compiler.removedFiles =
304
+ this.watcher.getAggregatedRemovals &&
305
+ this.watcher.getAggregatedRemovals();
306
+ this.compiler.fileTimestamps = this.watcher.getFileTimeInfoEntries();
307
+ this.compiler.contextTimestamps = this.watcher.getContextTimeInfoEntries();
312
308
  this.pausedWatcher = this.watcher;
313
309
  this.watcher.pause();
314
310
  this.watcher = null;
@@ -328,7 +324,6 @@ class Watching {
328
324
  resume() {
329
325
  if (this.suspended) {
330
326
  this.suspended = false;
331
- this._needWatcherInfo = true;
332
327
  this._invalidate();
333
328
  }
334
329
  }
@@ -98,6 +98,12 @@ class NodeWatchFileSystem {
98
98
  this.watcher.pause();
99
99
  }
100
100
  },
101
+ getAggregatedRemovals: () => {
102
+ return this.watcher && this.watcher.aggregatedRemovals;
103
+ },
104
+ getAggregatedChanges: () => {
105
+ return this.watcher && this.watcher.aggregatedChanges;
106
+ },
101
107
  getFileTimeInfoEntries: () => {
102
108
  if (this.watcher) {
103
109
  return this.watcher.getTimeInfoEntries();
@@ -1241,7 +1241,10 @@ class ConcatenatedModule extends Module {
1241
1241
  const path = getPathInAst(info.ast, identifier);
1242
1242
  if (path && path.length > 1) {
1243
1243
  const maybeProperty =
1244
- path[1].type === "AssignmentPattern" ? path[2] : path[1];
1244
+ path[1].type === "AssignmentPattern" &&
1245
+ path[1].left === path[0]
1246
+ ? path[2]
1247
+ : path[1];
1245
1248
  if (
1246
1249
  maybeProperty.type === "Property" &&
1247
1250
  maybeProperty.shorthand
package/lib/util/fs.js CHANGED
@@ -64,6 +64,8 @@ const path = require("path");
64
64
  * @typedef {Object} Watcher
65
65
  * @property {function(): void} close closes the watcher and all underlying file watchers
66
66
  * @property {function(): void} pause closes the watcher, but keeps underlying file watchers alive until the next watch call
67
+ * @property {function(): Set<string>=} getAggregatedChanges get current aggregated changes that have not yet send to callback
68
+ * @property {function(): Set<string>=} getAggregatedRemovals get current aggregated removals that have not yet send to callback
67
69
  * @property {function(): Map<string, FileSystemInfoEntry | "ignore">} getFileTimeInfoEntries get info about files
68
70
  * @property {function(): Map<string, FileSystemInfoEntry | "ignore">} getContextTimeInfoEntries get info about directories
69
71
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.24.1",
3
+ "version": "5.24.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
@@ -10786,6 +10786,16 @@ declare interface Watcher {
10786
10786
  */
10787
10787
  pause: () => void;
10788
10788
 
10789
+ /**
10790
+ * get current aggregated changes that have not yet send to callback
10791
+ */
10792
+ getAggregatedChanges?: () => Set<string>;
10793
+
10794
+ /**
10795
+ * get current aggregated removals that have not yet send to callback
10796
+ */
10797
+ getAggregatedRemovals?: () => Set<string>;
10798
+
10789
10799
  /**
10790
10800
  * get info about files
10791
10801
  */