@@ -14,6 +14,8 @@ import { listStories } from './list-stories';
1414const asyncFilter = async ( arr : string [ ] , predicate : ( val : string ) => Promise < boolean > ) =>
1515 Promise . all ( arr . map ( predicate ) ) . then ( ( results ) => arr . filter ( ( _v , index ) => results [ index ] ) ) ;
1616
17+ // TODO: This function should be reworked. The code it uses is outdated and we need to investigate
18+ // More info: https://github.com/storybookjs/storybook/issues/32462#issuecomment-3421326557
1719export async function getOptimizeDeps ( config : ViteInlineConfig , options : Options ) {
1820 const extraOptimizeDeps = await options . presets . apply ( 'optimizeViteDeps' , [ ] ) ;
1921
@@ -27,18 +29,15 @@ export async function getOptimizeDeps(config: ViteInlineConfig, options: Options
2729 // This function converts ids which might include ` > ` to a real path, if it exists on disk.
2830 // See https://github.com/vitejs/vite/blob/67d164392e8e9081dc3f0338c4b4b8eea6c5f7da/packages/vite/src/node/optimizer/index.ts#L182-L199
2931 const resolve = resolvedConfig . createResolver ( { asSrc : false } ) ;
30- const include = await asyncFilter (
31- Array . from ( new Set ( [ ...INCLUDE_CANDIDATES , ...extraOptimizeDeps ] ) ) ,
32- async ( id ) => Boolean ( await resolve ( id ) )
33- ) ;
32+ const include = await asyncFilter ( INCLUDE_CANDIDATES , async ( id ) => Boolean ( await resolve ( id ) ) ) ;
3433
3534 const optimizeDeps : UserConfig [ 'optimizeDeps' ] = {
3635 ...config . optimizeDeps ,
3736 // We don't need to resolve the glob since vite supports globs for entries.
3837 entries : stories ,
3938 // We need Vite to precompile these dependencies, because they contain non-ESM code that would break
4039 // if we served it directly to the browser.
41- include : [ ...include , ...( config . optimizeDeps ?. include || [ ] ) ] ,
40+ include : [ ...include , ...extraOptimizeDeps , ... ( config . optimizeDeps ?. include || [ ] ) ] ,
4241 } ;
4342
4443 return optimizeDeps ;
0 commit comments