-
Notifications
You must be signed in to change notification settings - Fork 12k
bug(MatListModule): Should not import @angular/forms in main chunk if it's just using mat-nav-list #19562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Splitting the selection list into a separate module would be a big breaking change at this point and it'll make the setup inconsistent with the rest of the library where we have one module per entry point. Furthermore, we're only using one constant from the forms module ( |
@crisbeto Did you see the reproduction repository or the reproduction steps? It is a clean application. Can you see why |
Looking through it, the module definitely gets pulled in because of the Material list, but I'm not sure why it's not limited to the one constant that we're actually using. This would be a better question for the CLI repository: https://github.com/angular/angular-cli/issues. I'll reopen the issue and transfer it there. |
The FESM output of the libraries causes each package entry point to be one large JavaScript module. This module will be located in the earliest application output chunk that uses the package entry point. Since Material is being used in the main output chunk and Material is using the forms package, the full forms JavaScript module must be placed in the main chunk to ensure accessibility for the Material code. The dead code elimination passes will remove code from the forms JavaScript module that is unused within the full application. However, any used forms code will be moved along with the forms JavaScript module into the main output chunk. |
Duplicate of #19527 (comment) and #13635 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Reproduction
Steps to reproduce:
ng new angular-test --routing=true & cd angular-test
ng add @angular/material
MatListModule
into theAppModule
and insert<mat-nav-list></mat-nav-list>
intoapp.component.html
ng generate module --route lazy --module app
MatInputModule
intoLazyModule
<input matInput />
intolazy.component.html
Or just clone my repository csbenjamin/issue-with-tree-shake
ng build --prod
Expected Behavior
@angular/forms
should be imported in the chunk lazy loaded.Actual Behavior
@angular/forms
is being imported in the main chunk.Note that if we remove the lazy route from
app.routing.module.ts
, then@angular/forms
goes away from the main chunk, even usingmat-nav-list
inapp.component.html
. Also, if we keep the lazy route and remove theMatListModule
dependency from theAppModule
, then the@angular/forms
goes to the lazy chunk, as it should be.A possible solution would be spliting
list.ts
andselection-list.ts
into two differentNgModule
, so, if we are not using theselection-list.ts
part, we just import theNgModule
that containslist.ts
, which does not depend on@angular/forms
.Environment
The text was updated successfully, but these errors were encountered: