angular / angular/angular-cli

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

オープン
#24,497 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
area: @schematics/angular freq1: low severity3: broken type: bug/fix
主要言語
TypeScript
スター
27k
フォーク
11.8k
平均マージ
14時間 23分
マージ済み PR(30日)
162

説明

### 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.
```

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

`provideRouter` を使用する Angular 15 プロジェクトで `ng g m foo --route=foo -m=app` を再現し、その後、`app-routing.module.ts` および `app.module.ts` と照らし合わせて、モジュール生成時のルート処理を調査します。コマンドがエクスポートされたルート宣言を見つけ、表示されたエラーなしで要求されたルートを含むモジュールを生成できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
cli, tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。