-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathenableIvy.ts
39 lines (30 loc) · 1.1 KB
/
enableIvy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env node
'use strict';
import * as fs from 'fs';
import * as path from 'path';
function baseDir(...dirs: string[]): string {
return path.resolve(__dirname, '.', ...dirs);
}
async function main(enableIvy: string) {
const doEnable = enableIvy === 'true' ? true : false;
console.log(`Enabling Ivy: ${doEnable}`);
const tsconfigPath = baseDir('tsconfig.app.json');
const angularConfigPath = baseDir('angular.json');
let tsconfigApp = JSON.parse(fs.readFileSync(tsconfigPath, 'utf8'));
let angularJson = JSON.parse(fs.readFileSync(angularConfigPath, 'utf8'));
if (doEnable) {
tsconfigApp['angularCompilerOptions'] = {
enableIvy: true
};
angularJson.projects.lazymodules.architect.build.options.aot = true;
} else {
delete tsconfigApp['angularCompilerOptions'];
angularJson.projects.lazymodules.architect.build.options.aot = false;
}
fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfigApp, null, 1));
fs.writeFileSync(angularConfigPath, JSON.stringify(angularJson, null, 1));
}
main(process.argv[2]).catch(err => {
console.error(err);
process.exit(1);
});