Angular component is not a know element when importing its module
See original GitHub issueDescribe the bug
In v6.2.0-alpha.28
when importing the module of a component inside a story the component is not a known element anymore.
To Reproduce
Import the module that hosts the component:
export default {
title: 'Components/MyComponent',
component: MyComponent,
decorators: [
moduleMetadata({
imports: [BrowserAnimationsModule, MyModule],
}),
],
} as Meta;
const Template: Story<MyComponent> = (args) => ({
component: MyComponent,
props: args,
});
export const MyState = Template.bind({});
In contrast it works when:
- Removing the Module import, but thats not an option since the module imports important dependencies like pipes, services, etc.
- Adding the component to exports, but actually I dont want to the component to be exported in my app
- Downgrading to
^6.1.18
Expected behavior
The component should be created as in 6.1.x without having to add it to module’s exports
System
System: OS: macOS 11.2.1 CPU: (12) x64 Intel® Core™ i7-9750H CPU @ 2.60GHz Binaries: Node: 15.6.0 - ~/.nvm/versions/node/v15.6.0/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.4.0 - ~/.nvm/versions/node/v15.6.0/bin/npm Browsers: Chrome: 88.0.4324.150 Firefox: 81.0.1 Safari: 14.0.3 npmPackages: @storybook/addon-actions: v6.2.0-alpha.28 => 6.2.0-alpha.28 @storybook/addon-essentials: v6.2.0-alpha.28 => 6.2.0-alpha.28 @storybook/addon-links: v6.2.0-alpha.28 => 6.2.0-alpha.28 @storybook/angular: v6.2.0-alpha.28 => 6.2.0-alpha.28
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top GitHub Comments
Yes you are right @MickL This was a fallacious storybook behaviour and which went against the functioning of Angular. I think
either you use a module that exports the component or either you reproduce in story, the module by declaring components, imports, ext…
A mix of the 2 is incoherent. Storybook needs to make a module and Angular prohibits declaration of component in 2 different modules 😕
If I try to reproduce the module by declaring components, imports, etc., I get an error that the component is defined in two modules. So the only way around this issue is to export all the components I want to have in Storybook.