Duplicated Material modules in aot generaed lazy load chunk files (Angular CLI)
See original GitHub issueBug, feature request, or proposal:
I’ve taken a look at my (lazy load) chunk files generated by Angular CLI (--prod
so with aot) and I wonder why do I have the used material components also in there floating around when they are already in the vendor.bundle
file?
Is this an issue on Material side, Angular CLI or it’s just the way it has to be?
Lazy load chunk 1
Lazy load chunk 2
Vendor bundle
What is the expected behavior?
Don’t duplicate the Material modules throuh the app - at least not the styles.
What is the current behavior?
Every chunk
gets the modules (& css) for the md components that it components use added
What are the steps to reproduce?
Plunker won’t do it so i’ve added a repo. https://github.com/bboehm86/mat-chunk-test
- You’ll need
@angular/cli@1.0.0-beta.32.3
- source-map-explorer might be helful (run
npm run build
to generate files with sourcemaps)
What is the use-case or motivation for changing an existing behavior?
smaller chunk sizes
Which versions of Angular, Material, OS, browsers are affected?
Angular 2.x, Angular CLI 1.0.0-beta.32.3, all Material versions
Is there anything else we should know?
That is probably not related and a webpack issue… but in the vendor.bundle
everything for Material gets inclued no matter what. The only way to prevent that is to include just the modules we use. On both, our app.module
and then in every module that uses a component
Issue Analytics
- State:
- Created 7 years ago
- Reactions:11
- Comments:15
@bboehm86 this is what my custom-ng-materials.module.ts file looks like:
This module is then imported into each module that has declared components using any of these material components. I think I’m doing everything correctly according to the Getting Started Guide and your demo app. What do you think is the problem?
I’m closing this since it seems to be resolved with the latest Angular CLI release (1.1.0-rc.1)