77 */
88import { Rule } from '@angular-devkit/schematics' ;
99import { removePackageJsonDependency } from '../../utility/dependencies' ;
10- import { findPropertyInAstObject , removePropertyInAstObject } from '../../utility/json-utils' ;
10+ import { JSONFile } from '../../utility/json-file' ;
11+ import { findPropertyInAstObject } from '../../utility/json-utils' ;
1112import { Builders } from '../../utility/workspace-models' ;
12- import { getAllOptions , getTargets , getWorkspace , readJsonFileAsAstObject } from './utils' ;
13+ import { getAllOptions , getTargets , getWorkspace } from './utils' ;
1314
1415/**
1516 * Remove tsickle from libraries
@@ -28,23 +29,17 @@ export function removeTsickle(): Rule {
2829 }
2930
3031 const tsConfigPath = tsConfigOption . value ;
31- const tsConfigAst = readJsonFileAsAstObject ( tree , tsConfigPath ) ;
32- if ( ! tsConfigAst ) {
32+ let tsConfigJson ;
33+ try {
34+ tsConfigJson = new JSONFile ( tree , tsConfigPath ) ;
35+ } catch {
3336 logger . warn ( `Cannot find file: ${ tsConfigPath } ` ) ;
3437
3538 continue ;
3639 }
3740
38- const ngCompilerOptions = findPropertyInAstObject ( tsConfigAst , 'angularCompilerOptions' ) ;
39- if ( ngCompilerOptions && ngCompilerOptions . kind === 'object' ) {
40- // remove annotateForClosureCompiler option
41- const recorder = tree . beginUpdate ( tsConfigPath ) ;
42- removePropertyInAstObject ( recorder , ngCompilerOptions , 'annotateForClosureCompiler' ) ;
43- tree . commitUpdate ( recorder ) ;
44- }
41+ tsConfigJson . remove ( [ 'angularCompilerOptions' , 'annotateForClosureCompiler' ] ) ;
4542 }
4643 }
47-
48- return tree ;
4944 } ;
5045}
0 commit comments