2018-11-05 12:21:27 -05:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
// Imports
|
|
|
|
const {extend, parse} = require('cjson');
|
|
|
|
const {readFileSync, writeFileSync} = require('fs');
|
|
|
|
const {join, resolve} = require('path');
|
|
|
|
|
|
|
|
// Constants
|
|
|
|
const ROOT_DIR = resolve(__dirname, '..');
|
2019-10-02 12:26:14 -04:00
|
|
|
const TS_CONFIG_PATH = join(ROOT_DIR, 'tsconfig.json');
|
2018-11-05 12:21:27 -05:00
|
|
|
const NG_COMPILER_OPTS = {
|
|
|
|
angularCompilerOptions: {
|
2019-09-30 17:54:00 -04:00
|
|
|
enableIvy: false,
|
2018-11-05 12:21:27 -05:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
// Run
|
|
|
|
_main(process.argv.slice(2));
|
|
|
|
|
|
|
|
// Functions - Definitions
|
2019-04-02 14:53:49 -04:00
|
|
|
function _main() {
|
2019-09-30 17:54:00 -04:00
|
|
|
// Enable ViewIngine/Disable Ivy in TS config.
|
2019-10-02 12:26:14 -04:00
|
|
|
console.log(`\nModifying \`${TS_CONFIG_PATH}\`...`);
|
|
|
|
const oldTsConfigStr = readFileSync(TS_CONFIG_PATH, 'utf8');
|
2018-11-05 12:21:27 -05:00
|
|
|
const oldTsConfigObj = parse(oldTsConfigStr);
|
|
|
|
const newTsConfigObj = extend(true, oldTsConfigObj, NG_COMPILER_OPTS);
|
2019-04-30 19:24:13 -04:00
|
|
|
const newTsConfigStr = `${JSON.stringify(newTsConfigObj, null, 2)}\n`;
|
2019-04-02 14:53:49 -04:00
|
|
|
console.log(`\nNew config: ${newTsConfigStr}`);
|
2019-10-02 12:26:14 -04:00
|
|
|
writeFileSync(TS_CONFIG_PATH, newTsConfigStr);
|
2018-11-05 12:21:27 -05:00
|
|
|
|
2019-04-02 14:53:49 -04:00
|
|
|
// Done.
|
2019-09-30 17:54:00 -04:00
|
|
|
console.log('\nReady to build with ViewEngine!');
|
|
|
|
console.log('(To switch back to Ivy (with packages from npm), undo the changes in ' +
|
2019-10-02 12:26:14 -04:00
|
|
|
`\`${TS_CONFIG_PATH}\` and run \`yarn aio-use-npm && yarn example-use-npm\`.)`);
|
2018-11-05 12:21:27 -05:00
|
|
|
}
|