7
7
*/
8
8
import { Rule } from '@angular-devkit/schematics' ;
9
9
import { 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' ;
11
12
import { Builders } from '../../utility/workspace-models' ;
12
- import { getAllOptions , getTargets , getWorkspace , readJsonFileAsAstObject } from './utils' ;
13
+ import { getAllOptions , getTargets , getWorkspace } from './utils' ;
13
14
14
15
/**
15
16
* Remove tsickle from libraries
@@ -28,23 +29,17 @@ export function removeTsickle(): Rule {
28
29
}
29
30
30
31
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 {
33
36
logger . warn ( `Cannot find file: ${ tsConfigPath } ` ) ;
34
37
35
38
continue ;
36
39
}
37
40
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' ] ) ;
45
42
}
46
43
}
47
-
48
- return tree ;
49
44
} ;
50
45
}
0 commit comments