feat(ivy): support pipe compilation from local metadata (#24703)

This updates the r3_pipe_compiler to not depend on global analysis,
and to produce ngPipeDef instructions in the same way that the other
compilers do. It's a precursor to JIT and AOT implementations of
@Pipe compilation.

PR Close #24703
This commit is contained in:
Alex Rickabaugh
2018-06-26 10:43:06 -07:00
committed by Miško Hevery
parent ffbacdf4ac
commit dbdcfed2bd
11 changed files with 78 additions and 43 deletions

View File

@ -15,7 +15,7 @@ import {ConstantPool} from '../../src/constant_pool';
import * as html from '../../src/ml_parser/ast';
import {removeWhitespaces} from '../../src/ml_parser/html_whitespaces';
import * as o from '../../src/output/output_ast';
import {compilePipe} from '../../src/render3/r3_pipe_compiler';
import {compilePipeFromRender2} from '../../src/render3/r3_pipe_compiler';
import {htmlAstToRender3Ast} from '../../src/render3/r3_template_transform';
import {compileComponentFromRender2, compileDirectiveFromRender2} from '../../src/render3/view/compiler';
import {BindingParser} from '../../src/template_parser/binding_parser';
@ -320,7 +320,7 @@ export function compile(
} else if (resolver.isPipe(pipeOrDirective)) {
const metadata = resolver.getPipeMetadata(pipeOrDirective);
if (metadata) {
compilePipe(outputCtx, metadata, reflector);
compilePipeFromRender2(outputCtx, metadata, reflector);
}
}
}

View File

@ -1072,7 +1072,7 @@ describe('compiler compliance', () => {
it('should render pipes', () => {
const MyPipeDefinition = `
static ngPipeDef = $r3$.ɵdefinePipe(
{name: 'myPipe', type: MyPipe, factory: function MyPipe_Factory() { return new MyPipe(); }});
{name: 'myPipe', type: MyPipe, factory: function MyPipe_Factory() { return new MyPipe(); }, pure: false});
`;
const MyPurePipeDefinition = `