Skip to content

Commit ee3d53c

Browse files
authored
Merge pull request webpack#3599 from webpack/bugfix/harmony-reexport
fixes webpack#3584
2 parents bc754fc + 386d232 commit ee3d53c

6 files changed

Lines changed: 16 additions & 3 deletions

File tree

lib/dependencies/HarmonyExportImportedSpecifierDependency.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,11 @@ HarmonyExportImportedSpecifierDependency.Template.prototype.apply = function(dep
137137
var content;
138138
var activeExports;
139139
var items;
140-
var importIsHarmony = importedModule && (!importedModule.meta || importedModule.meta.harmonyModule);
140+
var importsExportsUnknown = !importedModule || !Array.isArray(importedModule.providedExports);
141141

142142
function getReexportStatement(key, valueKey) {
143-
return(importIsHarmony || !valueKey ? "" : "if(__webpack_require__.o(" + name + ", " + valueKey + ")) ") +
143+
var conditional = !importsExportsUnknown || !valueKey ? "" : "if(__webpack_require__.o(" + name + ", " + valueKey + ")) ";
144+
return conditional +
144145
"__webpack_require__.d(exports, " + key + ", " +
145146
"function() { return " + name + (valueKey === null ? "_default.a" : valueKey && "[" + valueKey + "]") + "; });\n"
146147
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from "./c";
2+
export * from "./c2";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./d";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export var x = "x";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exports.y = "y";

test/cases/parsing/harmony-commonjs/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { x, y } from "./b";
2+
13
it("should pass when required by CommonJS module", function () {
24
var test1 = require('./a').default;
35
test1().should.be.eql("OK");
@@ -12,4 +14,9 @@ it("should pass when use babeljs transpiler", function() {
1214
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1315
var test2 = (0, _test2.default)();
1416
test2.should.be.eql("OK");
15-
})
17+
});
18+
19+
it("should double reexport from non-harmony modules correctly", function() {
20+
y.should.be.eql("y");
21+
x.should.be.eql("x");
22+
});

0 commit comments

Comments
 (0)