@@ -143,7 +143,8 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
143
143
*/
144
144
getReferencedExports ( moduleGraph , runtime ) {
145
145
let ids = this . getIds ( moduleGraph ) ;
146
- if ( ids . length === 0 ) return this . _getReferencedExportsInDestructuring ( ) ;
146
+ if ( ids . length === 0 )
147
+ return this . _getReferencedExportsInDestructuring ( moduleGraph ) ;
147
148
let namespaceObjectAsContext = this . namespaceObjectAsContext ;
148
149
if ( ids [ 0 ] === "default" ) {
149
150
const selfModule = moduleGraph . getParentModule ( this ) ;
@@ -160,7 +161,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
160
161
case "default-only" :
161
162
case "default-with-named" :
162
163
if ( ids . length === 1 )
163
- return this . _getReferencedExportsInDestructuring ( ) ;
164
+ return this . _getReferencedExportsInDestructuring ( moduleGraph ) ;
164
165
ids = ids . slice ( 1 ) ;
165
166
namespaceObjectAsContext = true ;
166
167
break ;
@@ -178,21 +179,30 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
178
179
ids = ids . slice ( 0 , - 1 ) ;
179
180
}
180
181
181
- return this . _getReferencedExportsInDestructuring ( ids ) ;
182
+ return this . _getReferencedExportsInDestructuring ( moduleGraph , ids ) ;
182
183
}
183
184
184
185
/**
186
+ * @param {ModuleGraph } moduleGraph module graph
185
187
* @param {string[]= } ids ids
186
188
* @returns {(string[] | ReferencedExport)[] } referenced exports
187
189
*/
188
- _getReferencedExportsInDestructuring ( ids ) {
190
+ _getReferencedExportsInDestructuring ( moduleGraph , ids ) {
189
191
if ( this . referencedPropertiesInDestructuring ) {
190
192
/** @type {ReferencedExport[] } */
191
193
const refs = [ ] ;
194
+ const importedModule = moduleGraph . getModule ( this ) ;
195
+ const canMangle =
196
+ Array . isArray ( ids ) &&
197
+ ids . length > 0 &&
198
+ ! moduleGraph
199
+ . getExportsInfo ( importedModule )
200
+ . getExportInfo ( ids [ 0 ] )
201
+ . isReexport ( ) ;
192
202
for ( const key of this . referencedPropertiesInDestructuring ) {
193
203
refs . push ( {
194
204
name : ids ? ids . concat ( [ key ] ) : [ key ] ,
195
- canMangle : Array . isArray ( ids ) && ids . length > 0
205
+ canMangle
196
206
} ) ;
197
207
}
198
208
return refs ;
0 commit comments