MCPcopy
hub / github.com/webpack/webpack / attachDependencyGuards

Function attachDependencyGuards

lib/dependencies/HarmonyImportGuard.js:231–251  ·  view source on GitHub ↗
(parser, dep)

Source from the content-addressed store, hash-verified

229 * @param {GuardableDependency} dep the dependency
230 */
231const attachDependencyGuards = (parser, dep) => {
232 const stack = /** @type {GuardFrame[] | undefined} */ (
233 parser.state.guardStack
234 );
235 if (stack === undefined || stack.length === 0) return;
236 /** @type {DependencyGuard[] | undefined} */
237 let guards;
238 for (const frame of stack) {
239 if (frame.depStart === undefined) continue;
240 let formula = frame.formula;
241 if (formula === undefined) {
242 formula = frame.formula = buildFrameFormula(parser, frame);
243 }
244 if (formula === null) continue;
245 (guards || (guards = [])).push({
246 formula,
247 value: /** @type {boolean} */ (frame.condition)
248 });
249 }
250 if (guards !== undefined) dep.branchGuards = guards;
251};
252
253module.exports.attachDependencyGuards = attachDependencyGuards;
254module.exports.isDeadByGuards = isDeadByGuards;

Callers

nothing calls this directly

Calls 2

buildFrameFormulaFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected