diff --git a/.changeset/tricky-icons-allow.md b/.changeset/tricky-icons-allow.md new file mode 100644 index 000000000..7b28bf1bd --- /dev/null +++ b/.changeset/tricky-icons-allow.md @@ -0,0 +1,5 @@ +--- +'sv': patch +--- + +fix: addons executed in the wrong order in certain circumstances diff --git a/packages/cli/lib/install.ts b/packages/cli/lib/install.ts index 6f98ce43d..b894bc07d 100644 --- a/packages/cli/lib/install.ts +++ b/packages/cli/lib/install.ts @@ -180,19 +180,11 @@ async function runAddon({ addon, multiple, workspace }: RunAddon) { }; } -// sorts them to their execution order +// 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 function orderAddons(addons: Array>, setupResults: Record) { - return Array.from(addons).sort((a, b) => { - const aDeps = setupResults[a.id].dependsOn; - const bDeps = setupResults[b.id].dependsOn; - - if (!aDeps && !bDeps) return 0; - if (!aDeps) return -1; - if (!bDeps) return 1; - - if (aDeps.includes(b.id)) return 1; - if (bDeps.includes(a.id)) return -1; - - return 0; - }); + return addons.sort( + (a, b) => setupResults[a.id]?.dependsOn?.length - setupResults[b.id]?.dependsOn?.length + ); }