-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@schematics/angular): add migration to enable AOT by default
With this change we enable the AOT option for the browser builder when an application will use Ivy as rendering engine.
- Loading branch information
1 parent
87b01ff
commit f4691a5
Showing
4 changed files
with
261 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
packages/schematics/angular/migrations/update-9/utils_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
|
||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
import { HostTree } from '@angular-devkit/schematics'; | ||
import { isIvyEnabled } from './utils'; | ||
|
||
describe('migrations update-9 utils', () => { | ||
describe('isIvyEnabled', () => { | ||
let tree: HostTree; | ||
|
||
beforeEach(() => { | ||
tree = new HostTree(); | ||
}); | ||
|
||
it('should return false when disabled in base tsconfig', () => { | ||
tree.create('tsconfig.json', JSON.stringify({ | ||
angularCompilerOptions: { | ||
enableIvy: false, | ||
}, | ||
})); | ||
|
||
tree.create('foo/tsconfig.app.json', JSON.stringify({ | ||
extends: '../tsconfig.json', | ||
})); | ||
|
||
expect(isIvyEnabled(tree, 'foo/tsconfig.app.json')).toBe(false); | ||
}); | ||
|
||
it('should return true when enable in child tsconfig but disabled in base tsconfig', () => { | ||
tree.create('tsconfig.json', JSON.stringify({ | ||
angularCompilerOptions: { | ||
enableIvy: false, | ||
}, | ||
})); | ||
|
||
tree.create('foo/tsconfig.app.json', JSON.stringify({ | ||
extends: '../tsconfig.json', | ||
angularCompilerOptions: { | ||
enableIvy: true, | ||
}, | ||
})); | ||
|
||
expect(isIvyEnabled(tree, 'foo/tsconfig.app.json')).toBe(true); | ||
}); | ||
|
||
it('should return false when disabled in child tsconfig but enabled in base tsconfig', () => { | ||
tree.create('tsconfig.json', JSON.stringify({ | ||
angularCompilerOptions: { | ||
enableIvy: true, | ||
}, | ||
})); | ||
|
||
tree.create('foo/tsconfig.app.json', JSON.stringify({ | ||
extends: '../tsconfig.json', | ||
angularCompilerOptions: { | ||
enableIvy: false, | ||
}, | ||
})); | ||
|
||
expect(isIvyEnabled(tree, 'foo/tsconfig.app.json')).toBe(false); | ||
}); | ||
|
||
it('should return false when disabled in base with multiple extends', () => { | ||
tree.create('tsconfig.json', JSON.stringify({ | ||
angularCompilerOptions: { | ||
enableIvy: false, | ||
}, | ||
})); | ||
|
||
tree.create('foo/tsconfig.project.json', JSON.stringify({ | ||
extends: '../tsconfig.json', | ||
})); | ||
|
||
tree.create('foo/tsconfig.app.json', JSON.stringify({ | ||
extends: './tsconfig.project.json', | ||
})); | ||
|
||
expect(isIvyEnabled(tree, 'foo/tsconfig.app.json')).toBe(false); | ||
}); | ||
|
||
it('should return true when enable in intermediate tsconfig with multiple extends', () => { | ||
tree.create('tsconfig.json', JSON.stringify({ | ||
angularCompilerOptions: { | ||
enableIvy: false, | ||
}, | ||
})); | ||
|
||
tree.create('foo/tsconfig.project.json', JSON.stringify({ | ||
extends: '../tsconfig.json', | ||
angularCompilerOptions: { | ||
enableIvy: true, | ||
}, | ||
})); | ||
|
||
tree.create('foo/tsconfig.app.json', JSON.stringify({ | ||
extends: './tsconfig.project.json', | ||
})); | ||
|
||
expect(isIvyEnabled(tree, 'foo/tsconfig.app.json')).toBe(true); | ||
}); | ||
}); | ||
}); |