-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Stories are not sorted by their export (in production) #15574
Comments
I see this too. Here's an example: I think this is caused by Webpack. We are using Webpack 5.45.1. Or possibly it's a babel thing. Certainly, I've looked in the bundles that Webpack is building, and I can see that the exports have been sorted into alphabetical order there. Here is part of a |
Also seeing this under the same circumstance - only in prod with webpack 5. Sorry for tagging you, @shilman. If you have any pointers, I can investigate further and try to propose a workaround. Btw, this issue should probably be labelled as |
An interesting side effect that is most likely related to this issue, our org is using DocsPage and the story presented as the 'primary' ends up getting replaced with the alphabetic first story, which for ~50% of our components is not right. I hacked around this for now by providing a custom re-implementation of the docs page (with doc blocks) that explicitly sets which story should be the primary one. This also affects the ArgsTable, however that is not fixable via the same workaround as the component is hard coded to only support naming a story to use when used via MDX documentation. |
I stumbled over the fact that stories that import any I can't make sense of this at the moment, but maybe this is helpful to someone. |
We also have the same problem. It's only in |
I've encountered this as well, using the vite builder, in dev. The vite builder uses I've tracked down the first broken version to An example of the issue can be seen in storybookjs/builder-vite#118. |
Yee-haw!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.0-beta.30 containing PR #16626 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
Confirmed that this indeed fixes the story sorting for the vite builder. 🎉 Thanks! |
Thanks for checking @IanVS !! You rock! |
I'm sadly still seeing this issue on |
@sQVe Rats!! Do you a have a reproduction repo you can share? If not, can you create one? See how to create a repro. 🙏 |
@shilman The repo I'm seeing this on is |
@shilman I just grabbed 6.4.0-rc3 and I have the same issue with ordering on webpack5. start-storybook has everything in export order. It will take me a bit to get a sample together, assuming I can reproduce it elsewhere. |
@shilman a sample has been created: https://github.com/FBNitro/webpack5-ordering If you clone that and I was able to isolate this to an issue of having a function in the story vs the same function being imported from another file. Let me know if you need anything else. |
I double-checked, and both the dev and production builds using the vite builder are correctly sorted by export order. So it seems like maybe this is specific to the webpack5 builder, rather than storybook core. |
Curious if anyone has looked at this yet, I've done all the work to move to webpack 5, but I'm holding off until this is resolved. |
Since I've upgraded from an older version (using Webpack 4) to version |
@fabpico do you have a custom babel config? |
@shilman I have following config: Project root There is no .storybook/.babelrc
Not sure if this is needed anymore. However when I remove this file and restart the dev server, the issue persists. .storybook/main.js There is no babel config.
|
@wuifdesign can you post your reproduction somewhere please? |
@tmeasday sure i can, but it is just running the two commands in a terminal anywhere.
Clean repo only run the two commands (no other changes): https://github.com/wuifdesign/storybook-sorting-bug running |
It's not a clean repo, but we have the same issue on https://github.com/redhat-developer/app-services-ui-components if it can help debugging |
Thanks @wuifdesign, I can see the problem. Appreciate the repro even if it's easy, just makes sure we are definitely looking at the same thing, no ambiguity :) |
Looks like you are using 6.4. This is fixed in 6.5. |
I'm closing this as fixed in 6.5. If you are still encountering this issue after upgrading:
Many thanks for your patience on this! The JS ecosystem is the gift that keeps on giving! |
@fabpico I can confirm that the posted reproduction was indeed fixed by 6.5. If you have a reproduction that fails in 6.5 we can re-open and take a look at it. |
@tmeasday You should be able to (at least I can) reproduce it on this fresh storybook installation (v6.5.5) since repro creation is not working. The screenshots prove that the rendered stories are still sorted alphabetically, insted of sorted by how they were defined in order. Node is v16.15.0 if this info helps. |
@tmeasday and @shilman I'm still seeing the issues using Angular 12 and Webpack 5:
while it should be:
This is the code I'm running: https://github.com/elenagarrone/canopy/tree/fep-434-angular-upgrade
|
@elenagarrone can you please open an angular-specific issue to track this? I believe it's fixed for the other frameworks already |
Will do thank you! |
Repros again using webpack 5.76.0 |
@dkilgore-eightfold can you open a new issue with a reproduction please? |
Describe the bug
In production, stories are not sorted according to their export instead, they are sorted alphabetically.
How they should be sorted (working correctly in dev):
How they are actually sorted (in production):
To Reproduce
I've tried to create an example but I could not reproduce the bug.
Here is a working example: https://github.com/inovex/elements
yarn install
yarn start
cd packages/storybook
yarn build
cd dist
serve .
)Everything related to the storybook can be found under
packages/storybook
.System
Additional context
It seems to be related to this issue: #15305
I've tried to sort the stories manually within the
preview.js
but it only sorted the entries in the sidebar but not the actual content on the canvas. Meaning, I would click on the story on the top of the sidebar, leading me to the rendered story at the bottom of the page in the canvas.The text was updated successfully, but these errors were encountered: