MCPcopy
hub / github.com/webpack/webpack / close

Method close

lib/Watching.js:482–550  ·  view source on GitHub ↗

* Processes the provided error callback. * @param {ErrorCallback} callback signals when the watcher is closed * @returns {void}

(callback)

Source from the content-addressed store, hash-verified

480 * @returns {void}
481 */
482 close(callback) {
483 if (this._closeCallbacks) {
484 if (callback) {
485 this._closeCallbacks.push(callback);
486 }
487 return;
488 }
489 /**
490 * Processes the provided err.
491 * @param {Error | null} err error if any
492 * @param {Compilation=} compilation compilation if any
493 */
494 const finalCallback = (err, compilation) => {
495 this.running = false;
496 this.compiler.running = false;
497 this.compiler.watching = undefined;
498 this.compiler.watchMode = false;
499 this.compiler.modifiedFiles = undefined;
500 this.compiler.removedFiles = undefined;
501 this.compiler.fileTimestamps = undefined;
502 this.compiler.contextTimestamps = undefined;
503 this.compiler.fsStartTime = undefined;
504 /**
505 * Processes the provided err.
506 * @param {Error | null} err error if any
507 */
508 const shutdown = (err) => {
509 this.compiler.hooks.watchClose.call();
510 const closeCallbacks =
511 /** @type {ErrorCallback[]} */
512 (this._closeCallbacks);
513 this._closeCallbacks = undefined;
514 for (const cb of closeCallbacks) cb(err);
515 };
516 if (compilation) {
517 const logger = compilation.getLogger("webpack.Watching");
518 logger.time("storeBuildDependencies");
519 this.compiler.cache.storeBuildDependencies(
520 compilation.buildDependencies,
521 (err2) => {
522 logger.timeEnd("storeBuildDependencies");
523 shutdown(err || err2);
524 }
525 );
526 } else {
527 shutdown(err);
528 }
529 };
530
531 this.closed = true;
532 if (this.watcher) {
533 this.watcher.close();
534 this.watcher = null;
535 }
536 if (this.pausedWatcher) {
537 this.pausedWatcher.close();
538 this.pausedWatcher = null;
539 }

Callers 7

updateEventSourceFunction · 0.45
watchMethod · 0.45
webpackFunction · 0.45
readMethod · 0.45
disposeFunction · 0.45
watchMethod · 0.45
webpack.jsFile · 0.45

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected