@@ -17,6 +17,7 @@ export function replaceBootstrap(
17
17
shouldTransform : ( fileName : string ) => boolean ,
18
18
getEntryModule : ( ) => { path : string , className : string } | null ,
19
19
getTypeChecker : ( ) => ts . TypeChecker ,
20
+ enableIvy ?: boolean ,
20
21
) : ts . TransformerFactory < ts . SourceFile > {
21
22
22
23
const standardTransform : StandardTransform = function ( sourceFile : ts . SourceFile ) {
@@ -37,9 +38,6 @@ export function replaceBootstrap(
37
38
return [ ] ;
38
39
}
39
40
40
- const relativeEntryModulePath = relative ( dirname ( sourceFile . fileName ) , entryModule . path ) ;
41
- const normalizedEntryModulePath = `./${ relativeEntryModulePath } ` . replace ( / \\ / g, '/' ) ;
42
-
43
41
// Find the bootstrap calls.
44
42
entryModuleIdentifiers . forEach ( entryModuleIdentifier => {
45
43
// Figure out if it's a `platformBrowserDynamic().bootstrapModule(AppModule)` call.
@@ -79,19 +77,28 @@ export function replaceBootstrap(
79
77
const idNgFactory = ts . createUniqueName ( '__NgCli_bootstrap_' ) ;
80
78
81
79
// Add the transform operations.
82
- const factoryClassName = entryModule . className + 'NgFactory' ;
83
- const factoryModulePath = normalizedEntryModulePath + '.ngfactory' ;
80
+ const relativeEntryModulePath = relative ( dirname ( sourceFile . fileName ) , entryModule . path ) ;
81
+ let className = entryModule . className ;
82
+ let modulePath = `./${ relativeEntryModulePath } ` . replace ( / \\ / g, '/' ) ;
83
+ let bootstrapIdentifier = 'bootstrapModule' ;
84
+
85
+ if ( ! enableIvy ) {
86
+ className += 'NgFactory' ;
87
+ modulePath += '.ngfactory' ;
88
+ bootstrapIdentifier = 'bootstrapModuleFactory' ;
89
+ }
90
+
84
91
ops . push (
85
92
// Replace the entry module import.
86
- ...insertStarImport ( sourceFile , idNgFactory , factoryModulePath ) ,
93
+ ...insertStarImport ( sourceFile , idNgFactory , modulePath ) ,
87
94
new ReplaceNodeOperation ( sourceFile , entryModuleIdentifier ,
88
- ts . createPropertyAccess ( idNgFactory , ts . createIdentifier ( factoryClassName ) ) ) ,
95
+ ts . createPropertyAccess ( idNgFactory , ts . createIdentifier ( className ) ) ) ,
89
96
// Replace the platformBrowserDynamic import.
90
97
...insertStarImport ( sourceFile , idPlatformBrowser , '@angular/platform-browser' ) ,
91
98
new ReplaceNodeOperation ( sourceFile , platformBrowserDynamicIdentifier ,
92
99
ts . createPropertyAccess ( idPlatformBrowser , 'platformBrowser' ) ) ,
93
100
new ReplaceNodeOperation ( sourceFile , bootstrapModuleIdentifier ,
94
- ts . createIdentifier ( 'bootstrapModuleFactory' ) ) ,
101
+ ts . createIdentifier ( bootstrapIdentifier ) ) ,
95
102
) ;
96
103
} ) ;
97
104
0 commit comments