webpack 4.1.0 → 4.4.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.
Files changed (118) hide show
  1. package/README.md +719 -721
  2. package/bin/webpack.js +69 -10
  3. package/lib/APIPlugin.js +84 -84
  4. package/lib/AmdMainTemplatePlugin.js +75 -77
  5. package/lib/AsyncDependencyToInitialChunkError.js +21 -23
  6. package/lib/BannerPlugin.js +101 -101
  7. package/lib/Chunk.js +477 -469
  8. package/lib/ChunkTemplate.js +51 -53
  9. package/lib/Compilation.js +1858 -1851
  10. package/lib/Compiler.js +493 -478
  11. package/lib/ConcurrentCompilationError.js +19 -0
  12. package/lib/ContextModule.js +696 -685
  13. package/lib/ContextModuleFactory.js +245 -243
  14. package/lib/DefinePlugin.js +197 -197
  15. package/lib/DelegatedModule.js +101 -101
  16. package/lib/DependenciesBlockVariable.js +51 -52
  17. package/lib/Dependency.js +53 -52
  18. package/lib/DllModule.js +54 -54
  19. package/lib/DllModuleFactory.js +29 -29
  20. package/lib/EnvironmentPlugin.js +65 -67
  21. package/lib/EvalDevToolModuleTemplatePlugin.js +60 -60
  22. package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +105 -105
  23. package/lib/ExportPropertyMainTemplatePlugin.js +40 -40
  24. package/lib/ExternalModule.js +159 -159
  25. package/lib/FunctionModuleTemplatePlugin.js +98 -98
  26. package/lib/HotModuleReplacement.runtime.js +631 -631
  27. package/lib/HotModuleReplacementPlugin.js +407 -406
  28. package/lib/HotUpdateChunkTemplate.js +78 -80
  29. package/lib/JavascriptGenerator.js +228 -229
  30. package/lib/JavascriptModulesPlugin.js +184 -158
  31. package/lib/JsonGenerator.js +42 -42
  32. package/lib/MainTemplate.js +406 -402
  33. package/lib/Module.js +343 -340
  34. package/lib/ModuleBuildError.js +42 -42
  35. package/lib/ModuleError.js +28 -28
  36. package/lib/ModuleFilenameHelpers.js +166 -166
  37. package/lib/ModuleTemplate.js +77 -79
  38. package/lib/ModuleWarning.js +30 -30
  39. package/lib/MultiCompiler.js +271 -259
  40. package/lib/MultiModule.js +78 -75
  41. package/lib/MultiModuleFactory.js +23 -23
  42. package/lib/MultiWatching.js +38 -37
  43. package/lib/NoModeWarning.js +23 -21
  44. package/lib/NormalModule.js +478 -470
  45. package/lib/NormalModuleFactory.js +483 -481
  46. package/lib/OptionsDefaulter.js +80 -86
  47. package/lib/Parser.js +2074 -2071
  48. package/lib/ProgressPlugin.js +231 -231
  49. package/lib/RawModule.js +54 -55
  50. package/lib/RecordIdsPlugin.js +160 -160
  51. package/lib/RemovedPluginError.js +13 -13
  52. package/lib/ResolverFactory.js +64 -67
  53. package/lib/RuntimeTemplate.js +267 -297
  54. package/lib/SetVarMainTemplatePlugin.js +57 -57
  55. package/lib/SourceMapDevToolPlugin.js +302 -308
  56. package/lib/Stats.js +1234 -1212
  57. package/lib/Template.js +205 -205
  58. package/lib/TemplatedPathPlugin.js +170 -143
  59. package/lib/UmdMainTemplatePlugin.js +264 -269
  60. package/lib/Watching.js +193 -193
  61. package/lib/WebAssemblyParser.js +50 -54
  62. package/lib/WebpackOptionsApply.js +401 -401
  63. package/lib/WebpackOptionsDefaulter.js +337 -317
  64. package/lib/WebpackOptionsValidationError.js +316 -319
  65. package/lib/debug/ProfilingPlugin.js +409 -405
  66. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +328 -311
  67. package/lib/dependencies/AMDRequireContextDependency.js +20 -20
  68. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +270 -241
  69. package/lib/dependencies/HarmonyAcceptImportDependency.js +23 -23
  70. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +620 -606
  71. package/lib/dependencies/HarmonyExportSpecifierDependency.js +53 -53
  72. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +214 -214
  73. package/lib/dependencies/HarmonyImportSpecifierDependency.js +154 -156
  74. package/lib/dependencies/ImportDependenciesBlock.js +17 -17
  75. package/lib/dependencies/ImportDependency.js +34 -34
  76. package/lib/dependencies/ImportEagerDependency.js +32 -32
  77. package/lib/dependencies/ImportParserPlugin.js +175 -179
  78. package/lib/dependencies/ImportWeakDependency.js +34 -34
  79. package/lib/dependencies/JsonExportsDependency.js +25 -25
  80. package/lib/dependencies/ModuleDependency.js +20 -20
  81. package/lib/dependencies/NullDependency.js +20 -20
  82. package/lib/dependencies/RequireContextDependency.js +22 -22
  83. package/lib/dependencies/RequireIncludeDependency.js +40 -40
  84. package/lib/dependencies/WebpackMissingModule.js +20 -22
  85. package/lib/node/NodeChunkTemplatePlugin.js +31 -31
  86. package/lib/node/NodeHotUpdateChunkTemplatePlugin.js +36 -36
  87. package/lib/node/NodeMainTemplatePlugin.js +320 -273
  88. package/lib/node/ReadFileCompileWasmMainTemplatePlugin.js +113 -115
  89. package/lib/optimize/AggressiveSplittingPlugin.js +281 -281
  90. package/lib/optimize/ConcatenatedModule.js +1364 -1366
  91. package/lib/optimize/RemoveParentModulesPlugin.js +114 -114
  92. package/lib/optimize/SplitChunksPlugin.js +519 -491
  93. package/lib/performance/SizeLimitsPlugin.js +105 -105
  94. package/lib/util/TrackingSet.js +35 -35
  95. package/lib/util/objectToMap.js +10 -10
  96. package/lib/wasm/WasmModuleTemplatePlugin.js +106 -106
  97. package/lib/web/JsonpChunkTemplatePlugin.js +47 -47
  98. package/lib/web/JsonpExportMainTemplatePlugin.js +47 -47
  99. package/lib/web/JsonpHotUpdateChunkTemplatePlugin.js +39 -39
  100. package/lib/web/JsonpMainTemplatePlugin.js +425 -403
  101. package/lib/webpack.js +182 -179
  102. package/lib/webworker/WebWorkerChunkTemplatePlugin.js +35 -35
  103. package/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js +40 -40
  104. package/lib/webworker/WebWorkerMainTemplatePlugin.js +177 -154
  105. package/package.json +9 -8
  106. package/schemas/WebpackOptions.json +1973 -1951
  107. package/schemas/ajv.absolutePath.js +55 -29
  108. package/schemas/plugins/BannerPlugin.json +85 -85
  109. package/schemas/plugins/DllPlugin.json +28 -28
  110. package/schemas/plugins/DllReferencePlugin.json +99 -99
  111. package/schemas/plugins/HashedModuleIdsPlugin.json +24 -24
  112. package/schemas/plugins/LoaderOptionsPlugin.json +26 -26
  113. package/schemas/plugins/SourceMapDevToolPlugin.json +187 -187
  114. package/schemas/plugins/WatchIgnorePlugin.json +16 -16
  115. package/schemas/plugins/debug/ProfilingPlugin.json +12 -12
  116. package/schemas/plugins/optimize/AggressiveSplittingPlugin.json +22 -22
  117. package/schemas/plugins/optimize/LimitChunkCountPlugin.json +15 -15
  118. package/schemas/plugins/optimize/MinChunkSizePlugin.json +13 -13
