angular / angular/angular-cli

ng g module with route option not working with the new provideRouter

Đang mở
#24,497 4 bình luận 0 reaction 0 người được giao Xem trên GitHub
area: @schematics/angular freq1: low severity3: broken type: bug/fix
Ngôn ngữ chính
TypeScript
Star
27k
Fork
11.8k
Merge trung bình
14 giờ 23 phút
Pull request đã merge (30 ngày)
162

Mô tả

### Command

generate

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

when using the new way `provideRouter` the command `ng g m foo --route=foo -m=app` stop working

### Minimal Reproduction

create new angular 15 project
in `app-routing.module.ts`

1. remove `AppRoutingModule`
2. export the `routes` const

in `app.module.ts`

1. remove `AppRoutingModule` from `import` array
2. add `provideRouter(routes)` to the `providers` array

then in the command line run `ng g m foo --route=foo -m=app`

### Exception or Error

```text
Couldn't find a route declaration in /src/app/app-routing.module.ts.
Use the '--module' option to specify a different routing module.
```

### Your Environment

```text
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1500.5
@angular-devkit/build-angular 15.0.5
@angular-devkit/core 15.0.5
@angular-devkit/schematics 15.0.5
@angular/cli 15.0.5
@schematics/angular 15.0.5
rxjs 7.5.7
typescript 4.8.4
```

### Anything else relevant?

changing the file name from `app-routing.module.ts` to `routes.ts` gives a different but similar error message
```
Couldn't find a route declaration in /src/app/app.module.ts.
Use the '--module' option to specify a different routing module.
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Tái hiện `ng g m foo --route=foo -m=app` trong một dự án Angular 15 sử dụng `provideRouter`, sau đó kiểm tra cách xử lý route khi tạo module so với `app-routing.module.ts` và `app.module.ts`. Được xem là hoàn tất khi lệnh tìm thấy khai báo route đã được export và tạo module với route được yêu cầu mà không có lỗi được hiển thị.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
cli, tooling
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.