@@ -610,41 +610,37 @@ export function runOptimizeDeps(
610
610
return context
611
611
. build ( )
612
612
. then ( ( result ) => {
613
- const depsForSrc : Record < string , OptimizedDepInfo [ ] > = { }
613
+ const depForEntryFileName : Record < string , OptimizedDepInfo > = { }
614
614
for ( const dep of Object . values ( depsInfo ) ) {
615
- if ( dep . src ) {
616
- // One chunk maybe corresponding multiply entry
617
- depsForSrc [ dep . src ] ||= [ ]
618
- depsForSrc [ dep . src ] . push ( dep )
619
- }
615
+ const entryFileName = flattenId ( dep . id ) + '.js'
616
+ depForEntryFileName [ entryFileName ] = dep
620
617
}
621
618
622
619
for ( const chunk of result . output ) {
623
620
if ( chunk . type !== 'chunk' ) continue
624
621
625
622
if ( chunk . isEntry ) {
626
- const deps = depsForSrc [ normalizePath ( chunk . facadeModuleId ! ) ]
627
- for ( const { exportsData, file, id, ...info } of deps ) {
628
- addOptimizedDepInfo ( metadata , 'optimized' , {
623
+ const { exportsData, file, id, ...info } =
624
+ depForEntryFileName [ chunk . fileName ]
625
+ addOptimizedDepInfo ( metadata , 'optimized' , {
626
+ id,
627
+ file,
628
+ ...info ,
629
+ // We only need to hash the output.imports in to check for stability, but adding the hash
630
+ // and file path gives us a unique hash that may be useful for other things in the future
631
+ fileHash : getHash (
632
+ metadata . hash + file + JSON . stringify ( chunk . modules ) ,
633
+ ) ,
634
+ browserHash : metadata . browserHash ,
635
+ // After bundling we have more information and can warn the user about legacy packages
636
+ // that require manual configuration
637
+ needsInterop : needsInterop (
638
+ environment ,
629
639
id ,
630
- file,
631
- ...info ,
632
- // We only need to hash the output.imports in to check for stability, but adding the hash
633
- // and file path gives us a unique hash that may be useful for other things in the future
634
- fileHash : getHash (
635
- metadata . hash + file + JSON . stringify ( chunk . modules ) ,
636
- ) ,
637
- browserHash : metadata . browserHash ,
638
- // After bundling we have more information and can warn the user about legacy packages
639
- // that require manual configuration
640
- needsInterop : needsInterop (
641
- environment ,
642
- id ,
643
- idToExports [ id ] ,
644
- chunk ,
645
- ) ,
646
- } )
647
- }
640
+ idToExports [ id ] ,
641
+ chunk ,
642
+ ) ,
643
+ } )
648
644
} else {
649
645
const id = chunk . fileName . replace ( jsExtensionRE , '' )
650
646
const file = getOptimizedDepPath ( environment , id )
@@ -796,6 +792,7 @@ async function prepareRolldownOptimizerRun(
796
792
format : 'esm' ,
797
793
sourcemap : true ,
798
794
dir : processingCacheDir ,
795
+ entryFileNames : '[name].js' ,
799
796
banner :
800
797
platform === 'node'
801
798
? `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
0 commit comments