@@ -1,631 +1,631 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
- /*global $hash$ $requestTimeout$ installedModules $require$ hotDownloadManifest hotDownloadUpdateChunk hotDisposeChunk modules */
6
- module.exports = function() {
7
- var hotApplyOnUpdate = true;
8
- var hotCurrentHash = $hash$; // eslint-disable-line no-unused-vars
9
- var hotRequestTimeout = $requestTimeout$;
10
- var hotCurrentModuleData = {};
11
- var hotCurrentChildModule; // eslint-disable-line no-unused-vars
12
- var hotCurrentParents = []; // eslint-disable-line no-unused-vars
13
- var hotCurrentParentsTemp = []; // eslint-disable-line no-unused-vars
14
-
15
- // eslint-disable-next-line no-unused-vars
16
- function hotCreateRequire(moduleId) {
17
- var me = installedModules[moduleId];
18
- if (!me) return $require$;
19
- var fn = function(request) {
20
- if (me.hot.active) {
21
- if (installedModules[request]) {
22
- if (!installedModules[request].parents.includes(moduleId))
23
- installedModules[request].parents.push(moduleId);
24
- } else {
25
- hotCurrentParents = [moduleId];
26
- hotCurrentChildModule = request;
27
- }
28
- if (!me.children.includes(request)) me.children.push(request);
29
- } else {
30
- console.warn(
31
- "[HMR] unexpected require(" +
32
- request +
33
- ") from disposed module " +
34
- moduleId
35
- );
36
- hotCurrentParents = [];
37
- }
38
- return $require$(request);
39
- };
40
- var ObjectFactory = function ObjectFactory(name) {
41
- return {
42
- configurable: true,
43
- enumerable: true,
44
- get: function() {
45
- return $require$[name];
46
- },
47
- set: function(value) {
48
- $require$[name] = value;
49
- }
50
- };
51
- };
52
- for (var name in $require$) {
53
- if (
54
- Object.prototype.hasOwnProperty.call($require$, name) &&
55
- name !== "e"
56
- ) {
57
- Object.defineProperty(fn, name, ObjectFactory(name));
58
- }
59
- }
60
- fn.e = function(chunkId) {
61
- if (hotStatus === "ready") hotSetStatus("prepare");
62
- hotChunksLoading++;
63
- return $require$.e(chunkId).then(finishChunkLoading, function(err) {
64
- finishChunkLoading();
65
- throw err;
66
- });
67
-
68
- function finishChunkLoading() {
69
- hotChunksLoading--;
70
- if (hotStatus === "prepare") {
71
- if (!hotWaitingFilesMap[chunkId]) {
72
- hotEnsureUpdateChunk(chunkId);
73
- }
74
- if (hotChunksLoading === 0 && hotWaitingFiles === 0) {
75
- hotUpdateDownloaded();
76
- }
77
- }
78
- }
79
- };
80
- return fn;
81
- }
82
-
83
- // eslint-disable-next-line no-unused-vars
84
- function hotCreateModule(moduleId) {
85
- var hot = {
86
- // private stuff
87
- _acceptedDependencies: {},
88
- _declinedDependencies: {},
89
- _selfAccepted: false,
90
- _selfDeclined: false,
91
- _disposeHandlers: [],
92
- _main: hotCurrentChildModule !== moduleId,
93
-
94
- // Module API
95
- active: true,
96
- accept: function(dep, callback) {
97
- if (typeof dep === "undefined") hot._selfAccepted = true;
98
- else if (typeof dep === "function") hot._selfAccepted = dep;
99
- else if (typeof dep === "object")
100
- for (var i = 0; i < dep.length; i++)
101
- hot._acceptedDependencies[dep[i]] = callback || function() {};
102
- else hot._acceptedDependencies[dep] = callback || function() {};
103
- },
104
- decline: function(dep) {
105
- if (typeof dep === "undefined") hot._selfDeclined = true;
106
- else if (typeof dep === "object")
107
- for (var i = 0; i < dep.length; i++)
108
- hot._declinedDependencies[dep[i]] = true;
109
- else hot._declinedDependencies[dep] = true;
110
- },
111
- dispose: function(callback) {
112
- hot._disposeHandlers.push(callback);
113
- },
114
- addDisposeHandler: function(callback) {
115
- hot._disposeHandlers.push(callback);
116
- },
117
- removeDisposeHandler: function(callback) {
118
- var idx = hot._disposeHandlers.indexOf(callback);
119
- if (idx >= 0) hot._disposeHandlers.splice(idx, 1);
120
- },
121
-
122
- // Management API
123
- check: hotCheck,
124
- apply: hotApply,
125
- status: function(l) {
126
- if (!l) return hotStatus;
127
- hotStatusHandlers.push(l);
128
- },
129
- addStatusHandler: function(l) {
130
- hotStatusHandlers.push(l);
131
- },
132
- removeStatusHandler: function(l) {
133
- var idx = hotStatusHandlers.indexOf(l);
134
- if (idx >= 0) hotStatusHandlers.splice(idx, 1);
135
- },
136
-
137
- //inherit from previous dispose call
138
- data: hotCurrentModuleData[moduleId]
139
- };
140
- hotCurrentChildModule = undefined;
141
- return hot;
142
- }
143
-
144
- var hotStatusHandlers = [];
145
- var hotStatus = "idle";
146
-
147
- function hotSetStatus(newStatus) {
148
- hotStatus = newStatus;
149
- for (var i = 0; i < hotStatusHandlers.length; i++)
150
- hotStatusHandlers[i].call(null, newStatus);
151
- }
152
-
153
- // while downloading
154
- var hotWaitingFiles = 0;
155
- var hotChunksLoading = 0;
156
- var hotWaitingFilesMap = {};
157
- var hotRequestedFilesMap = {};
158
- var hotAvailableFilesMap = {};
159
- var hotDeferred;
160
-
161
- // The update info
162
- var hotUpdate, hotUpdateNewHash;
163
-
164
- function toModuleId(id) {
165
- var isNumber = +id + "" === id;
166
- return isNumber ? +id : id;
167
- }
168
-
169
- function hotCheck(apply) {
170
- if (hotStatus !== "idle")
171
- throw new Error("check() is only allowed in idle status");
172
- hotApplyOnUpdate = apply;
173
- hotSetStatus("check");
174
- return hotDownloadManifest(hotRequestTimeout).then(function(update) {
175
- if (!update) {
176
- hotSetStatus("idle");
177
- return null;
178
- }
179
- hotRequestedFilesMap = {};
180
- hotWaitingFilesMap = {};
181
- hotAvailableFilesMap = update.c;
182
- hotUpdateNewHash = update.h;
183
-
184
- hotSetStatus("prepare");
185
- var promise = new Promise(function(resolve, reject) {
186
- hotDeferred = {
187
- resolve: resolve,
188
- reject: reject
189
- };
190
- });
191
- hotUpdate = {};
192
- /*foreachInstalledChunks*/
193
- {
194
- // eslint-disable-line no-lone-blocks
195
- /*globals chunkId */
196
- hotEnsureUpdateChunk(chunkId);
197
- }
198
- if (
199
- hotStatus === "prepare" &&
200
- hotChunksLoading === 0 &&
201
- hotWaitingFiles === 0
202
- ) {
203
- hotUpdateDownloaded();
204
- }
205
- return promise;
206
- });
207
- }
208
-
209
- // eslint-disable-next-line no-unused-vars
210
- function hotAddUpdateChunk(chunkId, moreModules) {
211
- if (!hotAvailableFilesMap[chunkId] || !hotRequestedFilesMap[chunkId])
212
- return;
213
- hotRequestedFilesMap[chunkId] = false;
214
- for (var moduleId in moreModules) {
215
- if (Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
216
- hotUpdate[moduleId] = moreModules[moduleId];
217
- }
218
- }
219
- if (--hotWaitingFiles === 0 && hotChunksLoading === 0) {
220
- hotUpdateDownloaded();
221
- }
222
- }
223
-
224
- function hotEnsureUpdateChunk(chunkId) {
225
- if (!hotAvailableFilesMap[chunkId]) {
226
- hotWaitingFilesMap[chunkId] = true;
227
- } else {
228
- hotRequestedFilesMap[chunkId] = true;
229
- hotWaitingFiles++;
230
- hotDownloadUpdateChunk(chunkId);
231
- }
232
- }
233
-
234
- function hotUpdateDownloaded() {
235
- hotSetStatus("ready");
236
- var deferred = hotDeferred;
237
- hotDeferred = null;
238
- if (!deferred) return;
239
- if (hotApplyOnUpdate) {
240
- // Wrap deferred object in Promise to mark it as a well-handled Promise to
241
- // avoid triggering uncaught exception warning in Chrome.
242
- // See https://bugs.chromium.org/p/chromium/issues/detail?id=465666
243
- Promise.resolve()
244
- .then(function() {
245
- return hotApply(hotApplyOnUpdate);
246
- })
247
- .then(
248
- function(result) {
249
- deferred.resolve(result);
250
- },
251
- function(err) {
252
- deferred.reject(err);
253
- }
254
- );
255
- } else {
256
- var outdatedModules = [];
257
- for (var id in hotUpdate) {
258
- if (Object.prototype.hasOwnProperty.call(hotUpdate, id)) {
259
- outdatedModules.push(toModuleId(id));
260
- }
261
- }
262
- deferred.resolve(outdatedModules);
263
- }
264
- }
265
-
266
- function hotApply(options) {
267
- if (hotStatus !== "ready")
268
- throw new Error("apply() is only allowed in ready status");
269
- options = options || {};
270
-
271
- var cb;
272
- var i;
273
- var j;
274
- var module;
275
- var moduleId;
276
-
277
- function getAffectedStuff(updateModuleId) {
278
- var outdatedModules = [updateModuleId];
279
- var outdatedDependencies = {};
280
-
281
- var queue = outdatedModules.slice().map(function(id) {
282
- return {
283
- chain: [id],
284
- id: id
285
- };
286
- });
287
- while (queue.length > 0) {
288
- var queueItem = queue.pop();
289
- var moduleId = queueItem.id;
290
- var chain = queueItem.chain;
291
- module = installedModules[moduleId];
292
- if (!module || module.hot._selfAccepted) continue;
293
- if (module.hot._selfDeclined) {
294
- return {
295
- type: "self-declined",
296
- chain: chain,
297
- moduleId: moduleId
298
- };
299
- }
300
- if (module.hot._main) {
301
- return {
302
- type: "unaccepted",
303
- chain: chain,
304
- moduleId: moduleId
305
- };
306
- }
307
- for (var i = 0; i < module.parents.length; i++) {
308
- var parentId = module.parents[i];
309
- var parent = installedModules[parentId];
310
- if (!parent) continue;
311
- if (parent.hot._declinedDependencies[moduleId]) {
312
- return {
313
- type: "declined",
314
- chain: chain.concat([parentId]),
315
- moduleId: moduleId,
316
- parentId: parentId
317
- };
318
- }
319
- if (outdatedModules.includes(parentId)) continue;
320
- if (parent.hot._acceptedDependencies[moduleId]) {
321
- if (!outdatedDependencies[parentId])
322
- outdatedDependencies[parentId] = [];
323
- addAllToSet(outdatedDependencies[parentId], [moduleId]);
324
- continue;
325
- }
326
- delete outdatedDependencies[parentId];
327
- outdatedModules.push(parentId);
328
- queue.push({
329
- chain: chain.concat([parentId]),
330
- id: parentId
331
- });
332
- }
333
- }
334
-
335
- return {
336
- type: "accepted",
337
- moduleId: updateModuleId,
338
- outdatedModules: outdatedModules,
339
- outdatedDependencies: outdatedDependencies
340
- };
341
- }
342
-
343
- function addAllToSet(a, b) {
344
- for (var i = 0; i < b.length; i++) {
345
- var item = b[i];
346
- if (!a.includes(item)) a.push(item);
347
- }
348
- }
349
-
350
- // at begin all updates modules are outdated
351
- // the "outdated" status can propagate to parents if they don't accept the children
352
- var outdatedDependencies = {};
353
- var outdatedModules = [];
354
- var appliedUpdate = {};
355
-
356
- var warnUnexpectedRequire = function warnUnexpectedRequire() {
357
- console.warn(
358
- "[HMR] unexpected require(" + result.moduleId + ") to disposed module"
359
- );
360
- };
361
-
362
- for (var id in hotUpdate) {
363
- if (Object.prototype.hasOwnProperty.call(hotUpdate, id)) {
364
- moduleId = toModuleId(id);
365
- var result;
366
- if (hotUpdate[id]) {
367
- result = getAffectedStuff(moduleId);
368
- } else {
369
- result = {
370
- type: "disposed",
371
- moduleId: id
372
- };
373
- }
374
- var abortError = false;
375
- var doApply = false;
376
- var doDispose = false;
377
- var chainInfo = "";
378
- if (result.chain) {
379
- chainInfo = "\nUpdate propagation: " + result.chain.join(" -> ");
380
- }
381
- switch (result.type) {
382
- case "self-declined":
383
- if (options.onDeclined) options.onDeclined(result);
384
- if (!options.ignoreDeclined)
385
- abortError = new Error(
386
- "Aborted because of self decline: " +
387
- result.moduleId +
388
- chainInfo
389
- );
390
- break;
391
- case "declined":
392
- if (options.onDeclined) options.onDeclined(result);
393
- if (!options.ignoreDeclined)
394
- abortError = new Error(
395
- "Aborted because of declined dependency: " +
396
- result.moduleId +
397
- " in " +
398
- result.parentId +
399
- chainInfo
400
- );
401
- break;
402
- case "unaccepted":
403
- if (options.onUnaccepted) options.onUnaccepted(result);
404
- if (!options.ignoreUnaccepted)
405
- abortError = new Error(
406
- "Aborted because " + moduleId + " is not accepted" + chainInfo
407
- );
408
- break;
409
- case "accepted":
410
- if (options.onAccepted) options.onAccepted(result);
411
- doApply = true;
412
- break;
413
- case "disposed":
414
- if (options.onDisposed) options.onDisposed(result);
415
- doDispose = true;
416
- break;
417
- default:
418
- throw new Error("Unexception type " + result.type);
419
- }
420
- if (abortError) {
421
- hotSetStatus("abort");
422
- return Promise.reject(abortError);
423
- }
424
- if (doApply) {
425
- appliedUpdate[moduleId] = hotUpdate[moduleId];
426
- addAllToSet(outdatedModules, result.outdatedModules);
427
- for (moduleId in result.outdatedDependencies) {
428
- if (
429
- Object.prototype.hasOwnProperty.call(
430
- result.outdatedDependencies,
431
- moduleId
432
- )
433
- ) {
434
- if (!outdatedDependencies[moduleId])
435
- outdatedDependencies[moduleId] = [];
436
- addAllToSet(
437
- outdatedDependencies[moduleId],
438
- result.outdatedDependencies[moduleId]
439
- );
440
- }
441
- }
442
- }
443
- if (doDispose) {
444
- addAllToSet(outdatedModules, [result.moduleId]);
445
- appliedUpdate[moduleId] = warnUnexpectedRequire;
446
- }
447
- }
448
- }
449
-
450
- // Store self accepted outdated modules to require them later by the module system
451
- var outdatedSelfAcceptedModules = [];
452
- for (i = 0; i < outdatedModules.length; i++) {
453
- moduleId = outdatedModules[i];
454
- if (
455
- installedModules[moduleId] &&
456
- installedModules[moduleId].hot._selfAccepted
457
- )
458
- outdatedSelfAcceptedModules.push({
459
- module: moduleId,
460
- errorHandler: installedModules[moduleId].hot._selfAccepted
461
- });
462
- }
463
-
464
- // Now in "dispose" phase
465
- hotSetStatus("dispose");
466
- Object.keys(hotAvailableFilesMap).forEach(function(chunkId) {
467
- if (hotAvailableFilesMap[chunkId] === false) {
468
- hotDisposeChunk(chunkId);
469
- }
470
- });
471
-
472
- var idx;
473
- var queue = outdatedModules.slice();
474
- while (queue.length > 0) {
475
- moduleId = queue.pop();
476
- module = installedModules[moduleId];
477
- if (!module) continue;
478
-
479
- var data = {};
480
-
481
- // Call dispose handlers
482
- var disposeHandlers = module.hot._disposeHandlers;
483
- for (j = 0; j < disposeHandlers.length; j++) {
484
- cb = disposeHandlers[j];
485
- cb(data);
486
- }
487
- hotCurrentModuleData[moduleId] = data;
488
-
489
- // disable module (this disables requires from this module)
490
- module.hot.active = false;
491
-
492
- // remove module from cache
493
- delete installedModules[moduleId];
494
-
495
- // when disposing there is no need to call dispose handler
496
- delete outdatedDependencies[moduleId];
497
-
498
- // remove "parents" references from all children
499
- for (j = 0; j < module.children.length; j++) {
500
- var child = installedModules[module.children[j]];
501
- if (!child) continue;
502
- idx = child.parents.indexOf(moduleId);
503
- if (idx >= 0) {
504
- child.parents.splice(idx, 1);
505
- }
506
- }
507
- }
508
-
509
- // remove outdated dependency from module children
510
- var dependency;
511
- var moduleOutdatedDependencies;
512
- for (moduleId in outdatedDependencies) {
513
- if (
514
- Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)
515
- ) {
516
- module = installedModules[moduleId];
517
- if (module) {
518
- moduleOutdatedDependencies = outdatedDependencies[moduleId];
519
- for (j = 0; j < moduleOutdatedDependencies.length; j++) {
520
- dependency = moduleOutdatedDependencies[j];
521
- idx = module.children.indexOf(dependency);
522
- if (idx >= 0) module.children.splice(idx, 1);
523
- }
524
- }
525
- }
526
- }
527
-
528
- // Not in "apply" phase
529
- hotSetStatus("apply");
530
-
531
- hotCurrentHash = hotUpdateNewHash;
532
-
533
- // insert new code
534
- for (moduleId in appliedUpdate) {
535
- if (Object.prototype.hasOwnProperty.call(appliedUpdate, moduleId)) {
536
- modules[moduleId] = appliedUpdate[moduleId];
537
- }
538
- }
539
-
540
- // call accept handlers
541
- var error = null;
542
- for (moduleId in outdatedDependencies) {
543
- if (
544
- Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)
545
- ) {
546
- module = installedModules[moduleId];
547
- if (module) {
548
- moduleOutdatedDependencies = outdatedDependencies[moduleId];
549
- var callbacks = [];
550
- for (i = 0; i < moduleOutdatedDependencies.length; i++) {
551
- dependency = moduleOutdatedDependencies[i];
552
- cb = module.hot._acceptedDependencies[dependency];
553
- if (cb) {
554
- if (callbacks.includes(cb)) continue;
555
- callbacks.push(cb);
556
- }
557
- }
558
- for (i = 0; i < callbacks.length; i++) {
559
- cb = callbacks[i];
560
- try {
561
- cb(moduleOutdatedDependencies);
562
- } catch (err) {
563
- if (options.onErrored) {
564
- options.onErrored({
565
- type: "accept-errored",
566
- moduleId: moduleId,
567
- dependencyId: moduleOutdatedDependencies[i],
568
- error: err
569
- });
570
- }
571
- if (!options.ignoreErrored) {
572
- if (!error) error = err;
573
- }
574
- }
575
- }
576
- }
577
- }
578
- }
579
-
580
- // Load self accepted modules
581
- for (i = 0; i < outdatedSelfAcceptedModules.length; i++) {
582
- var item = outdatedSelfAcceptedModules[i];
583
- moduleId = item.module;
584
- hotCurrentParents = [moduleId];
585
- try {
586
- $require$(moduleId);
587
- } catch (err) {
588
- if (typeof item.errorHandler === "function") {
589
- try {
590
- item.errorHandler(err);
591
- } catch (err2) {
592
- if (options.onErrored) {
593
- options.onErrored({
594
- type: "self-accept-error-handler-errored",
595
- moduleId: moduleId,
596
- error: err2,
597
- originalError: err
598
- });
599
- }
600
- if (!options.ignoreErrored) {
601
- if (!error) error = err2;
602
- }
603
- if (!error) error = err;
604
- }
605
- } else {
606
- if (options.onErrored) {
607
- options.onErrored({
608
- type: "self-accept-errored",
609
- moduleId: moduleId,
610
- error: err
611
- });
612
- }
613
- if (!options.ignoreErrored) {
614
- if (!error) error = err;
615
- }
616
- }
617
- }
618
- }
619
-
620
- // handle errors in accept handlers and self accepted module load
621
- if (error) {
622
- hotSetStatus("fail");
623
- return Promise.reject(error);
624
- }
625
-
626
- hotSetStatus("idle");
627
- return new Promise(function(resolve) {
628
- resolve(outdatedModules);
629
- });
630
- }
631
- };
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+ /*global $hash$ $requestTimeout$ installedModules $require$ hotDownloadManifest hotDownloadUpdateChunk hotDisposeChunk modules */
6
+ module.exports = function() {
7
+ var hotApplyOnUpdate = true;
8
+ var hotCurrentHash = $hash$; // eslint-disable-line no-unused-vars
9
+ var hotRequestTimeout = $requestTimeout$;
10
+ var hotCurrentModuleData = {};
11
+ var hotCurrentChildModule; // eslint-disable-line no-unused-vars
12
+ var hotCurrentParents = []; // eslint-disable-line no-unused-vars
13
+ var hotCurrentParentsTemp = []; // eslint-disable-line no-unused-vars
14
+
15
+ // eslint-disable-next-line no-unused-vars
16
+ function hotCreateRequire(moduleId) {
17
+ var me = installedModules[moduleId];
18
+ if (!me) return $require$;
19
+ var fn = function(request) {
20
+ if (me.hot.active) {
21
+ if (installedModules[request]) {
22
+ if (installedModules[request].parents.indexOf(moduleId) === -1)
23
+ installedModules[request].parents.push(moduleId);
24
+ } else {
25
+ hotCurrentParents = [moduleId];
26
+ hotCurrentChildModule = request;
27
+ }
28
+ if (me.children.indexOf(request) === -1) me.children.push(request);
29
+ } else {
30
+ console.warn(
31
+ "[HMR] unexpected require(" +
32
+ request +
33
+ ") from disposed module " +
34
+ moduleId
35
+ );
36
+ hotCurrentParents = [];
37
+ }
38
+ return $require$(request);
39
+ };
40
+ var ObjectFactory = function ObjectFactory(name) {
41
+ return {
42
+ configurable: true,
43
+ enumerable: true,
44
+ get: function() {
45
+ return $require$[name];
46
+ },
47
+ set: function(value) {
48
+ $require$[name] = value;
49
+ }
50
+ };
51
+ };
52
+ for (var name in $require$) {
53
+ if (
54
+ Object.prototype.hasOwnProperty.call($require$, name) &&
55
+ name !== "e"
56
+ ) {
57
+ Object.defineProperty(fn, name, ObjectFactory(name));
58
+ }
59
+ }
60
+ fn.e = function(chunkId) {
61
+ if (hotStatus === "ready") hotSetStatus("prepare");
62
+ hotChunksLoading++;
63
+ return $require$.e(chunkId).then(finishChunkLoading, function(err) {
64
+ finishChunkLoading();
65
+ throw err;
66
+ });
67
+
68
+ function finishChunkLoading() {
69
+ hotChunksLoading--;
70
+ if (hotStatus === "prepare") {
71
+ if (!hotWaitingFilesMap[chunkId]) {
72
+ hotEnsureUpdateChunk(chunkId);
73
+ }
74
+ if (hotChunksLoading === 0 && hotWaitingFiles === 0) {
75
+ hotUpdateDownloaded();
76
+ }
77
+ }
78
+ }
79
+ };
80
+ return fn;
81
+ }
82
+
83
+ // eslint-disable-next-line no-unused-vars
84
+ function hotCreateModule(moduleId) {
85
+ var hot = {
86
+ // private stuff
87
+ _acceptedDependencies: {},
88
+ _declinedDependencies: {},
89
+ _selfAccepted: false,
90
+ _selfDeclined: false,
91
+ _disposeHandlers: [],
92
+ _main: hotCurrentChildModule !== moduleId,
93
+
94
+ // Module API
95
+ active: true,
96
+ accept: function(dep, callback) {
97
+ if (typeof dep === "undefined") hot._selfAccepted = true;
98
+ else if (typeof dep === "function") hot._selfAccepted = dep;
99
+ else if (typeof dep === "object")
100
+ for (var i = 0; i < dep.length; i++)
101
+ hot._acceptedDependencies[dep[i]] = callback || function() {};
102
+ else hot._acceptedDependencies[dep] = callback || function() {};
103
+ },
104
+ decline: function(dep) {
105
+ if (typeof dep === "undefined") hot._selfDeclined = true;
106
+ else if (typeof dep === "object")
107
+ for (var i = 0; i < dep.length; i++)
108
+ hot._declinedDependencies[dep[i]] = true;
109
+ else hot._declinedDependencies[dep] = true;
110
+ },
111
+ dispose: function(callback) {
112
+ hot._disposeHandlers.push(callback);
113
+ },
114
+ addDisposeHandler: function(callback) {
115
+ hot._disposeHandlers.push(callback);
116
+ },
117
+ removeDisposeHandler: function(callback) {
118
+ var idx = hot._disposeHandlers.indexOf(callback);
119
+ if (idx >= 0) hot._disposeHandlers.splice(idx, 1);
120
+ },
121
+
122
+ // Management API
123
+ check: hotCheck,
124
+ apply: hotApply,
125
+ status: function(l) {
126
+ if (!l) return hotStatus;
127
+ hotStatusHandlers.push(l);
128
+ },
129
+ addStatusHandler: function(l) {
130
+ hotStatusHandlers.push(l);
131
+ },
132
+ removeStatusHandler: function(l) {
133
+ var idx = hotStatusHandlers.indexOf(l);
134
+ if (idx >= 0) hotStatusHandlers.splice(idx, 1);
135
+ },
136
+
137
+ //inherit from previous dispose call
138
+ data: hotCurrentModuleData[moduleId]
139
+ };
140
+ hotCurrentChildModule = undefined;
141
+ return hot;
142
+ }
143
+
144
+ var hotStatusHandlers = [];
145
+ var hotStatus = "idle";
146
+
147
+ function hotSetStatus(newStatus) {
148
+ hotStatus = newStatus;
149
+ for (var i = 0; i < hotStatusHandlers.length; i++)
150
+ hotStatusHandlers[i].call(null, newStatus);
151
+ }
152
+
153
+ // while downloading
154
+ var hotWaitingFiles = 0;
155
+ var hotChunksLoading = 0;
156
+ var hotWaitingFilesMap = {};
157
+ var hotRequestedFilesMap = {};
158
+ var hotAvailableFilesMap = {};
159
+ var hotDeferred;
160
+
161
+ // The update info
162
+ var hotUpdate, hotUpdateNewHash;
163
+
164
+ function toModuleId(id) {
165
+ var isNumber = +id + "" === id;
166
+ return isNumber ? +id : id;
167
+ }
168
+
169
+ function hotCheck(apply) {
170
+ if (hotStatus !== "idle")
171
+ throw new Error("check() is only allowed in idle status");
172
+ hotApplyOnUpdate = apply;
173
+ hotSetStatus("check");
174
+ return hotDownloadManifest(hotRequestTimeout).then(function(update) {
175
+ if (!update) {
176
+ hotSetStatus("idle");
177
+ return null;
178
+ }
179
+ hotRequestedFilesMap = {};
180
+ hotWaitingFilesMap = {};
181
+ hotAvailableFilesMap = update.c;
182
+ hotUpdateNewHash = update.h;
183
+
184
+ hotSetStatus("prepare");
185
+ var promise = new Promise(function(resolve, reject) {
186
+ hotDeferred = {
187
+ resolve: resolve,
188
+ reject: reject
189
+ };
190
+ });
191
+ hotUpdate = {};
192
+ /*foreachInstalledChunks*/
193
+ {
194
+ // eslint-disable-line no-lone-blocks
195
+ /*globals chunkId */
196
+ hotEnsureUpdateChunk(chunkId);
197
+ }
198
+ if (
199
+ hotStatus === "prepare" &&
200
+ hotChunksLoading === 0 &&
201
+ hotWaitingFiles === 0
202
+ ) {
203
+ hotUpdateDownloaded();
204
+ }
205
+ return promise;
206
+ });
207
+ }
208
+
209
+ // eslint-disable-next-line no-unused-vars
210
+ function hotAddUpdateChunk(chunkId, moreModules) {
211
+ if (!hotAvailableFilesMap[chunkId] || !hotRequestedFilesMap[chunkId])
212
+ return;
213
+ hotRequestedFilesMap[chunkId] = false;
214
+ for (var moduleId in moreModules) {
215
+ if (Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
216
+ hotUpdate[moduleId] = moreModules[moduleId];
217
+ }
218
+ }
219
+ if (--hotWaitingFiles === 0 && hotChunksLoading === 0) {
220
+ hotUpdateDownloaded();
221
+ }
222
+ }
223
+
224
+ function hotEnsureUpdateChunk(chunkId) {
225
+ if (!hotAvailableFilesMap[chunkId]) {
226
+ hotWaitingFilesMap[chunkId] = true;
227
+ } else {
228
+ hotRequestedFilesMap[chunkId] = true;
229
+ hotWaitingFiles++;
230
+ hotDownloadUpdateChunk(chunkId);
231
+ }
232
+ }
233
+
234
+ function hotUpdateDownloaded() {
235
+ hotSetStatus("ready");
236
+ var deferred = hotDeferred;
237
+ hotDeferred = null;
238
+ if (!deferred) return;
239
+ if (hotApplyOnUpdate) {
240
+ // Wrap deferred object in Promise to mark it as a well-handled Promise to
241
+ // avoid triggering uncaught exception warning in Chrome.
242
+ // See https://bugs.chromium.org/p/chromium/issues/detail?id=465666
243
+ Promise.resolve()
244
+ .then(function() {
245
+ return hotApply(hotApplyOnUpdate);
246
+ })
247
+ .then(
248
+ function(result) {
249
+ deferred.resolve(result);
250
+ },
251
+ function(err) {
252
+ deferred.reject(err);
253
+ }
254
+ );
255
+ } else {
256
+ var outdatedModules = [];
257
+ for (var id in hotUpdate) {
258
+ if (Object.prototype.hasOwnProperty.call(hotUpdate, id)) {
259
+ outdatedModules.push(toModuleId(id));
260
+ }
261
+ }
262
+ deferred.resolve(outdatedModules);
263
+ }
264
+ }
265
+
266
+ function hotApply(options) {
267
+ if (hotStatus !== "ready")
268
+ throw new Error("apply() is only allowed in ready status");
269
+ options = options || {};
270
+
271
+ var cb;
272
+ var i;
273
+ var j;
274
+ var module;
275
+ var moduleId;
276
+
277
+ function getAffectedStuff(updateModuleId) {
278
+ var outdatedModules = [updateModuleId];
279
+ var outdatedDependencies = {};
280
+
281
+ var queue = outdatedModules.slice().map(function(id) {
282
+ return {
283
+ chain: [id],
284
+ id: id
285
+ };
286
+ });
287
+ while (queue.length > 0) {
288
+ var queueItem = queue.pop();
289
+ var moduleId = queueItem.id;
290
+ var chain = queueItem.chain;
291
+ module = installedModules[moduleId];
292
+ if (!module || module.hot._selfAccepted) continue;
293
+ if (module.hot._selfDeclined) {
294
+ return {
295
+ type: "self-declined",
296
+ chain: chain,
297
+ moduleId: moduleId
298
+ };
299
+ }
300
+ if (module.hot._main) {
301
+ return {
302
+ type: "unaccepted",
303
+ chain: chain,
304
+ moduleId: moduleId
305
+ };
306
+ }
307
+ for (var i = 0; i < module.parents.length; i++) {
308
+ var parentId = module.parents[i];
309
+ var parent = installedModules[parentId];
310
+ if (!parent) continue;
311
+ if (parent.hot._declinedDependencies[moduleId]) {
312
+ return {
313
+ type: "declined",
314
+ chain: chain.concat([parentId]),
315
+ moduleId: moduleId,
316
+ parentId: parentId
317
+ };
318
+ }
319
+ if (outdatedModules.indexOf(parentId) !== -1) continue;
320
+ if (parent.hot._acceptedDependencies[moduleId]) {
321
+ if (!outdatedDependencies[parentId])
322
+ outdatedDependencies[parentId] = [];
323
+ addAllToSet(outdatedDependencies[parentId], [moduleId]);
324
+ continue;
325
+ }
326
+ delete outdatedDependencies[parentId];
327
+ outdatedModules.push(parentId);
328
+ queue.push({
329
+ chain: chain.concat([parentId]),
330
+ id: parentId
331
+ });
332
+ }
333
+ }
334
+
335
+ return {
336
+ type: "accepted",
337
+ moduleId: updateModuleId,
338
+ outdatedModules: outdatedModules,
339
+ outdatedDependencies: outdatedDependencies
340
+ };
341
+ }
342
+
343
+ function addAllToSet(a, b) {
344
+ for (var i = 0; i < b.length; i++) {
345
+ var item = b[i];
346
+ if (a.indexOf(item) === -1) a.push(item);
347
+ }
348
+ }
349
+
350
+ // at begin all updates modules are outdated
351
+ // the "outdated" status can propagate to parents if they don't accept the children
352
+ var outdatedDependencies = {};
353
+ var outdatedModules = [];
354
+ var appliedUpdate = {};
355
+
356
+ var warnUnexpectedRequire = function warnUnexpectedRequire() {
357
+ console.warn(
358
+ "[HMR] unexpected require(" + result.moduleId + ") to disposed module"
359
+ );
360
+ };
361
+
362
+ for (var id in hotUpdate) {
363
+ if (Object.prototype.hasOwnProperty.call(hotUpdate, id)) {
364
+ moduleId = toModuleId(id);
365
+ var result;
366
+ if (hotUpdate[id]) {
367
+ result = getAffectedStuff(moduleId);
368
+ } else {
369
+ result = {
370
+ type: "disposed",
371
+ moduleId: id
372
+ };
373
+ }
374
+ var abortError = false;
375
+ var doApply = false;
376
+ var doDispose = false;
377
+ var chainInfo = "";
378
+ if (result.chain) {
379
+ chainInfo = "\nUpdate propagation: " + result.chain.join(" -> ");
380
+ }
381
+ switch (result.type) {
382
+ case "self-declined":
383
+ if (options.onDeclined) options.onDeclined(result);
384
+ if (!options.ignoreDeclined)
385
+ abortError = new Error(
386
+ "Aborted because of self decline: " +
387
+ result.moduleId +
388
+ chainInfo
389
+ );
390
+ break;
391
+ case "declined":
392
+ if (options.onDeclined) options.onDeclined(result);
393
+ if (!options.ignoreDeclined)
394
+ abortError = new Error(
395
+ "Aborted because of declined dependency: " +
396
+ result.moduleId +
397
+ " in " +
398
+ result.parentId +
399
+ chainInfo
400
+ );
401
+ break;
402
+ case "unaccepted":
403
+ if (options.onUnaccepted) options.onUnaccepted(result);
404
+ if (!options.ignoreUnaccepted)
405
+ abortError = new Error(
406
+ "Aborted because " + moduleId + " is not accepted" + chainInfo
407
+ );
408
+ break;
409
+ case "accepted":
410
+ if (options.onAccepted) options.onAccepted(result);
411
+ doApply = true;
412
+ break;
413
+ case "disposed":
414
+ if (options.onDisposed) options.onDisposed(result);
415
+ doDispose = true;
416
+ break;
417
+ default:
418
+ throw new Error("Unexception type " + result.type);
419
+ }
420
+ if (abortError) {
421
+ hotSetStatus("abort");
422
+ return Promise.reject(abortError);
423
+ }
424
+ if (doApply) {
425
+ appliedUpdate[moduleId] = hotUpdate[moduleId];
426
+ addAllToSet(outdatedModules, result.outdatedModules);
427
+ for (moduleId in result.outdatedDependencies) {
428
+ if (
429
+ Object.prototype.hasOwnProperty.call(
430
+ result.outdatedDependencies,
431
+ moduleId
432
+ )
433
+ ) {
434
+ if (!outdatedDependencies[moduleId])
435
+ outdatedDependencies[moduleId] = [];
436
+ addAllToSet(
437
+ outdatedDependencies[moduleId],
438
+ result.outdatedDependencies[moduleId]
439
+ );
440
+ }
441
+ }
442
+ }
443
+ if (doDispose) {
444
+ addAllToSet(outdatedModules, [result.moduleId]);
445
+ appliedUpdate[moduleId] = warnUnexpectedRequire;
446
+ }
447
+ }
448
+ }
449
+
450
+ // Store self accepted outdated modules to require them later by the module system
451
+ var outdatedSelfAcceptedModules = [];
452
+ for (i = 0; i < outdatedModules.length; i++) {
453
+ moduleId = outdatedModules[i];
454
+ if (
455
+ installedModules[moduleId] &&
456
+ installedModules[moduleId].hot._selfAccepted
457
+ )
458
+ outdatedSelfAcceptedModules.push({
459
+ module: moduleId,
460
+ errorHandler: installedModules[moduleId].hot._selfAccepted
461
+ });
462
+ }
463
+
464
+ // Now in "dispose" phase
465
+ hotSetStatus("dispose");
466
+ Object.keys(hotAvailableFilesMap).forEach(function(chunkId) {
467
+ if (hotAvailableFilesMap[chunkId] === false) {
468
+ hotDisposeChunk(chunkId);
469
+ }
470
+ });
471
+
472
+ var idx;
473
+ var queue = outdatedModules.slice();
474
+ while (queue.length > 0) {
475
+ moduleId = queue.pop();
476
+ module = installedModules[moduleId];
477
+ if (!module) continue;
478
+
479
+ var data = {};
480
+
481
+ // Call dispose handlers
482
+ var disposeHandlers = module.hot._disposeHandlers;
483
+ for (j = 0; j < disposeHandlers.length; j++) {
484
+ cb = disposeHandlers[j];
485
+ cb(data);
486
+ }
487
+ hotCurrentModuleData[moduleId] = data;
488
+
489
+ // disable module (this disables requires from this module)
490
+ module.hot.active = false;
491
+
492
+ // remove module from cache
493
+ delete installedModules[moduleId];
494
+
495
+ // when disposing there is no need to call dispose handler
496
+ delete outdatedDependencies[moduleId];
497
+
498
+ // remove "parents" references from all children
499
+ for (j = 0; j < module.children.length; j++) {
500
+ var child = installedModules[module.children[j]];
501
+ if (!child) continue;
502
+ idx = child.parents.indexOf(moduleId);
503
+ if (idx >= 0) {
504
+ child.parents.splice(idx, 1);
505
+ }
506
+ }
507
+ }
508
+
509
+ // remove outdated dependency from module children
510
+ var dependency;
511
+ var moduleOutdatedDependencies;
512
+ for (moduleId in outdatedDependencies) {
513
+ if (
514
+ Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)
515
+ ) {
516
+ module = installedModules[moduleId];
517
+ if (module) {
518
+ moduleOutdatedDependencies = outdatedDependencies[moduleId];
519
+ for (j = 0; j < moduleOutdatedDependencies.length; j++) {
520
+ dependency = moduleOutdatedDependencies[j];
521
+ idx = module.children.indexOf(dependency);
522
+ if (idx >= 0) module.children.splice(idx, 1);
523
+ }
524
+ }
525
+ }
526
+ }
527
+
528
+ // Not in "apply" phase
529
+ hotSetStatus("apply");
530
+
531
+ hotCurrentHash = hotUpdateNewHash;
532
+
533
+ // insert new code
534
+ for (moduleId in appliedUpdate) {
535
+ if (Object.prototype.hasOwnProperty.call(appliedUpdate, moduleId)) {
536
+ modules[moduleId] = appliedUpdate[moduleId];
537
+ }
538
+ }
539
+
540
+ // call accept handlers
541
+ var error = null;
542
+ for (moduleId in outdatedDependencies) {
543
+ if (
544
+ Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)
545
+ ) {
546
+ module = installedModules[moduleId];
547
+ if (module) {
548
+ moduleOutdatedDependencies = outdatedDependencies[moduleId];
549
+ var callbacks = [];
550
+ for (i = 0; i < moduleOutdatedDependencies.length; i++) {
551
+ dependency = moduleOutdatedDependencies[i];
552
+ cb = module.hot._acceptedDependencies[dependency];
553
+ if (cb) {
554
+ if (callbacks.indexOf(cb) !== -1) continue;
555
+ callbacks.push(cb);
556
+ }
557
+ }
558
+ for (i = 0; i < callbacks.length; i++) {
559
+ cb = callbacks[i];
560
+ try {
561
+ cb(moduleOutdatedDependencies);
562
+ } catch (err) {
563
+ if (options.onErrored) {
564
+ options.onErrored({
565
+ type: "accept-errored",
566
+ moduleId: moduleId,
567
+ dependencyId: moduleOutdatedDependencies[i],
568
+ error: err
569
+ });
570
+ }
571
+ if (!options.ignoreErrored) {
572
+ if (!error) error = err;
573
+ }
574
+ }
575
+ }
576
+ }
577
+ }
578
+ }
579
+
580
+ // Load self accepted modules
581
+ for (i = 0; i < outdatedSelfAcceptedModules.length; i++) {
582
+ var item = outdatedSelfAcceptedModules[i];
583
+ moduleId = item.module;
584
+ hotCurrentParents = [moduleId];
585
+ try {
586
+ $require$(moduleId);
587
+ } catch (err) {
588
+ if (typeof item.errorHandler === "function") {
589
+ try {
590
+ item.errorHandler(err);
591
+ } catch (err2) {
592
+ if (options.onErrored) {
593
+ options.onErrored({
594
+ type: "self-accept-error-handler-errored",
595
+ moduleId: moduleId,
596
+ error: err2,
597
+ originalError: err
598
+ });
599
+ }
600
+ if (!options.ignoreErrored) {
601
+ if (!error) error = err2;
602
+ }
603
+ if (!error) error = err;
604
+ }
605
+ } else {
606
+ if (options.onErrored) {
607
+ options.onErrored({
608
+ type: "self-accept-errored",
609
+ moduleId: moduleId,
610
+ error: err
611
+ });
612
+ }
613
+ if (!options.ignoreErrored) {
614
+ if (!error) error = err;
615
+ }
616
+ }
617
+ }
618
+ }
619
+
620
+ // handle errors in accept handlers and self accepted module load
621
+ if (error) {
622
+ hotSetStatus("fail");
623
+ return Promise.reject(error);
624
+ }
625
+
626
+ hotSetStatus("idle");
627
+ return new Promise(function(resolve) {
628
+ resolve(outdatedModules);
629
+ });
630
+ }
631
+ };