@@ -435,6 +435,33 @@ function _diagnoseDeps(reasons: ModuleReason[], plugin: AotPlugin, checked: Set<
435435}
436436
437437
438+ export function _stuff ( plugin : AotPlugin , refactor : TypeScriptFileRefactor ) {
439+ if ( ! plugin . replaceExport ) {
440+ return ;
441+ }
442+
443+ const exports = refactor
444+ . findAstNodes ( refactor . sourceFile , ts . SyntaxKind . ExportDeclaration , true ) ;
445+
446+ exports
447+ . filter ( node => {
448+
449+ const identifiers = refactor . findAstNodes ( node , ts . SyntaxKind . Identifier , false ) ;
450+
451+ identifiers
452+ . filter ( node => node . getText ( ) === plugin . entryModule . className ) ;
453+
454+ return identifiers . length > 0 ;
455+ } )
456+ . forEach ( node => {
457+ const factoryPath = _getNgFactoryPath ( plugin , refactor ) ;
458+ const factoryClassName = plugin . entryModule . className + 'NgFactory' ;
459+ const exportStatement = `export \{ ${ factoryClassName } \} from '${ factoryPath } '` ;
460+ refactor . appendAfter ( node , exportStatement ) ;
461+ } ) ;
462+ }
463+
464+
438465// Super simple TS transpiler loader for testing / isolated usage. does not type check!
439466export function ngcLoader ( this : LoaderContext & { _compilation : any } , source : string | null ) {
440467 const cb = this . async ( ) ;
@@ -464,7 +491,8 @@ export function ngcLoader(this: LoaderContext & { _compilation: any }, source: s
464491 if ( ! plugin . skipCodeGeneration ) {
465492 return Promise . resolve ( )
466493 . then ( ( ) => _removeDecorators ( refactor ) )
467- . then ( ( ) => _refactorBootstrap ( plugin , refactor ) ) ;
494+ . then ( ( ) => _refactorBootstrap ( plugin , refactor ) )
495+ . then ( ( ) => _stuff ( plugin , refactor ) ) ;
468496 } else {
469497 return Promise . resolve ( )
470498 . then ( ( ) => _replaceResources ( refactor ) )
0 commit comments