@@ -40,9 +40,12 @@ function getExternalImport(importedModule, importedVar, exportName, asCall) {
4040 if ( ! isHarmonyModule && exportName === "default" ) {
4141 return asCall ? `${ importedVar } _default()` : `${ importedVar } _default.a` ;
4242 }
43+ // TODO use Template.toNormalComment when merging with pure-module
44+ const comment = used !== exportName ? ` /* ${ exportName } */` : "" ;
45+ const reference = `${ importedVar } [${ JSON . stringify ( used ) } ${ comment } ]` ;
4346 if ( asCall )
44- return `Object(${ importedVar } [ ${ JSON . stringify ( used ) } ] )` ;
45- return ` ${ importedVar } [ ${ JSON . stringify ( used ) } ]` ;
47+ return `Object(${ reference } )` ;
48+ return reference ;
4649}
4750
4851function getFinalName ( info , exportName , moduleToInfoMap , requestShortener , asCall ) {
@@ -445,7 +448,7 @@ class ConcatenatedModule extends Module {
445448 } ) ;
446449
447450 // List of all used names to avoid conflicts
448- const allUsedNames = new Set ( [ "__WEBPACK_MODULE_DEFAULT_EXPORT__" , "defaultExport" , " Object"] ) ;
451+ const allUsedNames = new Set ( [ "__WEBPACK_MODULE_DEFAULT_EXPORT__" , "Object" ] ) ;
449452
450453 // get all global names
451454 modulesWithInfo . forEach ( info => {
@@ -500,7 +503,7 @@ class ConcatenatedModule extends Module {
500503 }
501504 case "external" :
502505 {
503- const externalName = this . findNewName ( "externalModule " , allUsedNames , null , info . module . readableIdentifier ( requestShortener ) ) ;
506+ const externalName = this . findNewName ( "" , allUsedNames , null , info . module . readableIdentifier ( requestShortener ) ) ;
504507 allUsedNames . add ( externalName ) ;
505508 info . name = externalName ;
506509 break ;
@@ -573,14 +576,14 @@ class ConcatenatedModule extends Module {
573576 let name = oldName ;
574577
575578 if ( name === "__WEBPACK_MODULE_DEFAULT_EXPORT__" )
576- name = "defaultExport " ;
579+ name = "" ;
577580
578581 // Remove uncool stuff
579582 extraInfo = extraInfo . replace ( / ( \/ i n d e x ) ? \. ( [ a - z A - Z 0 - 9 ] { 1 , 4 } ) $ / , "" ) ;
580583
581584 const splittedInfo = extraInfo . split ( "/" ) ;
582585 while ( splittedInfo . length ) {
583- name = splittedInfo . pop ( ) + "_" + name ;
586+ name = splittedInfo . pop ( ) + ( name ? "_" + name : "" ) ;
584587 const nameIdent = Template . toIdentifier ( name ) ;
585588 if ( ! usedNamed1 . has ( nameIdent ) && ( ! usedNamed2 || ! usedNamed2 . has ( nameIdent ) ) ) return nameIdent ;
586589 }
0 commit comments