@@ -143,7 +143,7 @@ export default class Chunk {
143143 private dynamicName : string | null = null ;
144144 private readonly exportNamesByVariable = new Map < Variable , string [ ] > ( ) ;
145145 private readonly exports = new Set < Variable > ( ) ;
146- private readonly exportsByName : Record < string , Variable > = Object . create ( null ) ;
146+ private readonly exportsByName = new Map < string , Variable > ( ) ;
147147 private fileName : string | null = null ;
148148 private implicitEntryModules : Module [ ] = [ ] ;
149149 private readonly implicitlyLoadedBefore = new Set < Chunk > ( ) ;
@@ -295,7 +295,7 @@ export default class Chunk {
295295 for ( const [ variable , exportNames ] of exportNamesByVariable ) {
296296 this . exportNamesByVariable . set ( variable , [ ...exportNames ] ) ;
297297 for ( const exportName of exportNames ) {
298- this . exportsByName [ exportName ] = variable ;
298+ this . exportsByName . set ( exportName , variable ) ;
299299 }
300300 remainingExports . delete ( variable ) ;
301301 }
@@ -503,15 +503,11 @@ export default class Chunk {
503503 }
504504
505505 getChunkName ( ) : string {
506- return (
507- this . name || ( this . name = this . outputOptions . sanitizeFileName ( this . getFallbackChunkName ( ) ) )
508- ) ;
506+ return ( this . name ??= this . outputOptions . sanitizeFileName ( this . getFallbackChunkName ( ) ) ) ;
509507 }
510508
511509 getExportNames ( ) : string [ ] {
512- return (
513- this . sortedExportNames || ( this . sortedExportNames = Object . keys ( this . exportsByName ) . sort ( ) )
514- ) ;
510+ return ( this . sortedExportNames ??= Array . from ( this . exportsByName . keys ( ) ) . sort ( ) ) ;
515511 }
516512
517513 getRenderedHash ( ) : string {
@@ -533,7 +529,7 @@ export default class Chunk {
533529 hash . update (
534530 this . getExportNames ( )
535531 . map ( exportName => {
536- const variable = this . exportsByName [ exportName ] ;
532+ const variable = this . exportsByName . get ( exportName ) ! ;
537533 return `${ relativeId ( ( variable . module as Module ) . id ) . replace ( / \\ / g, '/' ) } :${
538534 variable . name
539535 } :${ exportName } `;
@@ -741,13 +737,13 @@ export default class Chunk {
741737 hasExports,
742738 id : this . id ,
743739 indent : this . indentString ,
744- intro : addons . intro ! ,
740+ intro : addons . intro ,
745741 isEntryFacade :
746742 this . outputOptions . preserveModules ||
747743 ( this . facadeModule !== null && this . facadeModule . info . isEntry ) ,
748744 isModuleFacade : this . facadeModule !== null ,
749745 namedExportsMode : this . exportMode !== 'default' ,
750- outro : addons . outro ! ,
746+ outro : addons . outro ,
751747 snippets,
752748 usesTopLevelAwait,
753749 warn : this . inputOptions . onwarn
@@ -868,14 +864,12 @@ export default class Chunk {
868864 existingNames : Record < string , unknown >
869865 ) : string {
870866 const hash = createHash ( ) ;
871- hash . update (
872- [ addons . intro , addons . outro , addons . banner , addons . footer ] . map ( addon => addon || '' ) . join ( ':' )
873- ) ;
867+ hash . update ( [ addons . intro , addons . outro , addons . banner , addons . footer ] . join ( ':' ) ) ;
874868 hash . update ( options . format ) ;
875869 const dependenciesForHashing = new Set < Chunk | ExternalModule > ( [ this ] ) ;
876870 for ( const current of dependenciesForHashing ) {
877871 if ( current instanceof ExternalModule ) {
878- hash . update ( ':' + current . renderPath ) ;
872+ hash . update ( `: ${ current . renderPath } ` ) ;
879873 } else {
880874 hash . update ( current . getRenderedHash ( ) ) ;
881875 hash . update ( current . generateId ( addons , options , existingNames , false ) ) ;
@@ -1013,7 +1007,7 @@ export default class Chunk {
10131007 for ( const exportName of this . getExportNames ( ) ) {
10141008 if ( exportName [ 0 ] === '*' ) continue ;
10151009
1016- const variable = this . exportsByName [ exportName ] ;
1010+ const variable = this . exportsByName . get ( exportName ) ! ;
10171011 if ( ! ( variable instanceof SyntheticNamedExportVariable ) ) {
10181012 const module = variable . module ;
10191013 if ( module && this . chunkByModule . get ( module as Module ) !== this ) continue ;
@@ -1171,7 +1165,7 @@ export default class Chunk {
11711165 dependency = this . modulesById . get ( id ) as ExternalModule ;
11721166 imported = exportName = '*' ;
11731167 } else {
1174- const variable = this . exportsByName [ exportName ] ;
1168+ const variable = this . exportsByName . get ( exportName ) ! ;
11751169 if ( variable instanceof SyntheticNamedExportVariable ) continue ;
11761170 const module = variable . module ! ;
11771171 if ( module instanceof Module ) {
@@ -1287,7 +1281,7 @@ export default class Chunk {
12871281 } : NormalizedOutputOptions ) {
12881282 const syntheticExports = new Set < SyntheticNamedExportVariable > ( ) ;
12891283 for ( const exportName of this . getExportNames ( ) ) {
1290- const exportVariable = this . exportsByName [ exportName ] ;
1284+ const exportVariable = this . exportsByName . get ( exportName ) ! ;
12911285 if (
12921286 format !== 'es' &&
12931287 format !== 'system' &&
0 commit comments