MCPcopy
hub / github.com/webpack/webpack / unpack

Method unpack

lib/cache/PackFileCacheStrategy.js:952–990  ·  view source on GitHub ↗

* Returns maybe a promise if lazy. * @param {string} reason explanation why unpack is necessary * @returns {void | Promise<void>} maybe a promise if lazy

(reason)

Source from the content-addressed store, hash-verified

950 * @returns {void | Promise<void>} maybe a promise if lazy
951 */
952 unpack(reason) {
953 if (this.content) return;
954
955 const logger = /** @type {Logger} */ (this.logger);
956 // Move from state B to C
957 if (this.lazy) {
958 const { lazyName } = this;
959 /** @type {string | undefined} */
960 let timeMessage;
961 if (lazyName) {
962 // only log once
963 this.lazyName = undefined;
964 timeMessage = `unpack cache content ${lazyName} (${formatSize(
965 this.getSize()
966 )})`;
967 logger.log(
968 `starting to unpack cache content ${lazyName} (${formatSize(
969 this.getSize()
970 )}) because ${reason}`
971 );
972 logger.time(timeMessage);
973 }
974 const value =
975 /** @type {PackContentItems | Promise<PackContentItems>} */
976 (this.lazy());
977 if ("then" in value) {
978 return value.then((data) => {
979 if (timeMessage) {
980 logger.timeEnd(timeMessage);
981 }
982 this.content = data.map;
983 });
984 }
985 if (timeMessage) {
986 logger.timeEnd(timeMessage);
987 }
988 this.content = value.map;
989 }
990 }
991
992 /**
993 * Returns the estimated size for the requested source type.

Callers 3

_optimizeSmallContentMethod · 0.80
_gcOldestContentMethod · 0.80

Calls 5

getSizeMethod · 0.95
formatSizeFunction · 0.85
logMethod · 0.80
timeMethod · 0.80
timeEndMethod · 0.80

Tested by

no test coverage detected