@@ -15,14 +15,16 @@ import {
1515import { AngularCompilerPlugin } from '@ngtools/webpack' ;
1616import { getResolvedEntryModule } from "../utils/transformers-utils" ;
1717
18-
1918export function nsReplaceBootstrap ( getNgCompiler : ( ) => AngularCompilerPlugin ) : ts . TransformerFactory < ts . SourceFile > {
2019 const shouldTransform = ( fileName ) => ! fileName . endsWith ( '.ngfactory.ts' ) && ! fileName . endsWith ( '.ngstyle.ts' ) ;
2120 const getTypeChecker = ( ) => getNgCompiler ( ) . typeChecker ;
2221
2322 const standardTransform : StandardTransform = function ( sourceFile : ts . SourceFile ) {
2423 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 ) ;
2628
2729 if ( ! shouldTransform ( sourceFile . fileName ) || ! entryModule ) {
2830 return ops ;
@@ -73,16 +75,15 @@ export function nsReplaceBootstrap(getNgCompiler: () => AngularCompilerPlugin):
7375
7476 const firstNode = getFirstNode ( sourceFile ) ;
7577
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' ;
8080
8181 const newBootstrapPropAccessExpr = ts . getMutableClone ( bootstrapPropAccessExpr ) ;
8282 const newNsPlatformCallExpr = ts . getMutableClone ( bootstrapPropAccessExpr . expression ) as ts . CallExpression ;
8383 newNsPlatformCallExpr . expression = ts . createPropertyAccess ( idPlatformNativeScript , 'platformNativeScript' ) ;
8484 newBootstrapPropAccessExpr . expression = newNsPlatformCallExpr ;
85- newBootstrapPropAccessExpr . name = ts . createIdentifier ( "bootstrapModuleFactory" ) ;
85+ newBootstrapPropAccessExpr . name =
86+ enableIvy ? ts . createIdentifier ( "bootstrapModule" ) : ts . createIdentifier ( "bootstrapModuleFactory" ) ;
8687
8788 const newBootstrapCallExpr = ts . getMutableClone ( bootstrapCallExpr ) ;
8889 newBootstrapCallExpr . expression = newBootstrapPropAccessExpr ;
0 commit comments