build(docs-infra): make tsconfig path detection in switch-to-ivy
more robust (#29989)
In light of #29926, that will change the path of `tsconfig.app.json`, this commit switches from a hard-coded `tsconfig.app.json` path to looking it up in `angular.json` (to be more future-proof). PR Close #29989
This commit is contained in:
parent
11eef85133
commit
5650e3847b
@ -10,7 +10,7 @@ set('-e');
|
|||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const ROOT_DIR = resolve(__dirname, '..');
|
const ROOT_DIR = resolve(__dirname, '..');
|
||||||
const TS_CONFIG_PATH = join(ROOT_DIR, 'src/tsconfig.app.json');
|
const NG_JSON = join(ROOT_DIR, 'angular.json');
|
||||||
const NG_COMPILER_OPTS = {
|
const NG_COMPILER_OPTS = {
|
||||||
angularCompilerOptions: {
|
angularCompilerOptions: {
|
||||||
// Related Jira issue: FW-737
|
// Related Jira issue: FW-737
|
||||||
@ -24,14 +24,18 @@ _main(process.argv.slice(2));
|
|||||||
|
|
||||||
// Functions - Definitions
|
// Functions - Definitions
|
||||||
function _main() {
|
function _main() {
|
||||||
|
// Detect path to `tsconfig.app.json`.
|
||||||
|
const ngConfig = parse(readFileSync(NG_JSON, 'utf8'));
|
||||||
|
const tsConfigPath = join(ROOT_DIR, ngConfig.projects.site.architect.build.options.tsConfig);
|
||||||
|
|
||||||
// Enable Ivy in TS config.
|
// Enable Ivy in TS config.
|
||||||
console.log(`\nModifying \`${TS_CONFIG_PATH}\`...`);
|
console.log(`\nModifying \`${tsConfigPath}\`...`);
|
||||||
const oldTsConfigStr = readFileSync(TS_CONFIG_PATH, 'utf8');
|
const oldTsConfigStr = readFileSync(tsConfigPath, 'utf8');
|
||||||
const oldTsConfigObj = parse(oldTsConfigStr);
|
const oldTsConfigObj = parse(oldTsConfigStr);
|
||||||
const newTsConfigObj = extend(true, oldTsConfigObj, NG_COMPILER_OPTS);
|
const newTsConfigObj = extend(true, oldTsConfigObj, NG_COMPILER_OPTS);
|
||||||
const newTsConfigStr = JSON.stringify(newTsConfigObj, null, 2);
|
const newTsConfigStr = JSON.stringify(newTsConfigObj, null, 2);
|
||||||
console.log(`\nNew config: ${newTsConfigStr}`);
|
console.log(`\nNew config: ${newTsConfigStr}`);
|
||||||
writeFileSync(TS_CONFIG_PATH, newTsConfigStr);
|
writeFileSync(tsConfigPath, newTsConfigStr);
|
||||||
|
|
||||||
// Run ngcc.
|
// Run ngcc.
|
||||||
const ngccArgs = '--loglevel debug --properties es2015 module';
|
const ngccArgs = '--loglevel debug --properties es2015 module';
|
||||||
@ -41,5 +45,5 @@ function _main() {
|
|||||||
// Done.
|
// Done.
|
||||||
console.log('\nReady to build with Ivy!');
|
console.log('\nReady to build with Ivy!');
|
||||||
console.log('(To switch back to ViewEngine (with packages from npm), undo the changes in ' +
|
console.log('(To switch back to ViewEngine (with packages from npm), undo the changes in ' +
|
||||||
`\`${TS_CONFIG_PATH}\` and run \`yarn aio-use-npm && yarn example-use-npm\`.)`);
|
`\`${tsConfigPath}\` and run \`yarn aio-use-npm && yarn example-use-npm\`.)`);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user