MCPcopy
hub / github.com/webpack/webpack / run

Method run

lib/Compiler.js:547–684  ·  view source on GitHub ↗

* Processes the provided stat. * @param {Callback<Stats>} callback signals when the call finishes * @returns {void}

(callback)

Source from the content-addressed store, hash-verified

545 * @returns {void}
546 */
547 run(callback) {
548 if (this.running) {
549 callback(new ConcurrentCompilationError());
550 return;
551 }
552
553 /** @type {Logger | undefined} */
554 let logger;
555
556 /**
557 * Processes the provided err.
558 * @param {Error | null} err error
559 * @param {Stats=} stats stats
560 */
561 const finalCallback = (err, stats) => {
562 if (logger) logger.time("beginIdle");
563 this.idle = true;
564 this.cache.beginIdle();
565 if (logger) logger.timeEnd("beginIdle");
566 this.running = false;
567 if (err) {
568 this.hooks.failed.call(err);
569 }
570 if (callback !== undefined) callback(err, stats);
571 this.hooks.afterDone.call(/** @type {Stats} */ (stats));
572 };
573
574 const startTime = Date.now();
575
576 this.running = true;
577
578 /**
579 * Processes the provided err.
580 * @param {Error | null} err error
581 * @param {Compilation=} _compilation compilation
582 * @returns {void}
583 */
584 const onCompiled = (err, _compilation) => {
585 if (err) return finalCallback(err);
586
587 const compilation = /** @type {Compilation} */ (_compilation);
588
589 if (this.hooks.shouldEmit.call(compilation) === false) {
590 compilation.startTime = startTime;
591 compilation.endTime = Date.now();
592 const stats = new Stats(compilation);
593 this.hooks.done.callAsync(stats, (err) => {
594 if (err) return finalCallback(err);
595 return finalCallback(null, stats);
596 });
597 return;
598 }
599
600 process.nextTick(() => {
601 logger = compilation.getLogger("webpack.Compiler");
602 logger.time("emitAssets");
603 this.emitAssets(compilation, (err) => {
604 /** @type {Logger} */

Callers

nothing calls this directly

Calls 5

readRecordsMethod · 0.95
compileMethod · 0.95
endIdleMethod · 0.80
callbackFunction · 0.50
runFunction · 0.50

Tested by

no test coverage detected