MCPcopy
hub / github.com/webpack/webpack / _done

Method _done

lib/Watching.js:273–365  ·  view source on GitHub ↗

* Processes the provided err. * @param {(Error | null)=} err an optional error * @param {Compilation=} compilation the compilation * @returns {void}

(err, compilation)

Source from the content-addressed store, hash-verified

271 * @returns {void}
272 */
273 _done(err, compilation) {
274 this.running = false;
275
276 const logger =
277 /** @type {Logger} */
278 (compilation && compilation.getLogger("webpack.Watching"));
279
280 /** @type {Stats | undefined} */
281 let stats;
282
283 /**
284 * Processes the provided err.
285 * @param {Error} err error
286 * @param {ErrorCallback[]=} cbs callbacks
287 */
288 const handleError = (err, cbs) => {
289 this.compiler.hooks.failed.call(err);
290 this.compiler.cache.beginIdle();
291 this.compiler.idle = true;
292 this.handler(err, /** @type {Stats} */ (stats));
293 if (!cbs) {
294 cbs = this.callbacks;
295 this.callbacks = [];
296 }
297 for (const cb of cbs) cb(err);
298 };
299
300 if (
301 this.invalid &&
302 !this.suspended &&
303 !this.blocked &&
304 !(this._isBlocked() && (this.blocked = true))
305 ) {
306 if (compilation) {
307 logger.time("storeBuildDependencies");
308 this.compiler.cache.storeBuildDependencies(
309 compilation.buildDependencies,
310 (err) => {
311 logger.timeEnd("storeBuildDependencies");
312 if (err) return handleError(err);
313 this._go();
314 }
315 );
316 } else {
317 this._go();
318 }
319 return;
320 }
321
322 if (compilation) {
323 compilation.startTime = /** @type {number} */ (this.startTime);
324 compilation.endTime = Date.now();
325 stats = new Stats(compilation);
326 }
327 this.startTime = null;
328 if (err) return handleError(err);
329
330 const cbs = this.callbacks;

Callers 2

runMethod · 0.95
onCompiledMethod · 0.95

Calls 10

_goMethod · 0.95
watchMethod · 0.95
timeMethod · 0.80
timeEndMethod · 0.80
beginIdleMethod · 0.80
handleErrorFunction · 0.70
getLoggerMethod · 0.65
handlerMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected