storybookjs/storybook

[Bug]: RouterModule.forRoot() is imported twice when loading a story

開放

#25,726 建立於 2024年1月23日

 (3 則留言) (2 個反應) (0 位負責人)TypeScript (10,058 個分叉)batch import
angularbughelp wanted

倉庫指標

星標
 (89,909 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

Describe the bug

When importing the RouterModule and using the forRoot() pattern for routing storybook seems to import this twice causing NG04007: The Router was provided more than once.

You can see this in the screenshot below: image

I see this error in: storybook 7.4.3 Angular 15 storybook 7.5 Angular 16. I even upgraded to 7.6.10 with Angular 15 and still had the same issue.

I do not have this error in storybook 7.4.3 Angular 14.

To Reproduce

Stackblitz: https://stackblitz.com/edit/github-vrpkro-pu8ckn?file=src%2Fstories%2FPage.stories.ts

Code change on line 22 in Page.Stories.ts Reproduction:

  1. Load project
  2. Navigate to page example
  3. The error will appear in place of story

You can navigate to the other examples and see that without the RouterModule.forRoot() imported you will not have the same issue.

System

Local project: 7.4.3
StackBlitz: 7.5.0-alpha
chrome: Version 120.0.6099.234

Additional context

I found a similar issue that has been resolved here: https://github.com/storybookjs/storybook/issues/21284

貢獻者指南