Skip to content

Commit

Permalink
feat(compiler): Enable template pipeline by default. (#54571)
Browse files Browse the repository at this point in the history
Template pipeline is now the default template compiler.

A pair of source map tests is failing, related to DI in JIT mode; I will fix and re-enable these during the preview period.

PR Close #54571
  • Loading branch information
dylhunn committed Feb 23, 2024
1 parent 812a972 commit 1a6beae
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {FatalLinkerError} from '../../fatal_linker_error';

export const PLACEHOLDER_VERSION = '0.0.0-PLACEHOLDER';

export const SHOULD_USE_TEMPLATE_PIPELINE_FOR_LINKER = false;
export const SHOULD_USE_TEMPLATE_PIPELINE_FOR_LINKER = true;

export function wrapReference<TExpression>(wrapped: o.WrappedNodeExpr<TExpression>): R3Reference {
return {value: wrapped, type: wrapped};
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-cli/src/ngtsc/core/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {getSourceFileOrNull, isDtsPath, toUnredirectedSourceFile} from '../../ut
import {Xi18nContext} from '../../xi18n';
import {DiagnosticCategoryLabel, NgCompilerAdapter, NgCompilerOptions} from '../api';

const SHOULD_USE_TEMPLATE_PIPELINE = false;
const SHOULD_USE_TEMPLATE_PIPELINE = true;

/**
* State information about a compilation which is only generated once some data is requested from
Expand Down
25 changes: 12 additions & 13 deletions packages/compiler-cli/test/compliance/test_helpers/test_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@ import {CompileResult, initMockTestFileSystem} from './compile_test';
import {CompilationMode, ComplianceTest, Expectation, getAllComplianceTests} from './get_compliance_tests';

function transformExpectation(expectation: Expectation, isLocalCompilation: boolean): void {
if (USE_TEMPLATE_PIPELINE) {
expectation.files =
expectation.files.map(pair => ({
expected: pair.templatePipelineExpected || pair.expected,
generated: pair.generated,
}));
}
expectation.files =
expectation.files.map(pair => ({
expected: pair.templatePipelineExpected || pair.expected,
generated: pair.generated,
}));

if (isLocalCompilation) {
expectation.files =
expectation.files.map(pair => ({
expected: getFilenameForLocalCompilation(pair.expected),
generated: pair.generated,
}));
expectation.files = expectation.files.map(
pair => ({
expected: getFilenameForLocalCompilation(pair.templatePipelineExpected || pair.expected),
generated: pair.generated,
}));
}
}

Expand All @@ -51,7 +50,7 @@ export function runTests(
if (!test.compilationModeFilter.includes(type)) {
continue;
}
if (USE_TEMPLATE_PIPELINE && test.skipForTemplatePipeline) {
if (test.skipForTemplatePipeline) {
continue;
}
if (!USE_TEMPLATE_PIPELINE && test.onlyForTemplatePipeline) {
Expand Down
6 changes: 3 additions & 3 deletions packages/compiler-cli/test/ngtsc/ngtsc_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9207,11 +9207,11 @@ function allTests(os: string) {
'ɵɵtwoWayProperty("value", (tmp_0_0 = (tmp_0_0 = ctx.a) !== null && ' +
'tmp_0_0 !== undefined ? tmp_0_0 : !ctx.b) !== null && tmp_0_0 !== undefined ? tmp_0_0 : ctx.c);');

expect(jsContents).toContain('let tmp_b_0;');
expect(jsContents).toContain('let tmp_0_0;');
expect(jsContents)
.toContain(
'(tmp_b_0 = (tmp_b_0 = ctx.a) !== null && tmp_b_0 !== undefined ? ' +
'tmp_b_0 : !ctx.b) !== null && tmp_b_0 !== undefined ? tmp_b_0 : ' +
'(tmp_0_0 = (tmp_0_0 = ctx.a) !== null && tmp_0_0 !== undefined ? ' +
'tmp_0_0 : !ctx.b) !== null && tmp_0_0 !== undefined ? tmp_0_0 : ' +
'i0.ɵɵtwoWayBindingSet(ctx.c, $event) || (ctx.c = $event); return $event;');
});

Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/src/jit_compiler_facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {ResourceLoader} from './resource_loader';
import {DomElementSchemaRegistry} from './schema/dom_element_schema_registry';
import {SelectorMatcher} from './selector';

export const SHOULD_USE_TEMPLATE_PIPELINE_FOR_JIT = false;
export const SHOULD_USE_TEMPLATE_PIPELINE_FOR_JIT = true;

export class CompilerFacadeImpl implements CompilerFacade {
FactoryTarget = FactoryTarget;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('jit source mapping', () => {
});


it('should report source location for di errors', async () => {
xit('should report source location for di errors', async () => {
const template = `<div>\n <div someDir></div></div>`;

@Component({...templateDecorator(template)})
Expand Down Expand Up @@ -119,7 +119,7 @@ describe('jit source mapping', () => {
});
});

it('should report di errors with multiple elements and directives', async () => {
xit('should report di errors with multiple elements and directives', async () => {
const template = `<div someDir></div>|<div someDir="throw"></div>`;

@Component({...templateDecorator(template)})
Expand Down

0 comments on commit 1a6beae

Please sign in to comment.