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
Importing any Material module imports FormsModule when using CLI #5942
Comments
Some components depend on @angular/forms, but the code is being refactored to take it off: #5871 |
I understand that, my question is more why modules like |
Oh right, do you mean that it's because at least one Material submodule imports it, and these submodules all exist in the same file, so importing any one submodule will import the ES6 module imports of that Material bundle file and thus cause things like Forms to be included? This would explain why it does not appear in production as the unreferenced symbol import is shaken out by Webpack. |
No, in fact I've missed the part you mentioned the card module, sorry. I've read about the refactoring more than once among the issues and the PR's. I'm really not sure of how the forms module is being imported inside the project, but after a fast search, I've found the forms module imported only in components (nothing about a shared library and also nothing about the MdCard importing other component that in turn import forms). In this case I don't know why the forms is being imported in dev environment just because of MdCard. |
@benelliott I think your hunch is correct. If you import just |
@benelliott, it happens that your problem is a real not solved yet issue :#4137 (comment) |
@IgorMinar @kara is this solved by the same underlying work on #4137? |
Duplicate of #4137 |
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. |
Bug, feature request, or proposal:
Perhaps I am misunderstanding what is going on here but it seems that importing any (sub)module from
@angular/material
will cause@angular/forms
content to be included in the outputvendor
bundle when using@angular/cli
.What is the expected behavior?
Either for the external dependencies of modules to be explicitly stated or for an unrelated module not to be included in the output vendor bundle.
What is the current behavior?
Content from
@angular/forms
is included invendor.bundle.js
when importing a trivial Material module likeMdCardModule
.What are the steps to reproduce?
npm i -g @angular/cli
ng new temp
ng build
@angular/forms
is included in thevendor
bundle (e.g. search for a symbol likeFormBuilder
)MdCardModule
:npm i -S @angular/material @angular/cdk
and addMdCardModule
to theNgModule
's importsng build
@angular/forms
content is now included in thevendor
bundleNote: it does seem like this content is removed from a production build (as it is unused). My query is why it is there in the first place.
What is the use-case or motivation for changing an existing behavior?
Module dependencies should be clear to the developer.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 4.3.1, Angular CLI 1.2.2, Material 2.0.0-beta.8, Windows 10
Is there anything else we should know?
No
The text was updated successfully, but these errors were encountered: