MCPcopy
hub / github.com/webpack/webpack / internalApply

Function internalApply

lib/hmr/HotModuleReplacement.runtime.js:449–542  ·  view source on GitHub ↗

* @param {boolean | ApplyOptions=} options apply options * @returns {Promise<ModuleId[]>} updated module ids

(options)

Source from the content-addressed store, hash-verified

447 * @returns {Promise<ModuleId[]>} updated module ids
448 */
449 function internalApply(options) {
450 options = options || {};
451
452 applyInvalidatedModules();
453
454 var results = /** @type {ApplyHandler[]} */ (
455 currentUpdateApplyHandlers
456 ).map(function (handler) {
457 return handler(/** @type {ApplyOptions} */ (options));
458 });
459 currentUpdateApplyHandlers = undefined;
460
461 var errors = results
462 .map(function (r) {
463 return r.error;
464 })
465 .filter(Boolean);
466
467 if (errors.length > 0) {
468 return setStatus("abort").then(function () {
469 throw errors[0];
470 });
471 }
472
473 // Now in "dispose" phase
474 var disposePromise = setStatus("dispose");
475
476 results.forEach(function (result) {
477 if (result.dispose) result.dispose();
478 });
479
480 // Now in "apply" phase
481 var applyPromise = setStatus("apply");
482
483 /** @type {Error | undefined} */
484 var error;
485 /**
486 * @param {Error} err error thrown while applying
487 * @returns {void}
488 */
489 var reportError = function (err) {
490 if (!error) error = err;
491 };
492
493 /** @type {ModuleId[]} */
494 var outdatedModules = [];
495
496 /**
497 * @returns {Promise<ModuleId[]>} updated module ids
498 */
499 var onAccepted = function () {
500 return Promise.all([disposePromise, applyPromise]).then(function () {
501 // handle errors in accept handlers and self accepted module load
502 if (error) {
503 return setStatus("fail").then(function () {
504 throw error;
505 });
506 }

Callers 3

hotCheckFunction · 0.85
hotApplyFunction · 0.85
onAcceptedFunction · 0.85

Calls 6

applyInvalidatedModulesFunction · 0.85
setStatusFunction · 0.85
disposeMethod · 0.80
handlerFunction · 0.50
forEachMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected