( componentDefinition: ComponentDefinition<T>, )
| 329 | * @codeGenApi |
| 330 | */ |
| 331 | export function ɵɵdefineComponent<T>( |
| 332 | componentDefinition: ComponentDefinition<T>, |
| 333 | ): ComponentDef<any> { |
| 334 | return noSideEffects(() => { |
| 335 | // Initialize ngDevMode. This must be the first statement in ɵɵdefineComponent. |
| 336 | // See the `initNgDevMode` docstring for more information. |
| 337 | (typeof ngDevMode === 'undefined' || ngDevMode) && initNgDevMode(); |
| 338 | |
| 339 | const baseDef = getNgDirectiveDef(componentDefinition as DirectiveDefinition<T>); |
| 340 | const def: Writable<ComponentDef<T>> = { |
| 341 | ...baseDef, |
| 342 | decls: componentDefinition.decls, |
| 343 | vars: componentDefinition.vars, |
| 344 | template: componentDefinition.template, |
| 345 | consts: componentDefinition.consts || null, |
| 346 | ngContentSelectors: componentDefinition.ngContentSelectors, |
| 347 | onPush: componentDefinition.changeDetection !== ChangeDetectionStrategy.Eager, |
| 348 | directiveDefs: null!, // assigned in noSideEffects |
| 349 | pipeDefs: null!, // assigned in noSideEffects |
| 350 | dependencies: (baseDef.standalone && componentDefinition.dependencies) || null, |
| 351 | getStandaloneInjector: baseDef.standalone |
| 352 | ? (parentInjector: EnvironmentInjector) => { |
| 353 | return parentInjector.get(StandaloneService).getOrCreateStandaloneInjector(def); |
| 354 | } |
| 355 | : null, |
| 356 | getExternalStyles: null, |
| 357 | data: componentDefinition.data || {}, |
| 358 | encapsulation: componentDefinition.encapsulation || ViewEncapsulation.Emulated, |
| 359 | styles: componentDefinition.styles || EMPTY_ARRAY, |
| 360 | _: null, |
| 361 | schemas: componentDefinition.schemas || null, |
| 362 | tView: null, |
| 363 | id: '', |
| 364 | }; |
| 365 | |
| 366 | // TODO: Do we still need/want this ? |
| 367 | if (baseDef.standalone) { |
| 368 | performanceMarkFeature('NgStandalone'); |
| 369 | } |
| 370 | |
| 371 | initFeatures(def); |
| 372 | const dependencies = componentDefinition.dependencies; |
| 373 | def.directiveDefs = extractDefListOrFactory(dependencies, extractDirectiveDef); |
| 374 | def.pipeDefs = extractDefListOrFactory(dependencies, getPipeDef); |
| 375 | def.id = getComponentId(def); |
| 376 | |
| 377 | return def; |
| 378 | }); |
| 379 | } |
| 380 | |
| 381 | export function extractDirectiveDef(type: Type<any>): DirectiveDef<any> | ComponentDef<any> | null { |
| 382 | return getComponentDef(type) || getDirectiveDef(type); |
no test coverage detected