Skip to content

Commit 19089c3

Browse files
committed
fixed an error with unused reexport
1 parent 5282228 commit 19089c3

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/dependencies/HarmonyExportImportedSpecifierDependency.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ HarmonyExportImportedSpecifierDependency.Template.prototype.apply = function(dep
5959
"{configurable: false, enumerable: true, get: function() { return " + name + (valueKey === null ? "_default.a" : valueKey && "[" + valueKey + "]") + "; }});"
6060
}
6161
if(!used) { // we want to rexport something, but the export isn't used
62-
content = "/* unused harmony reexport " + (dep.name || "namespace") + " */\n";
62+
content = "/* unused harmony reexport " + dep.name + " */\n";
6363
} else if(!active) { // we want to reexport something but another exports overrides this one
6464
content = "/* inactive harmony reexport " + (dep.name || "namespace") + " */\n";
6565
} else if(dep.name && dep.id === "default" && !(importedModule && importedModule.meta && importedModule.meta.harmonyModule)) { // we want to reexport the default export from a non-hamory module
@@ -98,6 +98,8 @@ HarmonyExportImportedSpecifierDependency.Template.prototype.apply = function(dep
9898
content += "if(__WEBPACK_IMPORT_KEY__ !== 'default') ";
9999
content += "(function(key) { Object.defineProperty(exports, key, {configurable: false, enumerable: true, get: function() { return " + name + "[key]; }}) }(__WEBPACK_IMPORT_KEY__));\n";
100100
content += "(function(key) { Object.defineProperty(exports, key, {configurable: false, enumerable: true, get: function() { return " + name + "[key]; }}) }(__WEBPACK_IMPORT_KEY__));\n";
101+
} else {
102+
content = "/* unused harmony reexport namespace */\n";
101103
}
102104
source.insert(dep.position, content);
103105
};

test/cases/parsing/harmony/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import Thing2, { Other as Other2 } from "commonjs-trans";
2020

2121
import defaultExport from "def";
2222

23+
import "unused";
24+
2325

2426
it("should import a default export from a module", function() {
2527
defaultExport.should.be.eql("def");

test/cases/parsing/harmony/node_modules/unused.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)