Skip to content

Creating a module with --route & --routing creates duplicated & errored code #17139

Closed

Description

@Maryannah

🐞 bug report

Affected Package

The issue is caused by the schematics that create a module

Is this a regression?

I do not know, I have never tried it before

Description

when running a command to create a module with --route & --routing, the code gets duplicated : there are routes in the *.module.ts along with the *-routing.module.ts

🔬 Minimal Reproduction

I didn't manage to create a stackblitz, but here are the commands to reproduce it locally.
npx create-nx-workspace@latest workspace
cd workspace
ng add @nrwl/angular --defaults
ng g @nrwl/angular:application app --style scss --routing true --prefix app
ng g m home --route home --module app.module.ts --routing true --project app

🌍 Your Environment

Angular Version:


    "@angular/animations": "^9.0.0",
    "@angular/cdk": "^9.0.0",
    "@angular/common": "^9.0.0",
    "@angular/compiler": "^9.0.0",
    "@angular/core": "^9.0.0",
    "@angular/flex-layout": "^9.0.0-beta.29",
    "@angular/forms": "^9.0.0",
    "@angular/material": "^9.0.0",
    "@angular/platform-browser": "^9.0.0",
    "@angular/platform-browser-dynamic": "^9.0.0",
    "@angular/router": "^9.0.0",
    "@nrwl/angular": "^9.0.4",

Anything else relevant?

I do not know if this is wanted or not, and I do not know which one is the best practice (the one to keep).

Here is a picture of the issue, in case it helps : you can see routes on the module, but also a routing module that is imported with it.

image

Activity

  1. modified the milestone: Backlog on Mar 3, 2020
  2. alan-agius4 commented on Mar 3, 2020

    @alan-agius4
    Collaborator

    Hi @Maryannah, I tried this locally and while the second part is a bug, I was unable to reproduce the first issue with the steps provided.

    The resulted module looks like the below without the routing flag

    const routes: Routes = [
      { path: '', component: HomeComponent }
    ];
    
    @NgModule({
      declarations: [HomeComponent],
      imports: [
        CommonModule,
        RouterModule.forChild(routes)
      ]
    })
    export class HomeModule { }
  3. Maryannah commented on Mar 3, 2020

    @Maryannah
    Author

    @alan-agius4 I have followed the steps again and here is the result :

    image

    If I remove the routing flag :

    image

    It seems that the second (semi-colon) and third (schematics config not applied) issues are with my own repository, I will look into that myself ! I am removing them from my original issue

  4. alan-agius4 commented on Mar 3, 2020

    @alan-agius4
    Collaborator

    Hi @Maryannah, can you please update the issue title and description accordingly as it seems that you deleted the details of the actual bug?

    Thanks.

  5. Maryannah commented on Mar 3, 2020

    @Maryannah
    Author

    @alan-agius4 I have removed what is related to my own repository and kept the issue as it was found originally.

    I am adding a screenshot to picture it if needed, but that's all the issue, the duplication of the routes !

  6. added a commit that references this issue on Jul 1, 2022
    a279248
  7. self-assigned this
    on Jul 1, 2022
  8. added a commit that references this issue on Jul 6, 2022
    06bbedb
  9. added 2 commits that reference this issue on Jul 6, 2022
    9e31524
    f9f970c
  10. angular-automatic-lock-bot commented on Aug 6, 2022

    @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.

  11. locked and limited conversation to collaborators on Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions