@@ -222,19 +222,32 @@ function _replacePlatform(
222
222
}
223
223
224
224
225
- function _replaceBootstrap ( refactor : TypeScriptFileRefactor , call : ts . CallExpression ) {
226
- // If bootstrapModule can't be found, bail out early.
227
- if ( ! call . getText ( ) . includes ( 'bootstrapModule' ) ) {
228
- return ;
229
- }
225
+ function _replaceBootstrapOrRender ( refactor : TypeScriptFileRefactor , call : ts . CallExpression ) {
226
+ // If neither bootstrapModule or renderModule can't be found, bail out early.
227
+ let replacementTarget : string ;
228
+ let identifier : ts . Identifier ;
229
+ if ( call . getText ( ) . includes ( 'bootstrapModule' ) ) {
230
+ if ( call . expression . kind != ts . SyntaxKind . PropertyAccessExpression ) {
231
+ return ;
232
+ }
230
233
231
- if ( call . expression . kind == ts . SyntaxKind . PropertyAccessExpression ) {
234
+ replacementTarget = 'bootstrapModule' ;
232
235
const access = call . expression as ts . PropertyAccessExpression ;
236
+ identifier = access . name ;
237
+ _replacePlatform ( refactor , access ) ;
233
238
234
- if ( access . name . text === 'bootstrapModule' ) {
235
- _replacePlatform ( refactor , access ) ;
236
- refactor . replaceNode ( access . name , 'bootstrapModuleFactory' ) ;
239
+ } else if ( call . getText ( ) . includes ( 'renderModule' ) ) {
240
+ if ( call . expression . kind != ts . SyntaxKind . Identifier ) {
241
+ return ;
237
242
}
243
+
244
+ replacementTarget = 'renderModule' ;
245
+ identifier = call . expression as ts . Identifier ;
246
+ refactor . insertImport ( 'renderModuleFactory' , '@angular/platform-server' ) ;
247
+ }
248
+
249
+ if ( identifier && identifier . text === replacementTarget ) {
250
+ refactor . replaceNode ( identifier , replacementTarget + 'Factory' ) ;
238
251
}
239
252
}
240
253
@@ -268,7 +281,8 @@ function _replaceEntryModule(plugin: AotPlugin, refactor: TypeScriptFileRefactor
268
281
modules
269
282
. forEach ( reference => {
270
283
refactor . replaceNode ( reference , factoryClassName ) ;
271
- _replaceBootstrap ( refactor , _getCaller ( reference ) ) ;
284
+ const caller = _getCaller ( reference ) ;
285
+ _replaceBootstrapOrRender ( refactor , caller ) ;
272
286
} ) ;
273
287
}
274
288
0 commit comments