refactor(compiler-cli): implement ɵɵngDeclarePipe() (#40803)
This commit implements creating of `ɵɵngDeclarePipe()` calls in partial compilation, and processing of those calls in the linker and JIT compiler. See #40677 PR Close #40803
This commit is contained in:
committed by
Joey Perrott
parent
6425a6d543
commit
9cb43fb507
@@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {compilePipeFromMetadata, Identifiers, R3FactoryTarget, R3PipeMetadata, Statement, WrappedNodeExpr} from '@angular/compiler';
|
||||
import {compileDeclarePipeFromMetadata, compilePipeFromMetadata, Identifiers, R3FactoryTarget, R3PipeDef, R3PipeMetadata, Statement, WrappedNodeExpr} from '@angular/compiler';
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {ErrorCode, FatalDiagnosticError} from '../../diagnostics';
|
||||
@@ -134,10 +134,18 @@ export class PipeDecoratorHandler implements DecoratorHandler<Decorator, PipeHan
|
||||
}
|
||||
|
||||
compileFull(node: ClassDeclaration, analysis: Readonly<PipeHandlerData>): CompileResult[] {
|
||||
const meta = analysis.meta;
|
||||
const res = compilePipeFromMetadata(meta);
|
||||
const res = compilePipeFromMetadata(analysis.meta);
|
||||
return this.compilePipe(analysis, res);
|
||||
}
|
||||
|
||||
compilePartial(node: ClassDeclaration, analysis: Readonly<PipeHandlerData>): CompileResult[] {
|
||||
const res = compileDeclarePipeFromMetadata(analysis.meta);
|
||||
return this.compilePipe(analysis, res);
|
||||
}
|
||||
|
||||
private compilePipe(analysis: Readonly<PipeHandlerData>, def: R3PipeDef) {
|
||||
const factoryRes = compileNgFactoryDefField({
|
||||
...meta,
|
||||
...analysis.meta,
|
||||
injectFn: Identifiers.directiveInject,
|
||||
target: R3FactoryTarget.Pipe,
|
||||
});
|
||||
@@ -147,9 +155,9 @@ export class PipeDecoratorHandler implements DecoratorHandler<Decorator, PipeHan
|
||||
return [
|
||||
factoryRes, {
|
||||
name: 'ɵpipe',
|
||||
initializer: res.expression,
|
||||
initializer: def.expression,
|
||||
statements: [],
|
||||
type: res.type,
|
||||
type: def.type,
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user