Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upString-based Lazy Loading is not working anymore #35652
Comments
|
@maxschwarzmueller, that is expected that string based lazy loaded will fail unless you amend you tsconfig to include the lazy-loaded routes. This is because otherwise the lazy-loaded files will not be part of the compilation.
It does work, but you need to opt-in this behaviour. As by default the CLI will generate projects which stricter file inclusions intended to be used with the |
|
I see, thank you very much for the clarification! :) Is this documented somewhere? Just asking because others might experience the same "issue". |
|
I don’t think there are docs for this. Transferring to the Fw repo so that we can add this until the string based lazy loading is supported. |
after angular version 8 string based lazy loading is not activated by default it is an opt in behaviour in which you have to add the lazy loaded routes in the tsconfig file for compilation. Aded a note too that it will be removed in version 11. Fixes angular#35652
after angular version 8 string based lazy loading is not activated by default it is an opt in behaviour in which you have to add the lazy loaded routes in the tsconfig file for compilation. Aded a note too that it will be removed in version 11. Fixes angular#35652
after angular version 8 string based lazy loading is not activated by default it is an opt in behaviour in which you have to add the lazy loaded routes in the tsconfig file for compilation. Aded a note too that it will be removed in version 11. Fixes angular#35652
Is this a regression?
Yes, it worked in Angular 8.
Description
String-based lazy loading (
loadChildren: './path/to/module#Module') was deprecated as of Angular 8 and might be removed in Angular 11 (see: https://angular.io/guide/deprecations#index). Hence it should still work as of Angular 9.When creating new Angular projects via
ng new, this deprecated syntax doesn't work anymore though.Instead, you get a "Cannot find module './module/....module'" error (see below).
The error is definitely related to changes made in the
tsconfig.app.jsonfile. (see "Minimal Reproduction").It works as intended if the
tsconfig.app.jsonfile usesexclude: [ ... ]. It fails when usinginclude: [ ... ]+files: [ ... ].See: https://github.com/maxschwarzmueller/ng-string-lazy-loading-bug/
1) Failing Case
Clone and checkout "lazy-loading-fails" branch.
ng serveVisit localhost:4200/demo
You get the "cannot find module" error in the browser dev tools.
2) Working Case
Checkout "lazy-loading-succeeds" branch and repeat above steps => It now works.
As described above, the only difference between the two branches is the content of the
tsconfig.app.jsonfile (comparison: https://github.com/maxschwarzmueller/ng-string-lazy-loading-bug/compare/lazy-loading-fails...lazy-loading-succeeds?expand=1#diff-5446e8397826b1757d7b7d8f63223eab).