Skip to content

Importing any Material module imports FormsModule when using CLI #5942

@benelliott

Description

@benelliott

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 output vendor 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 in vendor.bundle.js when importing a trivial Material module like MdCardModule.

What are the steps to reproduce?

  1. Install Angular CLI (v1.2.2): npm i -g @angular/cli
  2. Create a new project: ng new temp
  3. Execute a development build: ng build
  4. Verify that no content from @angular/forms is included in the vendor bundle (e.g. search for a symbol like FormBuilder)
  5. Import MdCardModule: npm i -S @angular/material @angular/cdk and add MdCardModule to the NgModule's imports
  6. Execute another development build: ng build
  7. Verify that @angular/forms content is now included in the vendor bundle

Note: 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions