shlomiassaf / ng-router-loader

Webpack loader for NgModule lazy loading using the angular router
MIT License
46 stars 8 forks source link

False positive "loadChildren" regular expression match #11

Closed pglazkov closed 6 years ago

pglazkov commented 7 years ago

The regular expression for replacing loadChildren matches any string in the following format:

loadChildren: 'xxx'

This causes a problem with angular-tree-component when compiling the app with AOT. This is because that component has loadChildren property property and AOT produces an ngfactory.ts file that contains loadChildren: 'loadChildren' that gets replaced by the loader causing the compilation to fail.

This can be fixed by changing the regular expression to include the # symbol (since all lazy routes seem to require the module name separated by that symbol):

loadChildren[\s]*:[\s]*['|"].*#{1}.*['|"]