@@ -232,7 +232,8 @@ type fileMeta struct {
232
232
//
233
233
// Re-exports come from other files and are the result of resolving export
234
234
// star statements (i.e. "export * from 'foo'").
235
- resolvedExports map [string ]exportData
235
+ resolvedExports map [string ]exportData
236
+ resolvedExportStar * exportData
236
237
237
238
// Never iterate over "resolvedExports" directly. Instead, iterate over this
238
239
// array. Some exports in that map aren't meant to end up in generated code.
@@ -1248,10 +1249,10 @@ func (c *linkerContext) scanImportsAndExports() {
1248
1249
IsNamespaceExport : true ,
1249
1250
}, partMeta {})
1250
1251
1251
- // Also add a special export called "*" so import stars can bind to it.
1252
- // This must be done in this step because it must come after CommonJS
1253
- // module discovery but before matching imports with exports.
1254
- repr .meta .resolvedExports [ "*" ] = exportData {
1252
+ // Also add a special export so import stars can bind to it. This must be
1253
+ // done in this step because it must come after CommonJS module discovery
1254
+ // but before matching imports with exports.
1255
+ repr .meta .resolvedExportStar = & exportData {
1255
1256
ref : repr .ast .ExportsRef ,
1256
1257
sourceIndex : sourceIndex ,
1257
1258
}
@@ -1302,12 +1303,6 @@ func (c *linkerContext) scanImportsAndExports() {
1302
1303
aliases := make ([]string , 0 , len (repr .meta .resolvedExports ))
1303
1304
nextAlias:
1304
1305
for alias , export := range repr .meta .resolvedExports {
1305
- // The automatically-generated namespace export is just for internal binding
1306
- // purposes and isn't meant to end up in generated code.
1307
- if alias == "*" {
1308
- continue
1309
- }
1310
-
1311
1306
// Re-exporting multiple symbols with the same name causes an ambiguous
1312
1307
// export. These names cannot be used and should not end up in generated code.
1313
1308
otherRepr := c .files [export .sourceIndex ].repr .(* reprJS )
@@ -2286,7 +2281,7 @@ func (c *linkerContext) advanceImportTracker(tracker importTracker) (importTrack
2286
2281
2287
2282
// Is this a named import of a file without any exports?
2288
2283
otherRepr := c .files [otherSourceIndex ].repr .(* reprJS )
2289
- if namedImport .Alias != "*" && ! otherRepr .ast .UsesCommonJSExports () && ! otherRepr .ast .HasESMFeatures () && ! otherRepr .ast .HasLazyExport {
2284
+ if ! namedImport .AliasIsStar && ! otherRepr .ast .UsesCommonJSExports () && ! otherRepr .ast .HasESMFeatures () && ! otherRepr .ast .HasLazyExport {
2290
2285
// Just warn about it and replace the import with "undefined"
2291
2286
return importTracker {sourceIndex : otherSourceIndex , importRef : js_ast .InvalidRef }, importCommonJSWithoutExports , nil
2292
2287
}
@@ -2296,6 +2291,16 @@ func (c *linkerContext) advanceImportTracker(tracker importTracker) (importTrack
2296
2291
return importTracker {sourceIndex : otherSourceIndex , importRef : js_ast .InvalidRef }, importCommonJS , nil
2297
2292
}
2298
2293
2294
+ // Match this import star with an export star from the imported file
2295
+ if matchingExport := otherRepr .meta .resolvedExportStar ; namedImport .AliasIsStar && matchingExport != nil {
2296
+ // Check to see if this is a re-export of another import
2297
+ return importTracker {
2298
+ sourceIndex : matchingExport .sourceIndex ,
2299
+ importRef : matchingExport .ref ,
2300
+ nameLoc : matchingExport .nameLoc ,
2301
+ }, importFound , matchingExport .potentiallyAmbiguousExportStarRefs
2302
+ }
2303
+
2299
2304
// Match this import up with an export from the imported file
2300
2305
if matchingExport , ok := otherRepr .meta .resolvedExports [namedImport .Alias ]; ok {
2301
2306
// Check to see if this is a re-export of another import
@@ -3813,9 +3818,7 @@ func (repr *chunkReprJS) generate(c *linkerContext, chunk *chunkInfo) func(gener
3813
3818
resolvedExports := fileRepr .meta .resolvedExports
3814
3819
aliases = make ([]string , 0 , len (resolvedExports ))
3815
3820
for alias := range resolvedExports {
3816
- if alias != "*" {
3817
- aliases = append (aliases , alias )
3818
- }
3821
+ aliases = append (aliases , alias )
3819
3822
}
3820
3823
}
3821
3824
} else {
0 commit comments