Skip to content

Generate module command adds route path to wrong line #15117

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

Closed
mehmet-erim opened this issue Jul 18, 2019 · 3 comments · Fixed by #15142
Closed

Generate module command adds route path to wrong line #15117

mehmet-erim opened this issue Jul 18, 2019 · 3 comments · Fixed by #15142
Labels
area: @schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Milestone

Comments

@mehmet-erim
Copy link

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [x] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Description

ng generate module ranking --route ranking --module app.module command is working very well. But if there is a data property to routes in app-routing.module. The command add route path to wrong line.

🔬 Minimal Reproduction

ng new example-app --routing
ng generate module ranking --route ranking --module app.module

Add data property to ranking route, then my app-routing.module.ts like below

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
  {
    path: 'ranking',
    loadChildren: () => import('./ranking/ranking.module').then(m => m.RankingModule),
    data: { path: 'test', name: 'Test' },
  },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
})
export class AppRoutingModule {}

After, run the following command
ng generate module home --route home --module app.module

It adds my home route path to the wrong line like below:

const routes: Routes = [
  {
    path: 'ranking',
    loadChildren: () => import('./ranking/ranking.module').then(m => m.RankingModule),
    data: { path: 'test', name: 'Test' },
    { path: 'home', loadChildren: () => import('./home/home.module').then(m => m.HomeModule) },
  },
];
@alan-agius4
Copy link
Collaborator

Can you please provide the output of ng version?

@alan-agius4 alan-agius4 added the needs: more info Reporter must clarify the issue label Jul 18, 2019
@mehmet-erim
Copy link
Author

Can you please provide the output of ng version?

Sure,

Angular CLI: 8.1.2
Node: 10.16.0
OS: darwin x64
Angular: 8.1.2
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package Version

@angular-devkit/architect 0.801.2
@angular-devkit/build-angular 0.801.2
@angular-devkit/build-optimizer 0.801.2
@angular-devkit/build-webpack 0.801.2
@angular-devkit/core 8.1.2
@angular-devkit/schematics 8.1.2
@ngtools/webpack 8.1.2
@schematics/angular 8.1.2
@schematics/update 0.801.2
rxjs 6.4.0
typescript 3.4.5
webpack 4.35.2

@alan-agius4 alan-agius4 added area: @schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix and removed needs: more info Reporter must clarify the issue labels Jul 19, 2019
@ngbot ngbot bot added this to the Backlog milestone Jul 19, 2019
vikerman pushed a commit that referenced this issue Jul 25, 2019
… for child nodes of kind

Curtrently, when a node of kind is found, we recursivly continue to look up it's child nodes until the end of the AST. This ends up returing other nodes which we were not looking for as typically we are looking for the first level of children of the specified kind.

By default now, we stop recursivly looking for child nodes of kind when we encounter one.

Closes #15117
vikerman pushed a commit that referenced this issue Jul 26, 2019
… for child nodes of kind

Curtrently, when a node of kind is found, we recursivly continue to look up it's child nodes until the end of the AST. This ends up returing other nodes which we were not looking for as typically we are looking for the first level of children of the specified kind.

By default now, we stop recursivly looking for child nodes of kind when we encounter one.

Closes #15117
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @schematics/angular freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants