@@ -8,42 +8,42 @@ export const migrateImportStatements = async (
8
8
project : Project ,
9
9
cliOptions : CliOptions ,
10
10
) => {
11
- // Get all typescript source files in the project and update any @ionic /angular imports to @ionic /angular/standalone
12
- for ( const sourceFile of project . getSourceFiles ( ) ) {
13
- if ( ! sourceFile . getFilePath ( ) . endsWith ( ' .ts' ) ) {
14
- continue ;
15
- }
11
+ // Get all typescript source files in the project and update any @ionic /angular imports to @ionic /angular/standalone
12
+ for ( const sourceFile of project . getSourceFiles ( ) ) {
13
+ if ( ! sourceFile . getFilePath ( ) . endsWith ( " .ts" ) ) {
14
+ continue ;
15
+ }
16
16
17
- let hasChanges = false ;
17
+ let hasChanges = false ;
18
18
19
- const importDeclarations = sourceFile . getImportDeclarations ( ) ;
20
- importDeclarations . forEach ( ( importDeclaration ) => {
21
- const moduleSpecifier = importDeclaration . getModuleSpecifierValue ( ) ;
22
- if ( moduleSpecifier === "@ionic/angular" ) {
23
- importDeclaration . setModuleSpecifier ( "@ionic/angular/standalone" ) ;
19
+ const importDeclarations = sourceFile . getImportDeclarations ( ) ;
20
+ importDeclarations . forEach ( ( importDeclaration ) => {
21
+ const moduleSpecifier = importDeclaration . getModuleSpecifierValue ( ) ;
22
+ if ( moduleSpecifier === "@ionic/angular" ) {
23
+ importDeclaration . setModuleSpecifier ( "@ionic/angular/standalone" ) ;
24
24
25
- const namedImports = importDeclaration . getNamedImports ( ) ;
26
- const importSpecifier = namedImports . find (
25
+ const namedImports = importDeclaration . getNamedImports ( ) ;
26
+ const importSpecifier = namedImports . find (
27
27
( n ) => n . getName ( ) === "IonicModule" ,
28
28
) ;
29
29
30
- if ( importSpecifier ) {
31
- if ( namedImports . length > 1 ) {
32
- // Remove the IonicModule import specifier.
33
- importSpecifier . remove ( ) ;
34
- } else {
35
- // If this is the only import specifier, remove the entire import declaration.
36
- importDeclaration . remove ( ) ;
37
- }
38
- removeImportFromNgModuleDecorator ( sourceFile , "IonicModule" ) ;
39
- }
40
-
41
- hasChanges = true ;
42
- }
43
- } ) ;
44
-
45
- if ( hasChanges ) {
46
- await saveFileChanges ( sourceFile , cliOptions ) ;
30
+ if ( importSpecifier ) {
31
+ if ( namedImports . length > 1 ) {
32
+ // Remove the IonicModule import specifier.
33
+ importSpecifier . remove ( ) ;
34
+ } else {
35
+ // If this is the only import specifier, remove the entire import declaration.
36
+ importDeclaration . remove ( ) ;
37
+ }
38
+ removeImportFromNgModuleDecorator ( sourceFile , "IonicModule" ) ;
47
39
}
40
+
41
+ hasChanges = true ;
42
+ }
43
+ } ) ;
44
+
45
+ if ( hasChanges ) {
46
+ await saveFileChanges ( sourceFile , cliOptions ) ;
48
47
}
48
+ }
49
49
} ;
0 commit comments