webpack 4.42.1 → 4.43.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.
@@ -109,6 +109,7 @@ module.exports = function() {
109
109
  _declinedDependencies: {},
110
110
  _selfAccepted: false,
111
111
  _selfDeclined: false,
112
+ _selfInvalidated: false,
112
113
  _disposeHandlers: [],
113
114
  _main: hotCurrentChildModule !== moduleId,
114
115
 
@@ -139,6 +140,29 @@ module.exports = function() {
139
140
  var idx = hot._disposeHandlers.indexOf(callback);
140
141
  if (idx >= 0) hot._disposeHandlers.splice(idx, 1);
141
142
  },
143
+ invalidate: function() {
144
+ this._selfInvalidated = true;
145
+ switch (hotStatus) {
146
+ case "idle":
147
+ hotUpdate = {};
148
+ hotUpdate[moduleId] = modules[moduleId];
149
+ hotSetStatus("ready");
150
+ break;
151
+ case "ready":
152
+ hotApplyInvalidatedModule(moduleId);
153
+ break;
154
+ case "prepare":
155
+ case "check":
156
+ case "dispose":
157
+ case "apply":
158
+ (hotQueuedInvalidatedModules =
159
+ hotQueuedInvalidatedModules || []).push(moduleId);
160
+ break;
161
+ default:
162
+ // ignore requests in error states
163
+ break;
164
+ }
165
+ },
142
166
 
143
167
  // Management API
144
168
  check: hotCheck,
@@ -180,7 +204,7 @@ module.exports = function() {
180
204
  var hotDeferred;
181
205
 
182
206
  // The update info
183
- var hotUpdate, hotUpdateNewHash;
207
+ var hotUpdate, hotUpdateNewHash, hotQueuedInvalidatedModules;
184
208
 
185
209
  function toModuleId(id) {
186
210
  var isNumber = +id + "" === id;
@@ -195,7 +219,7 @@ module.exports = function() {
195
219
  hotSetStatus("check");
196
220
  return hotDownloadManifest(hotRequestTimeout).then(function(update) {
197
221
  if (!update) {
198
- hotSetStatus("idle");
222
+ hotSetStatus(hotApplyInvalidatedModules() ? "ready" : "idle");
199
223
  return null;
200
224
  }
201
225
  hotRequestedFilesMap = {};
@@ -288,6 +312,11 @@ module.exports = function() {
288
312
  if (hotStatus !== "ready")
289
313
  throw new Error("apply() is only allowed in ready status");
290
314
  options = options || {};
315
+ return hotApplyInternal(options);
316
+ }
317
+
318
+ function hotApplyInternal(options) {
319
+ hotApplyInvalidatedModules();
291
320
 
292
321
  var cb;
293
322
  var i;
@@ -310,7 +339,11 @@ module.exports = function() {
310
339
  var moduleId = queueItem.id;
311
340
  var chain = queueItem.chain;
312
341
  module = installedModules[moduleId];
313
- if (!module || module.hot._selfAccepted) continue;
342
+ if (
343
+ !module ||
344
+ (module.hot._selfAccepted && !module.hot._selfInvalidated)
345
+ )
346
+ continue;
314
347
  if (module.hot._selfDeclined) {
315
348
  return {
316
349
  type: "self-declined",
@@ -478,10 +511,13 @@ module.exports = function() {
478
511
  installedModules[moduleId] &&
479
512
  installedModules[moduleId].hot._selfAccepted &&
480
513
  // removed self-accepted modules should not be required
481
- appliedUpdate[moduleId] !== warnUnexpectedRequire
514
+ appliedUpdate[moduleId] !== warnUnexpectedRequire &&
515
+ // when called invalidate self-accepting is not possible
516
+ !installedModules[moduleId].hot._selfInvalidated
482
517
  ) {
483
518
  outdatedSelfAcceptedModules.push({
484
519
  module: moduleId,
520
+ parents: installedModules[moduleId].parents.slice(),
485
521
  errorHandler: installedModules[moduleId].hot._selfAccepted
486
522
  });
487
523
  }
@@ -554,7 +590,11 @@ module.exports = function() {
554
590
  // Now in "apply" phase
555
591
  hotSetStatus("apply");
556
592
 
557
- hotCurrentHash = hotUpdateNewHash;
593
+ if (hotUpdateNewHash !== undefined) {
594
+ hotCurrentHash = hotUpdateNewHash;
595
+ hotUpdateNewHash = undefined;
596
+ }
597
+ hotUpdate = undefined;
558
598
 
559
599
  // insert new code
560
600
  for (moduleId in appliedUpdate) {
@@ -607,7 +647,8 @@ module.exports = function() {
607
647
  for (i = 0; i < outdatedSelfAcceptedModules.length; i++) {
608
648
  var item = outdatedSelfAcceptedModules[i];
609
649
  moduleId = item.module;
610
- hotCurrentParents = [moduleId];
650
+ hotCurrentParents = item.parents;
651
+ hotCurrentChildModule = moduleId;
611
652
  try {
612
653
  $require$(moduleId);
613
654
  } catch (err) {
@@ -649,9 +690,32 @@ module.exports = function() {
649
690
  return Promise.reject(error);
650
691
  }
651
692
 
693
+ if (hotQueuedInvalidatedModules) {
694
+ return hotApplyInternal(options).then(function(list) {
695
+ outdatedModules.forEach(function(moduleId) {
696
+ if (list.indexOf(moduleId) < 0) list.push(moduleId);
697
+ });
698
+ return list;
699
+ });
700
+ }
701
+
652
702
  hotSetStatus("idle");
653
703
  return new Promise(function(resolve) {
654
704
  resolve(outdatedModules);
655
705
  });
656
706
  }
707
+
708
+ function hotApplyInvalidatedModules() {
709
+ if (hotQueuedInvalidatedModules) {
710
+ if (!hotUpdate) hotUpdate = {};
711
+ hotQueuedInvalidatedModules.forEach(hotApplyInvalidatedModule);
712
+ hotQueuedInvalidatedModules = undefined;
713
+ return true;
714
+ }
715
+ }
716
+
717
+ function hotApplyInvalidatedModule(moduleId) {
718
+ if (!Object.prototype.hasOwnProperty.call(hotUpdate, moduleId))
719
+ hotUpdate[moduleId] = modules[moduleId];
720
+ }
657
721
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "4.42.1",
3
+ "version": "4.43.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",
@@ -9,7 +9,7 @@
9
9
  "@webassemblyjs/helper-module-context": "1.9.0",
10
10
  "@webassemblyjs/wasm-edit": "1.9.0",
11
11
  "@webassemblyjs/wasm-parser": "1.9.0",
12
- "acorn": "^6.2.1",
12
+ "acorn": "^6.4.1",
13
13
  "ajv": "^6.10.2",
14
14
  "ajv-keywords": "^3.4.1",
15
15
  "chrome-trace-event": "^1.0.2",
@@ -26,7 +26,7 @@
26
26
  "schema-utils": "^1.0.0",
27
27
  "tapable": "^1.1.3",
28
28
  "terser-webpack-plugin": "^1.4.3",
29
- "watchpack": "^1.6.0",
29
+ "watchpack": "^1.6.1",
30
30
  "webpack-sources": "^1.4.1"
31
31
  },
32
32
  "devDependencies": {