Skip to content

ng generate adds component to module even if the generated component is identical #4323

@beeman

Description

@beeman

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

macOS Sierra

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:

angular-cli: 1.0.0-beta.28.3
node: 7.2.0
os: darwin x64
@angular/common: 2.4.5
@angular/compiler: 2.4.5
@angular/core: 2.4.5
@angular/forms: 2.4.5
@angular/http: 2.4.5
@angular/platform-browser: 2.4.5
@angular/platform-browser-dynamic: 2.4.5
@angular/router: 3.4.5
@angular/compiler-cli: 2.4.5

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.

Create an app with ng new

Follow these steps:

$ ng g m events
installing module
  create src/app/events/events.module.ts

$ ng g c events/list
installing component
  create src/app/events/list/list.component.css
  create src/app/events/list/list.component.html
  create src/app/events/list/list.component.spec.ts
  create src/app/events/list/list.component.ts
  update src/app/events/events.module.ts

$ ng g c events/list
installing component
  identical src/app/events/list/list.component.css
  identical src/app/events/list/list.component.html
  identical src/app/events/list/list.component.spec.ts
  identical src/app/events/list/list.component.ts
  update src/app/events/events.module.ts

$ cat src/app/events/events.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ListComponent } from './list/list.component';

@NgModule({
  imports: [
    CommonModule
  ],
  declarations: [ListComponent, ListComponent]
})
export class EventsModule { }

Because the last generate command generates all identical files I don't expect the update of the module to happen, as this will leave it with the same component being declared twice.

The log given by the failure.

Normally this include a stack trace and some more information.

No failures.

Mention any other details that might be useful.


Thanks! We'll be in touch soon.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions