fix(compiler): return enableIvy true when using `readConfiguration` (#32234)

PR Close #32234
This commit is contained in:
Alan 2019-08-21 08:46:40 +02:00 committed by Andrew Kushnir
parent 62f4140634
commit 424ab48672
2 changed files with 27 additions and 4 deletions

View File

@ -120,10 +120,11 @@ export function calcProjectFileAndBasePath(project: string):
export function createNgCompilerOptions(
basePath: string, config: any, tsOptions: ts.CompilerOptions): api.CompilerOptions {
// enableIvy `ngtsc` is an alias for `true`.
if (config.angularCompilerOptions && config.angularCompilerOptions.enableIvy === 'ngtsc') {
config.angularCompilerOptions.enableIvy = true;
}
return {...tsOptions, ...config.angularCompilerOptions, genDir: basePath, basePath};
const {angularCompilerOptions = {}} = config;
const {enableIvy} = angularCompilerOptions;
angularCompilerOptions.enableIvy = enableIvy !== false && enableIvy !== 'tsc';
return {...tsOptions, ...angularCompilerOptions, genDir: basePath, basePath};
}
export function readConfiguration(

View File

@ -55,4 +55,26 @@ describe('perform_compile', () => {
expect(options.skipMetadataEmit).toBe(true);
});
it(`should return 'enableIvy: true' when enableIvy is not defined in "angularCompilerOptions"`,
() => {
writeSomeConfigs();
const {options} = readConfiguration(path.resolve(basePath, 'tsconfig-level-1.json'));
expect(options.enableIvy).toBe(true);
});
it(`should return 'enableIvy: false' when enableIvy is disabled in "angularCompilerOptions"`,
() => {
writeSomeConfigs();
support.writeFiles({
'tsconfig-level-3.json': `{
"angularCompilerOptions": {
"enableIvy": false
}
}
`,
});
const {options} = readConfiguration(path.resolve(basePath, 'tsconfig-level-1.json'));
expect(options.enableIvy).toBe(false);
});
});