Lazy loaded chunk not generated when lazy route is a child of non-lazy route.
See original GitHub issueVersions
Angular CLI: 1.6.6
Node: 8.9.4
OS: linux x64
Angular: 5.2.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker
@angular/cdk: 5.1.0
@angular/cli: 1.6.6
@angular/material: 5.1.0
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.6
@schematics/angular: 0.1.17
typescript: 2.4.2
webpack-bundle-analyzer: 2.9.2
webpack: 3.10.0
Repro steps
- Create an angular 5 app
- In the main root module load 2 routes by module, but not lazy loaded.
- In one of the child modules, lazy load subsequent modules
Observed behavior
Error thrown when loading the lazy route. When search for the chunk expected in the filesystem it is not there.
Desired behavior
The lazy loaded route is loaded via a chunk create created by webpack
Mention any other details that might be useful (optional)
SO question raised, but nobody has an answer: https://stackoverflow.com/questions/48523411/angular-5-with-angular-cli-non-lazy-loading-modules-in-the-router
Demo code of the exact issue on github: https://github.com/jdcrecur/ang5ModuleRouting
Issue Analytics
- State:
- Created 6 years ago
- Reactions:65
- Comments:100 (3 by maintainers)
Top Results From Across the Web
Angular7: Lazy loading not creating chunks - Stack Overflow
chunks created via lazy. As shown chunks are indeed created. And not found module isn't appearing which is normal.
Read more >Lazy-loading feature modules - Angular
To lazy load Angular modules, use loadChildren (instead of component ) in ... In the lazy-loaded module's routing module, add a route for...
Read more >How To Use Lazy Loading Routes in Angular | DigitalOcean
Learn how to enable feature modules to be lazy-loaded in Angular, allowing to load the code for some routes to be loaded on-demand....
Read more >Lazy Loading Routes | Vue Router
It would be more efficient if we can split each route's components into separate chunks, and only load them when the route is...
Read more >Common Chunk and Lazy Loading in Angular - | juri.dev
The easiest way of applying lazy loading is to use the Angular Router's built-in functionality. const routes: Routes = [ { path: 'products', ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Actually, disregard that. I was importing my lazy-loaded module from the app’s NgModule. Once I removed that import, the lazy loading worked correctly.
Perhaps the error messaging itself could be improved, regardless.
@fromage9747
Basically if you are doing this
loadChildren: 'app/dashboard.module#DashboardModule'
You are already importing the module when you hit this route.
So if you import the same module (DashboardModule in this case) in app.module.ts you will get the error.
Hope this help you out.