-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[Bug]: Type "MyComponent" is part of the declarations of 2 modules: StorybookComponentModule and StorybookComponentModule #23669
Comments
Ok, I found the problem I think. First, the real error message is not I missed that because the first page Storybook loads is the Documentation, and I immediately click on my first component when the doc is loaded. This click fires the "2 modules" error, I don't know why (and this is very misleading). When I reload the page with F5 when I'm on a component directly, I have the blindingStartIndex error. After a few searches on Google, I found that linking the library with So in the end I think this bug is related to : #17601 Storybook seems to not support the local linking of libraries, because it seems there is no way to pass the |
Hi @DB-CL, Thank you for the investigations! So this issue can be closed? |
Hi there! Thank you for opening this issue, but it has been marked as |
I'm afraid we need to close this issue for now, since we can't take any action without the requested reproduction or additional information. But please don't hesitate to open a new issue if the problem persists – we're always happy to help. Thanks so much for your understanding. |
Describe the bug
I have two libraries : Library A and Library B. The libraries are two totally different projects. Library A is included in Library B via
npm install @myscope/libraryA
In Library A, I declare Component A in module A.
In Library B, I declare Component B in module B.
The component B is using Component A with something similar to
<div lib-component-A [model]="..." ></div>
.The ModuleB imports ModuleA like so :
Note : the component A is using attribute selector like a directive :
selector: '[lib-component-A]'
. But I don't think it matters.My story is configured that way :
And the error I have is the following :
Type ComponentB is part of the declarations of 2 modules: StorybookComponentModule and StorybookComponentModule! Please consider moving ComponentB to a higher module that imports StorybookComponentModule and StorybookComponentModule. You can also create a new NgModule that exports and includes ComponentB then import that NgModule in StorybookComponentModule and StorybookComponentModule.
I don't understand. ModuleA has nothing to do with ComponentB. Importing ModuleA should not trigger a double declaration for ComponentB
I've tried to play with the imports and the declarations, and when I remove the ModuleA import, I have the very classical runtime error :
Can't bind to 'model' since it isn't a known property of 'div'
. This error often indicates that the ComponentA is not recognized because the module is not properly imported.I've found this old error : #14026 or this one #19289
But both should have been resolved with 7.0, and I'm running Storybook v 7.1.1 with angular 15.2
Am I doing something wrong or is this a bug in storybook ? If so, does anyone know a workaround ?
To Reproduce
I've added a minimal reproduction repository here : https://github.com/DB-CL/bug-storybook/
The instructions to reproduce are in the readme
System
Additional context
Since my modules are not using any services, I didn't use
applicationConfig
But I tried it anyway : I pretented my LibraryA provided a service and I did something like :
Just to see if there was any difference. And it behave the same way with the same error.
The text was updated successfully, but these errors were encountered: