MCPcopy
hub / github.com/webpack/webpack / propagateLinearResult

Function propagateLinearResult

lib/NormalModule.js:362–387  ·  view source on GitHub ↗
(ancestors, state, moduleGraph, ctx)

Source from the content-addressed store, hash-verified

360 * @returns {ConnectionState} the root ancestor's result
361 */
362const propagateLinearResult = (ancestors, state, moduleGraph, ctx) => {
363 if (ancestors === null) return state;
364 while (ancestors.length > 0) {
365 const dep = /** @type {Dependency} */ (ancestors.pop());
366 const ancestor = /** @type {NormalModule} */ (ancestors.pop());
367 ancestor._isEvaluatingSideEffects = false;
368
369 if (state === true) {
370 recordSideEffectsBailout(ancestor, moduleGraph, dep);
371 // `true` is monotonic — safe to cache regardless of cycle status.
372 ancestor._sideEffectsStateGraph = moduleGraph;
373 ancestor._sideEffectsStateValue = true;
374 } else if (state === ModuleGraphConnection.CIRCULAR_CONNECTION) {
375 // CIRCULAR_CONNECTION is filtered before folding into `current`,
376 // so the ancestor's `current` stays at its initial `false`. From
377 // this point upward the propagated state is `false`, and the
378 // cycle taint prevents memoization further up (handled by
379 // `ctx.circular`).
380 state = false;
381 } else if (!ctx.circular) {
382 ancestor._sideEffectsStateGraph = moduleGraph;
383 ancestor._sideEffectsStateValue = state;
384 }
385 }
386 return state;
387};
388
389/**
390 * Recursive form of the side-effects walker. Folds the descent through

Callers 1

walkSideEffectsRecursiveFunction · 0.85

Calls 2

recordSideEffectsBailoutFunction · 0.85
popMethod · 0.80

Tested by

no test coverage detected