MCPcopy Index your code
hub / github.com/angular/angular / transitiveScopesForNgModule

Function transitiveScopesForNgModule

packages/core/src/render3/jit/module.ts:606–680  ·  view source on GitHub ↗
(moduleType: Type<T>)

Source from the content-addressed store, hash-verified

604 * @param moduleType module that transitive scope should be calculated for.
605 */
606export function transitiveScopesForNgModule<T>(moduleType: Type<T>): NgModuleTransitiveScopes {
607 const def = getNgModuleDefOrThrow(moduleType);
608
609 if (def.transitiveCompileScopes !== null) {
610 return def.transitiveCompileScopes;
611 }
612
613 const scopes: NgModuleTransitiveScopes = {
614 schemas: def.schemas || null,
615 compilation: {
616 directives: new Set<any>(),
617 pipes: new Set<any>(),
618 },
619 exported: {
620 directives: new Set<any>(),
621 pipes: new Set<any>(),
622 },
623 };
624
625 maybeUnwrapFn(def.imports).forEach(<I>(imported: Type<I>) => {
626 // When this module imports another, the imported module's exported directives and pipes are
627 // added to the compilation scope of this module.
628 const importedScope = transitiveScopesFor(imported);
629 importedScope.exported.directives.forEach((entry) => scopes.compilation.directives.add(entry));
630 importedScope.exported.pipes.forEach((entry) => scopes.compilation.pipes.add(entry));
631 });
632
633 maybeUnwrapFn(def.declarations).forEach((declared) => {
634 const declaredWithDefs = declared as Type<any> & {
635 ɵpipe?: any;
636 };
637
638 if (getPipeDef(declaredWithDefs)) {
639 scopes.compilation.pipes.add(declared);
640 } else {
641 // Either declared has a ɵcmp or ɵdir, or it's a component which hasn't
642 // had its template compiled yet. In either case, it gets added to the compilation's
643 // directives.
644 scopes.compilation.directives.add(declared);
645 }
646 });
647
648 maybeUnwrapFn(def.exports).forEach(<E>(exported: Type<E>) => {
649 const exportedType = exported as Type<E> & {
650 // Components, Directives, NgModules, and Pipes can all be exported.
651 ɵcmp?: any;
652 ɵdir?: any;
653 ɵmod?: NgModuleDef<E>;
654 ɵpipe?: any;
655 };
656
657 // Either the type is a module, a pipe, or a component/directive (which may not have a
658 // ɵcmp as it might be compiled asynchronously).
659 if (isNgModule(exportedType)) {
660 // When this module exports another, the exported module's exported directives and pipes are
661 // added to both the compilation and exported scopes of this module.
662 const exportedScope = transitiveScopesFor(exportedType);
663 exportedScope.exported.directives.forEach((entry) => {

Callers

nothing calls this directly

Calls 7

getNgModuleDefOrThrowFunction · 0.90
maybeUnwrapFnFunction · 0.90
getPipeDefFunction · 0.90
isNgModuleFunction · 0.90
transitiveScopesForFunction · 0.85
addMethod · 0.65
forEachMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…