MCPcopy
hub / github.com/webpack/webpack / _applyOnMultiCompiler

Method _applyOnMultiCompiler

lib/ProgressPlugin.js:296–308  ·  view source on GitHub ↗

* Apply on multi compiler. * @param {MultiCompiler} compiler webpack multi-compiler * @param {HandlerFn} handler function that executes for every progress step * @returns {void}

(compiler, handler)

Source from the content-addressed store, hash-verified

294 * @returns {void}
295 */
296 _applyOnMultiCompiler(compiler, handler) {
297 const states = compiler.compilers.map(
298 () => /** @type {[number, ...string[]]} */ ([0])
299 );
300 for (const [idx, item] of compiler.compilers.entries()) {
301 new ProgressPlugin((p, msg, ...args) => {
302 states[idx] = [p, msg, ...args];
303 let sum = 0;
304 for (const [p] of states) sum += p;
305 handler(sum / states.length, `[${idx}] ${msg}`, ...args);
306 }).apply(item);
307 }
308 }
309
310 /**
311 * Processes the provided compiler.

Callers 1

applyMethod · 0.95

Calls 3

entriesMethod · 0.80
applyMethod · 0.65
handlerFunction · 0.50

Tested by

no test coverage detected