MCPcopy Create free account
hub / github.com/angular/angular / patchComponentDefWithScope

Function patchComponentDefWithScope

packages/core/src/render3/jit/module.ts:543–562  ·  view source on GitHub ↗
(
  componentDef: ComponentDef<C>,
  transitiveScopes: NgModuleTransitiveScopes,
)

Source from the content-addressed store, hash-verified

541 * a given module.
542 */
543export function patchComponentDefWithScope<C>(
544 componentDef: ComponentDef<C>,
545 transitiveScopes: NgModuleTransitiveScopes,
546) {
547 componentDef.directiveDefs = () =>
548 Array.from(transitiveScopes.compilation.directives)
549 .map((dir) =>
550 Object.hasOwn(dir, NG_COMP_DEF) ? getComponentDef(dir)! : getDirectiveDef(dir)!,
551 )
552 .filter((def) => !!def);
553 componentDef.pipeDefs = () =>
554 Array.from(transitiveScopes.compilation.pipes).map((pipe) => getPipeDef(pipe)!);
555 componentDef.schemas = transitiveScopes.schemas;
556
557 // Since we avoid Components/Directives/Pipes recompiling in case there are no overrides, we
558 // may face a problem where previously compiled defs available to a given Component/Directive
559 // are cached in TView and may become stale (in case any of these defs gets recompiled). In
560 // order to avoid this problem, we force fresh TView to be created.
561 componentDef.tView = null;
562}
563
564/**
565 * Compute the pair of transitive scopes (compilation scope and exported scope) for a given type

Callers 3

compileComponentFunction · 0.90
applyTransitiveScopesMethod · 0.85

Calls 5

getComponentDefFunction · 0.90
getDirectiveDefFunction · 0.90
getPipeDefFunction · 0.90
mapMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected