@@ -24,11 +24,41 @@ HarmonyExportImportedSpecifierDependency.prototype.getReference = function() {
2424 var used = this . originModule . isUsed ( this . name ) ;
2525 var active = HarmonyModulesHelpers . isActive ( this . originModule , this ) ;
2626 if ( ! this . importDependency . module || ! used || ! active ) return null ;
27- return {
28- module : this . importDependency . module ,
29- importedNames : this . id ? [ this . id ] : true ,
30- precedence : this . name ? 2 : 3
31- } ;
27+ if ( ! this . originModule . usedExports ) return null ;
28+ var m = this . importDependency . module ;
29+ if ( ! this . name ) {
30+ // export *
31+ if ( Array . isArray ( this . originModule . usedExports ) ) {
32+ // reexport * with known used exports
33+ var activeExports = HarmonyModulesHelpers . getActiveExports ( this . originModule ) ;
34+ return {
35+ module : m ,
36+ importedNames : this . originModule . usedExports . filter ( function ( id ) {
37+ return activeExports . indexOf ( id ) < 0 ;
38+ } )
39+ }
40+ } else {
41+ return {
42+ module : m ,
43+ importedNames : true
44+ }
45+ }
46+ } else {
47+ if ( Array . isArray ( this . originModule . usedExports ) && this . originModule . usedExports . indexOf ( this . name ) < 0 ) return null ;
48+ if ( this . id ) {
49+ // export { name as name }
50+ return {
51+ module : m ,
52+ importedNames : [ this . id ]
53+ } ;
54+ } else {
55+ // export { * as name }
56+ return {
57+ module : m ,
58+ importedNames : true
59+ } ;
60+ }
61+ }
3262} ;
3363
3464HarmonyExportImportedSpecifierDependency . prototype . describeHarmonyExport = function ( ) {
@@ -77,7 +107,7 @@ HarmonyExportImportedSpecifierDependency.Template.prototype.apply = function(dep
77107 var items = dep . originModule . usedExports . map ( function ( id ) {
78108 if ( id === "default" ) return ;
79109 if ( activeExports . indexOf ( id ) >= 0 ) return ;
80- if ( importIsHarmony && importActiveExports . indexOf ( id ) < 0 ) return ;
110+ if ( importIsHarmony && ! HarmonyModulesHelpers . isExportedByHarmony ( importedModule , id ) ) return ;
81111 var exportUsed = dep . originModule . isUsed ( id ) ;
82112 var idUsed = importedModule && importedModule . isUsed ( id ) ;
83113 return [ exportUsed , idUsed ] ;
0 commit comments