@@ -15,14 +15,16 @@ import {
15
15
import { AngularCompilerPlugin } from '@ngtools/webpack' ;
16
16
import { getResolvedEntryModule } from "../utils/transformers-utils" ;
17
17
18
-
19
18
export function nsReplaceBootstrap ( getNgCompiler : ( ) => AngularCompilerPlugin ) : ts . TransformerFactory < ts . SourceFile > {
20
19
const shouldTransform = ( fileName ) => ! fileName . endsWith ( '.ngfactory.ts' ) && ! fileName . endsWith ( '.ngstyle.ts' ) ;
21
20
const getTypeChecker = ( ) => getNgCompiler ( ) . typeChecker ;
22
21
23
22
const standardTransform : StandardTransform = function ( sourceFile : ts . SourceFile ) {
24
23
const ops : TransformOperation [ ] = [ ] ;
25
- const entryModule = getResolvedEntryModule ( getNgCompiler ( ) ) ;
24
+ const ngCompiler = getNgCompiler ( ) ;
25
+ // TODO: use something public when available
26
+ const enableIvy = ( < any > ngCompiler ) . _compilerOptions && ( < any > ngCompiler ) . _compilerOptions . enableIvy ;
27
+ const entryModule = getResolvedEntryModule ( ngCompiler ) ;
26
28
27
29
if ( ! shouldTransform ( sourceFile . fileName ) || ! entryModule ) {
28
30
return ops ;
@@ -73,16 +75,15 @@ export function nsReplaceBootstrap(getNgCompiler: () => AngularCompilerPlugin):
73
75
74
76
const firstNode = getFirstNode ( sourceFile ) ;
75
77
76
- // Add the transform operations.
77
- const factoryClassName = entryModule . className + 'NgFactory' ;
78
- const factoryModulePath = normalizedEntryModulePath + '.ngfactory' ;
79
-
78
+ const factoryClassName = enableIvy ? entryModule . className : entryModule . className + 'NgFactory' ;
79
+ const factoryModulePath = enableIvy ? normalizedEntryModulePath : normalizedEntryModulePath + '.ngfactory' ;
80
80
81
81
const newBootstrapPropAccessExpr = ts . getMutableClone ( bootstrapPropAccessExpr ) ;
82
82
const newNsPlatformCallExpr = ts . getMutableClone ( bootstrapPropAccessExpr . expression ) as ts . CallExpression ;
83
83
newNsPlatformCallExpr . expression = ts . createPropertyAccess ( idPlatformNativeScript , 'platformNativeScript' ) ;
84
84
newBootstrapPropAccessExpr . expression = newNsPlatformCallExpr ;
85
- newBootstrapPropAccessExpr . name = ts . createIdentifier ( "bootstrapModuleFactory" ) ;
85
+ newBootstrapPropAccessExpr . name =
86
+ enableIvy ? ts . createIdentifier ( "bootstrapModule" ) : ts . createIdentifier ( "bootstrapModuleFactory" ) ;
86
87
87
88
const newBootstrapCallExpr = ts . getMutableClone ( bootstrapCallExpr ) ;
88
89
newBootstrapCallExpr . expression = newBootstrapPropAccessExpr ;
0 commit comments