Skip to content

Generated components are misplaced in app.module.ts declarations list #7950

Closed

Description

@RickePicke

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.4.1
node: 6.11.2
os: darwin x64
@angular/animations: 4.3.6
@angular/cdk: 2.0.0-beta.10-a7ce31e
@angular/common: 4.3.6
@angular/compiler: 4.3.6
@angular/core: 4.3.6
@angular/forms: 4.3.6
@angular/http: 4.3.6
@angular/material: 2.0.0-beta.10-a7ce31e
@angular/platform-browser: 4.3.6
@angular/platform-browser-dynamic: 4.3.6
@angular/router: 4.3.6
@angular/cli: 1.4.1
@angular/compiler-cli: 4.3.6
typescript: 2.2.2

Repro steps.

I have over 25 components in my app and lately when I've runed ng g component some the generated components are misplaced in app.module declarations like this:

app.module.ts

@NgModule({
   declarations: [
    ...
    anotherComponent,
    oneMoreCompone, // <--- nt is missing
    someComponentnt // <--- it's right here
   ],
   ...
}

The log given by the failure.

There are no failure logs. This is logged when the component is generated though, as usual:

  create src/app/components/some/some.component.css (0 bytes)
  create src/app/components/some/some.component.html (35 bytes)
  create src/app/components/some/some.component.spec.ts (692 bytes)
  create src/app/components/some/some.component.ts (308 bytes)
  update src/app/app.module.ts (5810 bytes)

Desired functionality.

What causes this issue?
Is it a bug?

Mention any other details that might be useful.

This happens all the time in the repo now, so it's a recurring problem. As I mentioned, I have a lot of imports and a lots of declarations in my app.module.ts.

Activity

  1. changed the title [-]Generated components are misplaced in app.module.ts declarations[/-] [+]Generated components are misplaced in app.module.ts-declarations[/+] on Oct 5, 2017
  2. changed the title [-]Generated components are misplaced in app.module.ts-declarations[/-] [+]Generated components are misplaced in app.module.ts - > declarations[/+] on Oct 5, 2017
  3. changed the title [-]Generated components are misplaced in app.module.ts - > declarations[/-] [+]Generated components are misplaced in app.module.ts -> declarations[/+] on Oct 5, 2017
  4. changed the title [-]Generated components are misplaced in app.module.ts -> declarations[/-] [+]Generated components are misplaced in app.module.ts declarations list[/+] on Oct 5, 2017
  5. hansl commented on Oct 11, 2017

    @hansl
    Contributor

    Could you share the whole file? I'm generating a 1000 components here and I don't see it. We use AST so it's robust, unless:

    1. there's something wrong with the AST (an error in your code perhaps)? or
    2. you're writing the file at the same time, causing a race condition somewhere.

    What editor are you using?

  6. self-assigned this
    on Oct 11, 2017
  7. RickePicke commented on Oct 15, 2017

    @RickePicke
    Author

    I'm using VS-code on mac. Tried some more times having the file closed and open with and without changes. The result this time was this:

    app.module.ts

    @NgModule({
       declarations: [
        ...
        TemplateBuilder, // <--- "Component" moved from here
        TestComponent, 
        Test2Component,
        Test3Component,
        Test4ComponentComponent // <--- to here, one step at the time
       ],
       ...
    }
  8. orestes-garcia-martinez commented on Oct 16, 2017

    @orestes-garcia-martinez

    I'm getting same issue using:
    VS Code v-1.17.1,
    OS Windows 7,
    @angular/core": "^4.4.5",
    @angular/cli": "^1.4.7",
    @angular/compiler-cli": "^4.4.5

    Running "ng g c component-name" the previous created component path and name is truncated in app.module.ts file triggering an error during compilation.

    terminal output:
    2017-10-16_1230

    app.module.ts file :
    2017-10-16_1139

  9. removed their assignment
    on Feb 6, 2018
  10. added a commit that references this issue on Oct 6, 2018
  11. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  12. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions