Skip to content

fix: Always add Storybook last #547

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

Merged
merged 5 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slimy-rivers-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sv': patch
---

fix: always add `storybook` after all other add-ons
11 changes: 7 additions & 4 deletions packages/cli/lib/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,12 @@ async function runAddon({ addon, multiple, workspace }: RunAddon) {

// orders addons by putting addons that don't require any other addon in the front.
// This is a drastic simplification, as this could still cause some inconvenient cituations,
// but works for now in contrary to the previouse implementation
// but works for now in contrary to the previous implementation
function orderAddons(addons: Array<Addon<any>>, setupResults: Record<string, AddonSetupResult>) {
return addons.sort(
(a, b) => setupResults[a.id]?.dependsOn?.length - setupResults[b.id]?.dependsOn?.length
);
return addons.sort((a, b) => {
// Adding storybook last means it will correctly detect and integrate with other addons like vitest and eslint
if (a.id === 'storybook') return 1;
if (b.id === 'storybook') return -1;
return setupResults[a.id]?.dependsOn?.length - setupResults[b.id]?.dependsOn?.length;
});
}