(type: Type<any>, meta?: Service)
| 23 | * defition (`ɵprov`) onto the type. |
| 24 | */ |
| 25 | export 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 | |
| 74 | function getServiceMetadata(type: Type<any>, srcMeta?: Service): R3ServiceMetadataFacade { |
| 75 | const compilerMeta: R3ServiceMetadataFacade = { |
no test coverage detected
searching dependent graphs…