feat(ivy): avoid unnecessary recompilations in TestBed (#29294)
Prior to this change, we always recompile all Components/Directives/Pipes even if they were AOT-compiled and had no overrides. This is causing problems in case we try to recompile a Component with "templateUrl" or "styleUrls" (which were already resolved in case of AOT) and generally this unnecessary work that TestBed was doing is not required. This commit adds extra logic to check whether a Component/Directive/Pipe already have compiled NG def (like ngComponentDef) and whether there are no overrides present - in this case recompilation is skipped. Recompilation is also skipped in case a Component/Directive has only Provider overrides - in this situation providers resolver function is patched to reflect overrides. Provider overrides are very common in g3, thus this code path ensures no full recompilation. PR Close #29294
This commit is contained in:

committed by
Matias Niemelä

parent
86aba1e8f3
commit
0244a2433e
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
import {SchemaMetadata, ViewEncapsulation} from '../../core';
|
||||
import {ProcessProvidersFunction} from '../../di/interface/provider';
|
||||
import {Type} from '../../interface/type';
|
||||
import {CssSelectorList} from './projection';
|
||||
|
||||
@ -138,7 +139,9 @@ export interface DirectiveDef<T> extends BaseDef<T> {
|
||||
type: Type<T>;
|
||||
|
||||
/** Function that resolves providers and publishes them into the DI system. */
|
||||
providersResolver: (<U extends T>(def: DirectiveDef<U>) => void)|null;
|
||||
providersResolver:
|
||||
(<U extends T>(def: DirectiveDef<U>, processProvidersFn?: ProcessProvidersFunction) =>
|
||||
void)|null;
|
||||
|
||||
/** The selectors that will be used to match nodes to this directive. */
|
||||
readonly selectors: CssSelectorList;
|
||||
|
Reference in New Issue
Block a user