You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have experienced weird occurances of the following errors "Unexpected directive ..... imported by the module. Please add an @NgModule annotation. StorybookComponentModule" in some of our stories that we could not really explain.
This meta data is then used to prepare the JIT compilation of an inline module (StorybookComponentModule). If the component passed in the Storybook story with the component property is detected as standalone component, the Storybook Angular framework addon is automatically adding the component at the end of the imports of the StorybookComponentModule.
The logic here https://github.com/storybookjs/storybook/blob/next/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.ts#L173-L180 might be working for most use-cases. However, we are facing some situations where this will not work as expected. In the case of component inheritance CompA(standalone) -> B(standalone) -> C(no standalone), all three Component Meta objects are returned from reflectionCapabilities.annotations(component). In this case the logic to detect if our referenced component (C, which is not standalone) will falsely detect the component as standalone (Because the use of some, checking on all three component meta objects).
To Reproduce
Create a Standalone Component A
Create a non-standalone component B that inherits from the previous standalone component A
Create a Story that references the B
Put the import of the NgModule that contains component B into the moduleMetadata section
The page should now show the error "Unexpected directive ..... imported by the module. Please add an @NgModule annotation. StorybookComponentModule" because the component B is mistaken as a standalone component and was added to the import list of the StorybookComponentModule.
Describe the bug
We have experienced weird occurances of the following errors "Unexpected directive ..... imported by the module. Please add an @NgModule annotation. StorybookComponentModule" in some of our stories that we could not really explain.
Currently the logic to detect if a component or directive is standalone is done here:
https://github.com/storybookjs/storybook/blob/next/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.ts#L173-L180
This meta data is then used to prepare the JIT compilation of an inline module (StorybookComponentModule). If the component passed in the Storybook story with the
component
property is detected as standalone component, the Storybook Angular framework addon is automatically adding the component at the end of the imports of theStorybookComponentModule
.The logic here https://github.com/storybookjs/storybook/blob/next/code/frameworks/angular/src/client/angular-beta/utils/PropertyExtractor.ts#L173-L180 might be working for most use-cases. However, we are facing some situations where this will not work as expected. In the case of component inheritance
CompA(standalone) -> B(standalone) -> C(no standalone)
, all threeComponent
Meta objects are returned fromreflectionCapabilities.annotations(component)
. In this case the logic to detect if our referenced component (C, which is not standalone) will falsely detect the component as standalone (Because the use of some, checking on all three component meta objects).To Reproduce
System
Additional context
No response
The text was updated successfully, but these errors were encountered: