MCPcopy
hub / github.com/webpack/webpack-dev-server / invalidate

Method invalidate

lib/Server.js:3468–3511  ·  view source on GitHub ↗

* @param {import("webpack-dev-middleware").Callback=} callback callback

(callback = () => {})

Source from the content-addressed store, hash-verified

3466 * @param {import("webpack-dev-middleware").Callback=} callback callback
3467 */
3468 invalidate(callback = () => {}) {
3469 // In plugin mode the host owns `compiler.watch()`, so the middleware has no
3470 // `watching` of its own — invalidate the host's watching(s) directly to
3471 // trigger a rebuild (each child's own `watching` for a `MultiCompiler`).
3472 if (this.isPlugin) {
3473 const compilers =
3474 /** @type {MultiCompiler} */ (this.compiler).compilers ||
3475 /** @type {Compiler[]} */ ([this.compiler]);
3476
3477 /** @type {NonNullable<Compiler["watching"]>[]} */
3478 const watchings = [];
3479
3480 for (const compiler of compilers) {
3481 if (compiler.watching) {
3482 watchings.push(compiler.watching);
3483 }
3484 }
3485
3486 if (watchings.length === 0) {
3487 callback();
3488 return;
3489 }
3490
3491 let pending = watchings.length;
3492
3493 const onInvalidated = () => {
3494 pending -= 1;
3495
3496 if (pending === 0) {
3497 callback();
3498 }
3499 };
3500
3501 for (const watching of watchings) {
3502 watching.invalidate(onInvalidated);
3503 }
3504
3505 return;
3506 }
3507
3508 if (this.middleware) {
3509 this.middleware.invalidate(callback);
3510 }
3511 }
3512
3513 /**
3514 * @returns {Promise<void>}

Callers 4

setupMiddlewaresMethod · 0.95
overlay.test.jsFile · 0.80
api-plugin.test.jsFile · 0.80
api.test.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected