In the angular docs, it says: "Also be sure to remove the ItemsModule from the AppModule. For step-by-step instructions on lazy loading modules, continue with the following sections of this page." It doesn't say why. In my local testing, I did not see the modules being lazy loaded shown in chrome's dev tools on initial load. I just want to know why these modules should be remove from the app module and I'd appreciate it if there was supporting documentation.
#Lazy Loading
4 messages · Page 1 of 1 (latest)
If it's not removed from the app module, then the app.module.ts file has a static TypeScript import for the ItemsModule, and the bundler (webpack) thus puts the code of the module (and transitively, of all the components it imports) in the main bundle. In short, it defeats the whole point of lazy loading, because the code is then loaded eagerly, as part of the main module.
Is there a way I could verify this? I'm trying to explain it to my coworker who modified my code
You could, by building the app before the change, saving the generated files, then building the app again after the change, and then comparing the generated files with the previous ones. Or you could also trust the official documentation.