@@ -87,6 +87,29 @@ function _replaceBootstrap(plugin: AotPlugin, refactor: TypeScriptFileRefactor)
87
87
refactor . insertImport ( entryModule . className + 'NgFactory' , ngFactoryPath ) ;
88
88
}
89
89
90
+ function _removeModuleId ( refactor : TypeScriptFileRefactor ) {
91
+ const sourceFile = refactor . sourceFile ;
92
+
93
+ // Find all object literals.
94
+ refactor . findAstNodes ( sourceFile , ts . SyntaxKind . ObjectLiteralExpression , true )
95
+ // Get all their property assignments.
96
+ . map ( node => refactor . findAstNodes ( node , ts . SyntaxKind . PropertyAssignment ) )
97
+ // Flatten into a single array (from an array of array<property assignments>).
98
+ . reduce ( ( prev , curr ) => curr ? prev . concat ( curr ) : prev , [ ] )
99
+ // Remove every property assignment that aren't 'loadChildren'.
100
+ . filter ( ( node : ts . PropertyAssignment ) => {
101
+ const key = _getContentOfKeyLiteral ( sourceFile , node . name ) ;
102
+ if ( ! key ) {
103
+ // key is an expression, can't do anything.
104
+ return false ;
105
+ }
106
+ return key == 'moduleId' ;
107
+ } )
108
+ . forEach ( ( node : ts . PropertyAssignment ) => {
109
+ refactor . removeNode ( node ) ;
110
+ } ) ;
111
+ }
112
+
90
113
function _replaceResources ( refactor : TypeScriptFileRefactor ) : void {
91
114
const sourceFile = refactor . sourceFile ;
92
115
@@ -163,7 +186,9 @@ export function ngcLoader(source: string) {
163
186
. then ( ( ) => _removeDecorators ( refactor ) )
164
187
. then ( ( ) => _replaceBootstrap ( plugin , refactor ) ) ;
165
188
} else {
166
- return _replaceResources ( refactor ) ;
189
+ return Promise . resolve ( )
190
+ . then ( ( ) => _replaceResources ( refactor ) )
191
+ . then ( ( ) => _removeModuleId ( refactor ) ) ;
167
192
}
168
193
} )
169
194
. then ( ( ) => {
0 commit comments