MCPcopy
hub / github.com/webpack/webpack / hotCheck

Function hotCheck

lib/hmr/HotModuleReplacement.runtime.js:377–426  ·  view source on GitHub ↗

* @param {boolean | ApplyOptions=} applyOnUpdate apply the update right away * @returns {Promise<ModuleId[] | null>} updated module ids or null

(applyOnUpdate)

Source from the content-addressed store, hash-verified

375 * @returns {Promise<ModuleId[] | null>} updated module ids or null
376 */
377 function hotCheck(applyOnUpdate) {
378 if (currentStatus !== "idle") {
379 throw new Error("check() is only allowed in idle status");
380 }
381 return setStatus("check")
382 .then($hmrDownloadManifest$)
383 .then(function (update) {
384 if (!update) {
385 return setStatus(applyInvalidatedModules() ? "ready" : "idle").then(
386 function () {
387 return null;
388 }
389 );
390 }
391
392 return setStatus("prepare").then(function () {
393 /** @type {ModuleId[]} */
394 var updatedModules = [];
395 currentUpdateApplyHandlers = [];
396
397 return Promise.all(
398 Object.keys($hmrDownloadUpdateHandlers$).reduce(function (
399 promises,
400 key
401 ) {
402 $hmrDownloadUpdateHandlers$[key](
403 update.c,
404 update.r,
405 update.m,
406 promises,
407 /** @type {ApplyHandler[]} */ (currentUpdateApplyHandlers),
408 updatedModules,
409 update.css,
410 update.f
411 );
412 return promises;
413 }, /** @type {Promise<unknown>[]} */ ([]))
414 ).then(function () {
415 return waitForBlockingPromises(function () {
416 if (applyOnUpdate) {
417 return internalApply(applyOnUpdate);
418 }
419 return setStatus("ready").then(function () {
420 return updatedModules;
421 });
422 });
423 });
424 });
425 });
426 }
427
428 /**
429 * @param {ApplyOptions=} options apply options

Callers

nothing calls this directly

Calls 5

setStatusFunction · 0.85
applyInvalidatedModulesFunction · 0.85
waitForBlockingPromisesFunction · 0.85
internalApplyFunction · 0.85
keysMethod · 0.65

Tested by

no test coverage detected