@@ -87,11 +87,15 @@ export function setupAddons(
8787 const addonSetupResults : Record < string , AddonSetupResult > = { } ;
8888
8989 for ( const addon of addons ) {
90- const setupResult : AddonSetupResult = { unsupported : [ ] , dependsOn : [ ] } ;
90+ const setupResult : AddonSetupResult = { unsupported : [ ] , dependsOn : [ ] , runsAfter : [ ] } ;
9191 addon . setup ?.( {
9292 ...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 )
9599 } ) ;
96100 addonSetupResults [ addon . id ] = setupResult ;
97101 }
@@ -181,13 +185,10 @@ async function runAddon({ addon, multiple, workspace }: RunAddon) {
181185}
182186
183187// 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 ,
185189// but works for now in contrary to the previous implementation
186190function orderAddons ( addons : Array < Addon < any > > , setupResults : Record < string , AddonSetupResult > ) {
187191 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 ;
192193 } ) ;
193194}
0 commit comments