@@ -908,9 +908,14 @@ export default class Chunk {
908
908
deconflictedDefault . add ( chunk ) ;
909
909
}
910
910
} else if (
911
- variable . name === '*' &&
912
- namespaceInteropHelpersByInteropType [ interop ( module . id ) ]
911
+ variable . isNamespace &&
912
+ namespaceInteropHelpersByInteropType [ interop ( module . id ) ] &&
913
+ ( this . imports . has ( variable ) ||
914
+ ! this . exportNamesByVariable . get ( variable ) ?. every ( name => name . startsWith ( '*' ) ) )
913
915
) {
916
+ // We only need to deconflict it if the namespace is actually
917
+ // created as a variable, i.e. because it is used internally or
918
+ // because it is reexported as an object
914
919
deconflictedNamespace . add ( chunk ) ;
915
920
}
916
921
}
@@ -1139,30 +1144,34 @@ export default class Chunk {
1139
1144
const reexportSpecifiers = this . getReexportSpecifiers ( ) ;
1140
1145
const renderedDependencies = new Map < Chunk | ExternalChunk , ChunkDependency > ( ) ;
1141
1146
const fileName = this . getFileName ( ) ;
1142
- for ( const dep of this . dependencies ) {
1143
- const imports = importSpecifiers . get ( dep ) || null ;
1144
- const reexports = reexportSpecifiers . get ( dep ) || null ;
1145
- const namedExportsMode = dep instanceof ExternalChunk || dep . exportMode !== 'default' ;
1146
- const importPath = dep . getImportPath ( fileName ) ;
1147
-
1148
- renderedDependencies . set ( dep , {
1149
- attributes : dep instanceof ExternalChunk ? dep . getImportAttributes ( this . snippets ) : null ,
1150
- defaultVariableName : dep . defaultVariableName ,
1147
+ for ( const dependency of this . dependencies ) {
1148
+ const imports = importSpecifiers . get ( dependency ) || null ;
1149
+ const reexports = reexportSpecifiers . get ( dependency ) || null ;
1150
+ const namedExportsMode =
1151
+ dependency instanceof ExternalChunk || dependency . exportMode !== 'default' ;
1152
+ const importPath = dependency . getImportPath ( fileName ) ;
1153
+
1154
+ renderedDependencies . set ( dependency , {
1155
+ attributes :
1156
+ dependency instanceof ExternalChunk
1157
+ ? dependency . getImportAttributes ( this . snippets )
1158
+ : null ,
1159
+ defaultVariableName : dependency . defaultVariableName ,
1151
1160
globalName :
1152
- dep instanceof ExternalChunk &&
1161
+ dependency instanceof ExternalChunk &&
1153
1162
( this . outputOptions . format === 'umd' || this . outputOptions . format === 'iife' ) &&
1154
1163
getGlobalName (
1155
- dep ,
1164
+ dependency ,
1156
1165
this . outputOptions . globals ,
1157
1166
( imports || reexports ) !== null ,
1158
1167
this . inputOptions . onLog
1159
1168
) ,
1160
1169
importPath,
1161
1170
imports,
1162
- isChunk : dep instanceof Chunk ,
1163
- name : dep . variableName ,
1171
+ isChunk : dependency instanceof Chunk ,
1172
+ name : dependency . variableName ,
1164
1173
namedExportsMode,
1165
- namespaceVariableName : dep . namespaceVariableName ,
1174
+ namespaceVariableName : dependency . namespaceVariableName ,
1166
1175
reexports
1167
1176
} ) ;
1168
1177
}
0 commit comments