feat(compiler): support sync runtime compile
Adds new abstraction `Compiler` with methods `compileComponentAsync` and `compileComponentSync`. This is in preparation of deprecating `ComponentResolver`. `compileComponentSync` is able to compile components synchronously given all components either have an inline template or they have been compiled before. Also changes `TestComponentBuilder.createSync` to take a `Type` and use the new `compileComponentSync` method. Also supports overriding the component metadata even if the component has already been compiled. Also fixes #7084 in a better way. BREAKING CHANGE: `TestComponentBuilder.createSync` now takes a component type and throws if not all templates are either inlined are compiled before via `createAsync`. Closes #9594
This commit is contained in:
6
tools/public_api_guard/compiler/testing.d.ts
vendored
6
tools/public_api_guard/compiler/testing.d.ts
vendored
@ -1,4 +1,5 @@
|
||||
export declare class MockDirectiveResolver extends DirectiveResolver {
|
||||
constructor(_injector: Injector);
|
||||
resolve(type: Type): DirectiveMetadata;
|
||||
setProvidersOverride(type: Type, providers: any[]): void;
|
||||
setViewProvidersOverride(type: Type, viewProviders: any[]): void;
|
||||
@ -22,7 +23,7 @@ export declare class MockSchemaRegistry implements ElementSchemaRegistry {
|
||||
}
|
||||
|
||||
export declare class MockViewResolver extends ViewResolver {
|
||||
constructor();
|
||||
constructor(_injector: Injector);
|
||||
overrideViewDirective(component: Type, from: Type, to: Type): void;
|
||||
resolve(component: Type): ViewMetadata;
|
||||
setAnimations(component: Type, animations: AnimationEntryMetadata[]): void;
|
||||
@ -32,7 +33,8 @@ export declare class MockViewResolver extends ViewResolver {
|
||||
|
||||
export declare class OverridingTestComponentBuilder extends TestComponentBuilder {
|
||||
constructor(injector: Injector);
|
||||
createAsync(rootComponentType: Type): Promise<ComponentFixture<any>>;
|
||||
createAsync<T>(rootComponentType: ConcreteType<T>): Promise<ComponentFixture<T>>;
|
||||
createSync<T>(rootComponentType: ConcreteType<T>): ComponentFixture<T>;
|
||||
overrideAnimations(componentType: Type, animations: AnimationEntryMetadata[]): TestComponentBuilder;
|
||||
overrideDirective(componentType: Type, from: Type, to: Type): OverridingTestComponentBuilder;
|
||||
overrideProviders(type: Type, providers: any[]): OverridingTestComponentBuilder;
|
||||
|
Reference in New Issue
Block a user