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:
@ -32,7 +32,7 @@ var rootSelectorVar = o.variable('rootSelector');
|
||||
|
||||
export class ViewFactoryDependency {
|
||||
constructor(
|
||||
public comp: CompileDirectiveMetadata, public placeholder: CompileIdentifierMetadata) {}
|
||||
public comp: CompileIdentifierMetadata, public placeholder: CompileIdentifierMetadata) {}
|
||||
}
|
||||
|
||||
export class ComponentFactoryDependency {
|
||||
@ -208,7 +208,8 @@ class ViewBuilderVisitor implements TemplateAstVisitor {
|
||||
if (isPresent(component)) {
|
||||
let nestedComponentIdentifier =
|
||||
new CompileIdentifierMetadata({name: getViewFactoryName(component, 0)});
|
||||
this.targetDependencies.push(new ViewFactoryDependency(component, nestedComponentIdentifier));
|
||||
this.targetDependencies.push(
|
||||
new ViewFactoryDependency(component.type, nestedComponentIdentifier));
|
||||
let precompileComponentIdentifiers =
|
||||
component.precompile.map((precompileComp: CompileIdentifierMetadata) => {
|
||||
var id = new CompileIdentifierMetadata({name: precompileComp.name});
|
||||
|
Reference in New Issue
Block a user