fix(ivy): ngtsc program emit ignoring custom transformers (#27837)

Fixes the `customTransformers` that are passed to the `NgtscProgram.emit` not being passed along.

PR Close #27837
This commit is contained in:
Kristiyan Kostadinov
2019-01-03 12:23:00 +02:00
committed by Kara Erickson
parent 48555f95c6
commit 13d23f315b
4 changed files with 50 additions and 9 deletions

View File

@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {CustomTransformers} from '@angular/compiler-cli';
import * as fs from 'fs';
import * as path from 'path';
import * as ts from 'typescript';
@ -111,9 +112,9 @@ export class NgtscTestEnvironment {
/**
* Run the compiler to completion, and assert that no errors occurred.
*/
driveMain(): void {
driveMain(customTransformers?: CustomTransformers): void {
const errorSpy = jasmine.createSpy('consoleError').and.callFake(console.error);
const exitCode = main(['-p', this.basePath], errorSpy);
const exitCode = main(['-p', this.basePath], errorSpy, undefined, customTransformers);
expect(errorSpy).not.toHaveBeenCalled();
expect(exitCode).toBe(0);
}

View File

@ -1227,4 +1227,32 @@ describe('ngtsc behavioral tests', () => {
expect(dtsContents).toContain('/// <amd-module name="@mymodule" />');
});
});
it('should execute custom transformers', () => {
let beforeCount = 0;
let afterCount = 0;
env.tsconfig();
env.write('test.ts', `
import {NgModule} from '@angular/core';
@NgModule({})
class Module {}
`);
env.driveMain({
beforeTs: [() => sourceFile => {
beforeCount++;
return sourceFile;
}],
afterTs: [() => sourceFile => {
afterCount++;
return sourceFile;
}],
});
expect(beforeCount).toBe(1);
expect(afterCount).toBe(1);
});
});