@@ -43,23 +43,39 @@ HarmonyExportImportedSpecifierDependency.Template = function HarmonyExportImport
4343HarmonyExportImportedSpecifierDependency . Template . prototype . apply = function ( dep , source , outputOptions , requestShortener ) {
4444 var name = dep . importedVar ;
4545 var used = dep . originModule . isUsed ( dep . name ) ;
46+ var importedModule = dep . importDependency . module ;
4647 var active = HarmonyModulesHelpers . isActive ( dep . originModule , dep ) ;
47- var comment = "" ;
48- if ( outputOptions . pathinfo ) comment = "/*! " + requestShortener . shorten ( dep . request ) + " */ " ;
4948 var content ;
5049 if ( ! used ) {
5150 content = "/* unused harmony reexport " + ( dep . name || "namespace" ) + " */" ;
5251 } else if ( ! active ) {
5352 content = "/* inactive harmony reexport " + ( dep . name || "namespace" ) + " */" ;
54- } else if ( dep . name === "default" && ! ( dep . importDependency . module . meta && dep . importDependency . module . meta . harmonyModule ) ) {
55- content = "/* harmony reexport */ Object.defineProperty(exports, " + JSON . stringify ( dep . name ) + ", {configurable: false, enumerable: true, get: function() { return " + comment + name + "_default.a; }});" ;
53+ } else if ( dep . name === "default" && ! ( importedModule && importedModule . meta && importedModule . meta . harmonyModule ) ) {
54+ content = "/* harmony reexport */ Object.defineProperty(exports, " + JSON . stringify ( used ) + ", {configurable: false, enumerable: true, get: function() { return " + name + "_default.a; }});" ;
5655 } else if ( dep . name && dep . id ) {
57- content = "/* harmony reexport */ Object.defineProperty(exports, " + JSON . stringify ( dep . name ) + ", {configurable: false, enumerable: true, get: function() { return " + comment + ( name + "[" + JSON . stringify ( dep . id ) + "]" ) + "; }});" ;
56+ var idUsed = importedModule && importedModule . isUsed ( dep . id ) ;
57+ content = "/* harmony reexport */ Object.defineProperty(exports, " + JSON . stringify ( used ) + ", {configurable: false, enumerable: true, get: function() { return " + ( name + "[" + JSON . stringify ( idUsed ) + "]" ) + "; }});" ;
5858 } else if ( dep . name ) {
59- content = "/* harmony reexport */ Object.defineProperty(exports, " + JSON . stringify ( dep . name ) + ", {configurable: false, enumerable: true, get: function() { return " + comment + name + "; }});" ;
60- } else {
59+ content = "/* harmony reexport */ Object.defineProperty(exports, " + JSON . stringify ( used ) + ", {configurable: false, enumerable: true, get: function() { return " + name + "; }});" ;
60+ } else if ( Array . isArray ( dep . originModule . usedExports ) ) {
6161 var activeExports = HarmonyModulesHelpers . getActiveExports ( dep . originModule ) ;
62- content = "/* harmony namespace reexport */ for(var __WEBPACK_IMPORT_KEY__ in " + comment + name + ") " ;
62+ var items = dep . originModule . usedExports . map ( function ( id ) {
63+ if ( id === "default" ) return ;
64+ if ( activeExports . indexOf ( id ) >= 0 ) return ;
65+ var exportUsed = dep . originModule . isUsed ( id ) ;
66+ var idUsed = importedModule && importedModule . isUsed ( id ) ;
67+ return [ exportUsed , idUsed ] ;
68+ } ) . filter ( Boolean ) ;
69+ if ( items . length > 1 ) {
70+ content = "/* harmony namespace reexport */ " + JSON . stringify ( items ) + ".forEach(function(i) { " +
71+ "Object.defineProperty(exports, i[0], {configurable: false, enumerable: true, get: function() { return " + ( name + "[i[1]]" ) + "; }});" +
72+ "});" ;
73+ } else if ( items . length === 1 ) {
74+ content = "/* harmony namespace reexport */ Object.defineProperty(exports, " + JSON . stringify ( items [ 0 ] [ 0 ] ) + ", {configurable: false, enumerable: true, get: function() { return " + ( name + "[" + JSON . stringify ( items [ 0 ] [ 1 ] ) + "]" ) + "; }});" ;
75+ } else content = "/* unused harmony namespace reexport */" ;
76+ } else if ( dep . originModule . usedExports ) {
77+ var activeExports = HarmonyModulesHelpers . getActiveExports ( dep . originModule ) ;
78+ content = "/* harmony namespace reexport */ for(var __WEBPACK_IMPORT_KEY__ in " + name + ") " ;
6379
6480 // Filter out exports which are defined by other exports
6581 // and filter out default export because it cannot be reexported with *
0 commit comments