Skip to content

Commit

Permalink
fixes #3584
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Dec 28, 2016
1 parent 2684e06 commit 386d232
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/dependencies/HarmonyExportImportedSpecifierDependency.js
Expand Up @@ -137,10 +137,11 @@ HarmonyExportImportedSpecifierDependency.Template.prototype.apply = function(dep
var content;
var activeExports;
var items;
var importIsHarmony = importedModule && (!importedModule.meta || importedModule.meta.harmonyModule);
var importsExportsUnknown = !importedModule || !Array.isArray(importedModule.providedExports);

function getReexportStatement(key, valueKey) {
return(importIsHarmony || !valueKey ? "" : "if(__webpack_require__.o(" + name + ", " + valueKey + ")) ") +
var conditional = !importsExportsUnknown || !valueKey ? "" : "if(__webpack_require__.o(" + name + ", " + valueKey + ")) ";
return conditional +
"__webpack_require__.d(exports, " + key + ", " +
"function() { return " + name + (valueKey === null ? "_default.a" : valueKey && "[" + valueKey + "]") + "; });\n"
}
Expand Down
2 changes: 2 additions & 0 deletions test/cases/parsing/harmony-commonjs/b.js
@@ -0,0 +1,2 @@
export * from "./c";
export * from "./c2";
1 change: 1 addition & 0 deletions test/cases/parsing/harmony-commonjs/c.js
@@ -0,0 +1 @@
export * from "./d";
1 change: 1 addition & 0 deletions test/cases/parsing/harmony-commonjs/c2.js
@@ -0,0 +1 @@
export var x = "x";
1 change: 1 addition & 0 deletions test/cases/parsing/harmony-commonjs/d.js
@@ -0,0 +1 @@
exports.y = "y";
9 changes: 8 additions & 1 deletion test/cases/parsing/harmony-commonjs/index.js
@@ -1,3 +1,5 @@
import { x, y } from "./b";

it("should pass when required by CommonJS module", function () {
var test1 = require('./a').default;
test1().should.be.eql("OK");
Expand All @@ -12,4 +14,9 @@ it("should pass when use babeljs transpiler", function() {
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var test2 = (0, _test2.default)();
test2.should.be.eql("OK");
})
});

it("should double reexport from non-harmony modules correctly", function() {
y.should.be.eql("y");
x.should.be.eql("x");
});

0 comments on commit 386d232

Please sign in to comment.