Skip to content
Permalink
Browse files

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

…32234)

PR Close #32234
  • Loading branch information...
alan-agius4 authored and AndrewKushnir committed Aug 21, 2019
1 parent 62f4140 commit 424ab486722c8721fe3ffba76a8ae9d1aac66e5f
Showing with 27 additions and 4 deletions.
  1. +5 −4 packages/compiler-cli/src/perform_compile.ts
  2. +22 −0 packages/compiler-cli/test/perform_compile_spec.ts
@@ -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(
@@ -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);
});
});

0 comments on commit 424ab48

Please sign in to comment.
You can’t perform that action at this time.