MCPcopy
hub / github.com/webpack/webpack / watch

Method watch

lib/MultiCompiler.js:638–669  ·  view source on GitHub ↗

* Returns a compiler watcher. * @param {WatchOptions | WatchOptions[]} watchOptions the watcher's options * @param {Callback<MultiStats>} handler signals when the call finishes * @returns {MultiWatching | undefined} a compiler watcher

(watchOptions, handler)

Source from the content-addressed store, hash-verified

636 * @returns {MultiWatching | undefined} a compiler watcher
637 */
638 watch(watchOptions, handler) {
639 if (this.running) {
640 handler(new ConcurrentCompilationError());
641 return;
642 }
643 this.running = true;
644
645 if (this.validateDependencies(handler)) {
646 const watchings = this._runGraph(
647 (compiler, idx, callback, isBlocked, setChanged, setInvalid) => {
648 const watching = compiler.watch(
649 Array.isArray(watchOptions) ? watchOptions[idx] : watchOptions,
650 callback
651 );
652 if (watching) {
653 watching._onInvalid = setInvalid;
654 watching._onChange = setChanged;
655 watching._isBlocked = isBlocked;
656 }
657 return watching;
658 },
659 (compiler, watching, _callback) => {
660 if (compiler.watching !== watching) return;
661 if (!watching.running) watching.invalidate();
662 },
663 handler
664 );
665 return new MultiWatching(watchings, this);
666 }
667
668 return new MultiWatching([], this);
669 }
670
671 /**
672 * Processes the provided multi stat.

Callers

nothing calls this directly

Calls 5

validateDependenciesMethod · 0.95
_runGraphMethod · 0.95
isArrayMethod · 0.80
invalidateMethod · 0.65
handlerFunction · 0.50

Tested by

no test coverage detected