storybook: Source-loader: Breaks when stories reference other stories before they are defined
Describe the bug waring: @storybook/source-loader was applied to a file which does not contain a story. Please check your webpack configuration and make sure to apply @storybook/source-loader only to files containg stories. Related file:"
To Reproduce Steps to reproduce the behavior:
- run is repo
Expected behavior no waring
Screenshots

Code snippets
export function AllButton() {
return (
<>
<DefaultButton />
<PrimaryButton />
<SuccessButton />
</>
);
}
export function DefaultButton() {
return (
<Button
onClick={action("clicked")}
text={text("Default Button", "Default Button")}
/>
);
}
export function PrimaryButton() {
return (
<Button
onClick={action("clicked")}
text={text("Primary Button", "Primary Button")}
type="primary"
/>
);
}
export function SuccessButton() {
return (
<Button
onClick={action("clicked")}
text={text("Success Button", "Success Button")}
type="success"
/>
);
}
System:
Environment Info:
System:
OS: macOS 10.15.4
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Binaries:
Node: 13.12.0 - ~/.nvm/versions/node/v13.12.0/bin/node
Yarn: 1.22.0 - /usr/local/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v13.12.0/bin/npm
Browsers:
Chrome: 80.0.3987.163
Safari: 13.1
npmPackages:
@storybook/addon-actions: ^5.3.18 => 5.3.18
@storybook/addon-console: ^1.2.1 => 1.2.1
@storybook/addon-docs: ^5.3.18 => 5.3.18
@storybook/addon-knobs: ^5.3.18 => 5.3.18
@storybook/addon-links: ^5.3.18 => 5.3.18
@storybook/addon-notes: ^5.3.18 => 5.3.18
@storybook/addons: ^5.3.18 => 5.3.18
@storybook/preset-create-react-app: ^2.1.1 => 2.1.1
@storybook/react: ^5.3.18 => 5.3.18
Additional context Add any other context about the problem here.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 9
- Comments: 21 (7 by maintainers)
I’m able to repro in the original repo. How I worked around it:
export function Footoexport const Foo =Allstory to the end of the file so that it is defined AFTER the stories it referencesI’m seeing even worse behavior in 6.0-beta. Renaming the issue and calling this a bug.
I’m using beta.29 and I have defined all of my components before referencing them:
I still see the console warning.
Can you try adding this to your
export defaultup top?includeStories: []I was getting both this warning and “story with id already exists in store” warnings. I added that per https://github.com/storybookjs/storybook/blob/master/addons/docs/docs/recipes.md#csf-stories-with-mdx-docs and both types of warnings disappeared for me. Might be worth a shot.
According to official-storybook/tooltip-listitem–all. Waring will solved if I update code snippets like this:
That’s a little puzzled! 😔
@aaronmcadam yep, same for me; would love to use the new CSF format. I am not a storybook dev so I cant say if this is a known limitation but by how @shilman seems to be surprised, I guess this is indeed a bug.
it seems like the
source-loaderplugin doesnt support the new CSF story format. Using the oldstoriesOf().add()works as expected