@umijs/bundler-webpack 4.7.7 → 4.7.8

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.
@@ -1,463 +0,0 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Tobias Koppers @sokra
4
- */
5
-
6
- "use strict";
7
-
8
- var $installedChunks$ = undefined;
9
- var $loadUpdateChunk$ = undefined;
10
- var $moduleCache$ = undefined;
11
- var $moduleFactories$ = undefined;
12
- var $ensureChunkHandlers$ = undefined;
13
- var $hasOwnProperty$ = undefined;
14
- var $hmrModuleData$ = undefined;
15
- var $hmrDownloadUpdateHandlers$ = undefined;
16
- var $hmrInvalidateModuleHandlers$ = undefined;
17
- var __webpack_require__ = undefined;
18
-
19
- module.exports = function () {
20
- var currentUpdateChunks;
21
- var currentUpdate;
22
- var currentUpdateRemovedChunks;
23
- var currentUpdateRuntime;
24
- function applyHandler(options) {
25
- if ($ensureChunkHandlers$) delete $ensureChunkHandlers$.$key$Hmr;
26
- currentUpdateChunks = undefined;
27
- function getAffectedModuleEffects(updateModuleId) {
28
- var outdatedModules = [updateModuleId];
29
- var outdatedDependencies = {};
30
-
31
- var queue = outdatedModules.map(function (id) {
32
- return {
33
- chain: [id],
34
- id: id
35
- };
36
- });
37
- while (queue.length > 0) {
38
- var queueItem = queue.pop();
39
- var moduleId = queueItem.id;
40
- var chain = queueItem.chain;
41
- var module = $moduleCache$[moduleId];
42
- if (
43
- !module ||
44
- (module.hot._selfAccepted && !module.hot._selfInvalidated)
45
- )
46
- continue;
47
- if (module.hot._selfDeclined) {
48
- return {
49
- type: "self-declined",
50
- chain: chain,
51
- moduleId: moduleId
52
- };
53
- }
54
- if (module.hot._main) {
55
- return {
56
- type: "unaccepted",
57
- chain: chain,
58
- moduleId: moduleId
59
- };
60
- }
61
- for (var i = 0; i < module.parents.length; i++) {
62
- var parentId = module.parents[i];
63
- var parent = $moduleCache$[parentId];
64
- if (!parent) continue;
65
- if (parent.hot._declinedDependencies[moduleId]) {
66
- return {
67
- type: "declined",
68
- chain: chain.concat([parentId]),
69
- moduleId: moduleId,
70
- parentId: parentId
71
- };
72
- }
73
- if (outdatedModules.indexOf(parentId) !== -1) continue;
74
- if (parent.hot._acceptedDependencies[moduleId]) {
75
- if (!outdatedDependencies[parentId])
76
- outdatedDependencies[parentId] = [];
77
- addAllToSet(outdatedDependencies[parentId], [moduleId]);
78
- continue;
79
- }
80
- delete outdatedDependencies[parentId];
81
- outdatedModules.push(parentId);
82
- queue.push({
83
- chain: chain.concat([parentId]),
84
- id: parentId
85
- });
86
- }
87
- }
88
-
89
- return {
90
- type: "accepted",
91
- moduleId: updateModuleId,
92
- outdatedModules: outdatedModules,
93
- outdatedDependencies: outdatedDependencies
94
- };
95
- }
96
-
97
- function addAllToSet(a, b) {
98
- for (var i = 0; i < b.length; i++) {
99
- var item = b[i];
100
- if (a.indexOf(item) === -1) a.push(item);
101
- }
102
- }
103
-
104
- // at begin all updates modules are outdated
105
- // the "outdated" status can propagate to parents if they don't accept the children
106
- var outdatedDependencies = {};
107
- var outdatedModules = [];
108
- var appliedUpdate = {};
109
-
110
- var warnUnexpectedRequire = function warnUnexpectedRequire(module) {
111
- console.warn(
112
- "[HMR] unexpected require(" + module.id + ") to disposed module"
113
- );
114
- };
115
-
116
- for (var moduleId in currentUpdate) {
117
- if ($hasOwnProperty$(currentUpdate, moduleId)) {
118
- var newModuleFactory = currentUpdate[moduleId];
119
- /** @type {TODO} */
120
- var result;
121
- if (newModuleFactory) {
122
- result = getAffectedModuleEffects(moduleId);
123
- } else {
124
- result = {
125
- type: "disposed",
126
- moduleId: moduleId
127
- };
128
- }
129
- /** @type {Error|false} */
130
- var abortError = false;
131
- var doApply = false;
132
- var doDispose = false;
133
- var chainInfo = "";
134
- if (result.chain) {
135
- chainInfo = "\nUpdate propagation: " + result.chain.join(" -> ");
136
- }
137
- switch (result.type) {
138
- case "self-declined":
139
- if (options.onDeclined) options.onDeclined(result);
140
- if (!options.ignoreDeclined)
141
- abortError = new Error(
142
- "Aborted because of self decline: " +
143
- result.moduleId +
144
- chainInfo
145
- );
146
- break;
147
- case "declined":
148
- if (options.onDeclined) options.onDeclined(result);
149
- if (!options.ignoreDeclined)
150
- abortError = new Error(
151
- "Aborted because of declined dependency: " +
152
- result.moduleId +
153
- " in " +
154
- result.parentId +
155
- chainInfo
156
- );
157
- break;
158
- case "unaccepted":
159
- if (options.onUnaccepted) options.onUnaccepted(result);
160
- if (!options.ignoreUnaccepted)
161
- abortError = new Error(
162
- "Aborted because " + moduleId + " is not accepted" + chainInfo
163
- );
164
- break;
165
- case "accepted":
166
- if (options.onAccepted) options.onAccepted(result);
167
- doApply = true;
168
- break;
169
- case "disposed":
170
- if (options.onDisposed) options.onDisposed(result);
171
- doDispose = true;
172
- break;
173
- default:
174
- throw new Error("Unexception type " + result.type);
175
- }
176
- if (abortError) {
177
- return {
178
- error: abortError
179
- };
180
- }
181
- if (doApply) {
182
- appliedUpdate[moduleId] = newModuleFactory;
183
- addAllToSet(outdatedModules, result.outdatedModules);
184
- for (moduleId in result.outdatedDependencies) {
185
- if ($hasOwnProperty$(result.outdatedDependencies, moduleId)) {
186
- if (!outdatedDependencies[moduleId])
187
- outdatedDependencies[moduleId] = [];
188
- addAllToSet(
189
- outdatedDependencies[moduleId],
190
- result.outdatedDependencies[moduleId]
191
- );
192
- }
193
- }
194
- }
195
- if (doDispose) {
196
- addAllToSet(outdatedModules, [result.moduleId]);
197
- appliedUpdate[moduleId] = warnUnexpectedRequire;
198
- }
199
- }
200
- }
201
- currentUpdate = undefined;
202
-
203
- // Store self accepted outdated modules to require them later by the module system
204
- var outdatedSelfAcceptedModules = [];
205
- for (var j = 0; j < outdatedModules.length; j++) {
206
- var outdatedModuleId = outdatedModules[j];
207
- var module = $moduleCache$[outdatedModuleId];
208
- if (
209
- module &&
210
- (module.hot._selfAccepted || module.hot._main) &&
211
- // removed self-accepted modules should not be required
212
- appliedUpdate[outdatedModuleId] !== warnUnexpectedRequire &&
213
- // when called invalidate self-accepting is not possible
214
- !module.hot._selfInvalidated
215
- ) {
216
- outdatedSelfAcceptedModules.push({
217
- module: outdatedModuleId,
218
- require: module.hot._requireSelf,
219
- errorHandler: module.hot._selfAccepted
220
- });
221
- }
222
- }
223
-
224
- var moduleOutdatedDependencies;
225
-
226
- return {
227
- dispose: function () {
228
- currentUpdateRemovedChunks.forEach(function (chunkId) {
229
- delete $installedChunks$[chunkId];
230
- });
231
- currentUpdateRemovedChunks = undefined;
232
-
233
- var idx;
234
- var queue = outdatedModules.slice();
235
- while (queue.length > 0) {
236
- var moduleId = queue.pop();
237
- var module = $moduleCache$[moduleId];
238
- if (!module) continue;
239
-
240
- var data = {};
241
-
242
- // Call dispose handlers
243
- var disposeHandlers = module.hot._disposeHandlers;
244
- for (j = 0; j < disposeHandlers.length; j++) {
245
- disposeHandlers[j].call(null, data);
246
- }
247
- $hmrModuleData$[moduleId] = data;
248
-
249
- // disable module (this disables requires from this module)
250
- module.hot.active = false;
251
-
252
- // remove module from cache
253
- delete $moduleCache$[moduleId];
254
-
255
- // when disposing there is no need to call dispose handler
256
- delete outdatedDependencies[moduleId];
257
-
258
- // remove "parents" references from all children
259
- for (j = 0; j < module.children.length; j++) {
260
- var child = $moduleCache$[module.children[j]];
261
- if (!child) continue;
262
- idx = child.parents.indexOf(moduleId);
263
- if (idx >= 0) {
264
- child.parents.splice(idx, 1);
265
- }
266
- }
267
- }
268
-
269
- // remove outdated dependency from module children
270
- var dependency;
271
- for (var outdatedModuleId in outdatedDependencies) {
272
- if ($hasOwnProperty$(outdatedDependencies, outdatedModuleId)) {
273
- module = $moduleCache$[outdatedModuleId];
274
- if (module) {
275
- moduleOutdatedDependencies =
276
- outdatedDependencies[outdatedModuleId];
277
- for (j = 0; j < moduleOutdatedDependencies.length; j++) {
278
- dependency = moduleOutdatedDependencies[j];
279
- idx = module.children.indexOf(dependency);
280
- if (idx >= 0) module.children.splice(idx, 1);
281
- }
282
- }
283
- }
284
- }
285
- },
286
- apply: function (reportError) {
287
- // insert new code
288
- for (var updateModuleId in appliedUpdate) {
289
- if ($hasOwnProperty$(appliedUpdate, updateModuleId)) {
290
- $moduleFactories$[updateModuleId] = appliedUpdate[updateModuleId];
291
- }
292
- }
293
-
294
- // run new runtime modules
295
- for (var i = 0; i < currentUpdateRuntime.length; i++) {
296
- currentUpdateRuntime[i](__webpack_require__);
297
- }
298
-
299
- // call accept handlers
300
- for (var outdatedModuleId in outdatedDependencies) {
301
- if ($hasOwnProperty$(outdatedDependencies, outdatedModuleId)) {
302
- var module = $moduleCache$[outdatedModuleId];
303
- if (module) {
304
- moduleOutdatedDependencies =
305
- outdatedDependencies[outdatedModuleId];
306
- var callbacks = [];
307
- var errorHandlers = [];
308
- var dependenciesForCallbacks = [];
309
- for (var j = 0; j < moduleOutdatedDependencies.length; j++) {
310
- var dependency = moduleOutdatedDependencies[j];
311
- var acceptCallback =
312
- module.hot._acceptedDependencies[dependency];
313
- var errorHandler =
314
- module.hot._acceptedErrorHandlers[dependency];
315
- if (acceptCallback) {
316
- if (callbacks.indexOf(acceptCallback) !== -1) continue;
317
- callbacks.push(acceptCallback);
318
- errorHandlers.push(errorHandler);
319
- dependenciesForCallbacks.push(dependency);
320
- }
321
- }
322
- for (var k = 0; k < callbacks.length; k++) {
323
- try {
324
- callbacks[k].call(null, moduleOutdatedDependencies);
325
- } catch (err) {
326
- if (typeof errorHandlers[k] === "function") {
327
- try {
328
- errorHandlers[k](err, {
329
- moduleId: outdatedModuleId,
330
- dependencyId: dependenciesForCallbacks[k]
331
- });
332
- } catch (err2) {
333
- if (options.onErrored) {
334
- options.onErrored({
335
- type: "accept-error-handler-errored",
336
- moduleId: outdatedModuleId,
337
- dependencyId: dependenciesForCallbacks[k],
338
- error: err2,
339
- originalError: err
340
- });
341
- }
342
- if (!options.ignoreErrored) {
343
- reportError(err2);
344
- reportError(err);
345
- }
346
- }
347
- } else {
348
- if (options.onErrored) {
349
- options.onErrored({
350
- type: "accept-errored",
351
- moduleId: outdatedModuleId,
352
- dependencyId: dependenciesForCallbacks[k],
353
- error: err
354
- });
355
- }
356
- if (!options.ignoreErrored) {
357
- reportError(err);
358
- }
359
- }
360
- }
361
- }
362
- }
363
- }
364
- }
365
-
366
- // Load self accepted modules
367
- for (var o = 0; o < outdatedSelfAcceptedModules.length; o++) {
368
- var item = outdatedSelfAcceptedModules[o];
369
- var moduleId = item.module;
370
- try {
371
- item.require(moduleId);
372
- } catch (err) {
373
- if (typeof item.errorHandler === "function") {
374
- try {
375
- item.errorHandler(err, {
376
- moduleId: moduleId,
377
- module: $moduleCache$[moduleId]
378
- });
379
- } catch (err2) {
380
- if (options.onErrored) {
381
- options.onErrored({
382
- type: "self-accept-error-handler-errored",
383
- moduleId: moduleId,
384
- error: err2,
385
- originalError: err
386
- });
387
- }
388
- if (!options.ignoreErrored) {
389
- reportError(err2);
390
- reportError(err);
391
- }
392
- }
393
- } else {
394
- if (options.onErrored) {
395
- options.onErrored({
396
- type: "self-accept-errored",
397
- moduleId: moduleId,
398
- error: err
399
- });
400
- }
401
- if (!options.ignoreErrored) {
402
- reportError(err);
403
- }
404
- }
405
- }
406
- }
407
-
408
- return outdatedModules;
409
- }
410
- };
411
- }
412
- $hmrInvalidateModuleHandlers$.$key$ = function (moduleId, applyHandlers) {
413
- if (!currentUpdate) {
414
- currentUpdate = {};
415
- currentUpdateRuntime = [];
416
- currentUpdateRemovedChunks = [];
417
- applyHandlers.push(applyHandler);
418
- }
419
- if (!$hasOwnProperty$(currentUpdate, moduleId)) {
420
- currentUpdate[moduleId] = $moduleFactories$[moduleId];
421
- }
422
- };
423
- $hmrDownloadUpdateHandlers$.$key$ = function (
424
- chunkIds,
425
- removedChunks,
426
- removedModules,
427
- promises,
428
- applyHandlers,
429
- updatedModulesList
430
- ) {
431
- applyHandlers.push(applyHandler);
432
- currentUpdateChunks = {};
433
- currentUpdateRemovedChunks = removedChunks;
434
- currentUpdate = removedModules.reduce(function (obj, key) {
435
- obj[key] = false;
436
- return obj;
437
- }, {});
438
- currentUpdateRuntime = [];
439
- chunkIds.forEach(function (chunkId) {
440
- if (
441
- $hasOwnProperty$($installedChunks$, chunkId) &&
442
- $installedChunks$[chunkId] !== undefined
443
- ) {
444
- promises.push($loadUpdateChunk$(chunkId, updatedModulesList));
445
- currentUpdateChunks[chunkId] = true;
446
- } else {
447
- currentUpdateChunks[chunkId] = false;
448
- }
449
- });
450
- if ($ensureChunkHandlers$) {
451
- $ensureChunkHandlers$.$key$Hmr = function (chunkId, promises) {
452
- if (
453
- currentUpdateChunks &&
454
- $hasOwnProperty$(currentUpdateChunks, chunkId) &&
455
- !currentUpdateChunks[chunkId]
456
- ) {
457
- promises.push($loadUpdateChunk$(chunkId));
458
- currentUpdateChunks[chunkId] = true;
459
- }
460
- };
461
- }
462
- };
463
- };
@@ -1,50 +0,0 @@
1
- /* global __resourceQuery */
2
-
3
- "use strict";
4
-
5
- var urlBase = decodeURIComponent(__resourceQuery.slice(1));
6
-
7
- /**
8
- * @param {{ data: string, onError: (err: Error) => void, active: boolean, module: module }} options options
9
- * @returns {() => void} function to destroy response
10
- */
11
- exports.keepAlive = function (options) {
12
- var data = options.data;
13
- var onError = options.onError;
14
- var active = options.active;
15
- var module = options.module;
16
- /** @type {import("http").IncomingMessage} */
17
- var response;
18
- var request = (
19
- urlBase.startsWith("https") ? require("https") : require("http")
20
- ).request(
21
- urlBase + data,
22
- {
23
- agent: false,
24
- headers: { accept: "text/event-stream" }
25
- },
26
- function (res) {
27
- response = res;
28
- response.on("error", errorHandler);
29
- if (!active && !module.hot) {
30
- console.log(
31
- "Hot Module Replacement is not enabled. Waiting for process restart..."
32
- );
33
- }
34
- }
35
- );
36
-
37
- /**
38
- * @param {Error} err error
39
- */
40
- function errorHandler(err) {
41
- err.message =
42
- "Problem communicating active modules to the server: " + err.message;
43
- onError(err);
44
- }
45
- request.on("error", errorHandler);
46
- request.end();
47
- return function () {
48
- response.destroy();
49
- };
50
- };
@@ -1,83 +0,0 @@
1
- /* global __resourceQuery */
2
-
3
- "use strict";
4
-
5
- if (typeof EventSource !== "function") {
6
- throw new Error(
7
- "Environment doesn't support lazy compilation (requires EventSource)"
8
- );
9
- }
10
-
11
- var urlBase = decodeURIComponent(__resourceQuery.slice(1));
12
- /** @type {EventSource | undefined} */
13
- var activeEventSource;
14
- var activeKeys = new Map();
15
- var errorHandlers = new Set();
16
-
17
- var updateEventSource = function updateEventSource() {
18
- if (activeEventSource) activeEventSource.close();
19
- if (activeKeys.size) {
20
- activeEventSource = new EventSource(
21
- urlBase + Array.from(activeKeys.keys()).join("@")
22
- );
23
- /**
24
- * @this {EventSource}
25
- * @param {Event & { message?: string, filename?: string, lineno?: number, colno?: number, error?: Error }} event event
26
- */
27
- activeEventSource.onerror = function (event) {
28
- errorHandlers.forEach(function (onError) {
29
- onError(
30
- new Error(
31
- "Problem communicating active modules to the server: " +
32
- event.message +
33
- " " +
34
- event.filename +
35
- ":" +
36
- event.lineno +
37
- ":" +
38
- event.colno +
39
- " " +
40
- event.error
41
- )
42
- );
43
- });
44
- };
45
- } else {
46
- activeEventSource = undefined;
47
- }
48
- };
49
-
50
- /**
51
- * @param {{ data: string, onError: (err: Error) => void, active: boolean, module: module }} options options
52
- * @returns {() => void} function to destroy response
53
- */
54
- exports.keepAlive = function (options) {
55
- var data = options.data;
56
- var onError = options.onError;
57
- var active = options.active;
58
- var module = options.module;
59
- errorHandlers.add(onError);
60
- var value = activeKeys.get(data) || 0;
61
- activeKeys.set(data, value + 1);
62
- if (value === 0) {
63
- updateEventSource();
64
- }
65
- if (!active && !module.hot) {
66
- console.log(
67
- "Hot Module Replacement is not enabled. Waiting for process restart..."
68
- );
69
- }
70
-
71
- return function () {
72
- errorHandlers.delete(onError);
73
- setTimeout(function () {
74
- var value = activeKeys.get(data);
75
- if (value === 1) {
76
- activeKeys.delete(data);
77
- updateEventSource();
78
- } else {
79
- activeKeys.set(data, value - 1);
80
- }
81
- }, 1000);
82
- };
83
- };