@@ -87,11 +87,15 @@ export function setupAddons(
87
87
const addonSetupResults : Record < string , AddonSetupResult > = { } ;
88
88
89
89
for ( const addon of addons ) {
90
- const setupResult : AddonSetupResult = { unsupported : [ ] , dependsOn : [ ] } ;
90
+ const setupResult : AddonSetupResult = { unsupported : [ ] , dependsOn : [ ] , runsAfter : [ ] } ;
91
91
addon . setup ?.( {
92
92
...workspace ,
93
- dependsOn : ( name ) => setupResult . dependsOn . push ( name ) ,
94
- unsupported : ( reason ) => setupResult . unsupported . push ( reason )
93
+ dependsOn : ( name ) => {
94
+ setupResult . dependsOn . push ( name ) ;
95
+ setupResult . runsAfter . push ( name ) ;
96
+ } ,
97
+ unsupported : ( reason ) => setupResult . unsupported . push ( reason ) ,
98
+ runsAfter : ( name ) => setupResult . runsAfter . push ( name )
95
99
} ) ;
96
100
addonSetupResults [ addon . id ] = setupResult ;
97
101
}
@@ -181,13 +185,10 @@ async function runAddon({ addon, multiple, workspace }: RunAddon) {
181
185
}
182
186
183
187
// orders addons by putting addons that don't require any other addon in the front.
184
- // This is a drastic simplification, as this could still cause some inconvenient cituations ,
188
+ // This is a drastic simplification, as this could still cause some inconvenient circumstances ,
185
189
// but works for now in contrary to the previous implementation
186
190
function orderAddons ( addons : Array < Addon < any > > , setupResults : Record < string , AddonSetupResult > ) {
187
191
return addons . sort ( ( a , b ) => {
188
- // Adding storybook last means it will correctly detect and integrate with other addons like vitest and eslint
189
- if ( a . id === 'storybook' ) return 1 ;
190
- if ( b . id === 'storybook' ) return - 1 ;
191
- return setupResults [ a . id ] ?. dependsOn ?. length - setupResults [ b . id ] ?. dependsOn ?. length ;
192
+ return setupResults [ a . id ] ?. runsAfter ?. length - setupResults [ b . id ] ?. runsAfter ?. length ;
192
193
} ) ;
193
194
}
0 commit comments