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

Function compileService

packages/core/src/di/jit/service.ts:25–72  ·  view source on GitHub ↗
(type: Type<any>, meta?: Service)

Source from the content-addressed store, hash-verified

23 * defition (`ɵprov`) onto the type.
24 */
25export function compileService(type: Type<any>, meta?: Service): void {
26 let def: any = null;
27 let factoryDef: any = null;
28
29 // if NG_PROV_DEF is already defined on this class then don't overwrite it
30 if (!type.hasOwnProperty(NG_PROV_DEF)) {
31 Object.defineProperty(type, NG_PROV_DEF, {
32 get: () => {
33 if (def === null) {
34 const compiler = getCompilerFacade({
35 usage: JitCompilerUsage.Decorator,
36 kind: 'service',
37 type,
38 });
39 def = compiler.compileService(
40 angularCoreDiEnv,
41 `ng:///${type.name}/ɵprov.js`,
42 getServiceMetadata(type, meta),
43 );
44 }
45 return def;
46 },
47 });
48 }
49
50 if (!type.hasOwnProperty(NG_FACTORY_DEF)) {
51 Object.defineProperty(type, NG_FACTORY_DEF, {
52 get: () => {
53 if (factoryDef === null) {
54 const compiler = getCompilerFacade({
55 usage: JitCompilerUsage.Decorator,
56 kind: 'service',
57 type,
58 });
59 factoryDef = compiler.compileFactory(angularCoreDiEnv, `ng:///${type.name}/ɵfac.js`, {
60 name: type.name,
61 type,
62 typeArgumentCount: 0,
63 deps: reflectDependencies(type),
64 target: compiler.FactoryTarget.Service,
65 });
66 }
67 return factoryDef;
68 },
69 configurable: true,
70 });
71 }
72}
73
74function getServiceMetadata(type: Type<any>, srcMeta?: Service): R3ServiceMetadataFacade {
75 const compilerMeta: R3ServiceMetadataFacade = {

Callers 1

service.tsFile · 0.90

Calls 5

getCompilerFacadeFunction · 0.90
reflectDependenciesFunction · 0.90
getServiceMetadataFunction · 0.85
compileServiceMethod · 0.65
compileFactoryMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…