Skip to content

Commit

Permalink
fixed webpack#1833
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jan 6, 2016
1 parent 5811c57 commit 987d718
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ HarmonyExportImportedSpecifierDependency.Template.prototype.apply = function(dep
content = "/* unused harmony reexport " + (dep.name || "namespace") + " */";
} else if(!active) {
content = "/* inactive harmony reexport " + (dep.name || "namespace") + " */";
} else if(dep.name === "default" && !dep.importDependency.module.meta.harmonyModule) {
} else if(dep.name === "default" && !(dep.importDependency.module.meta && dep.importDependency.module.meta.harmonyModule)) {
content = "/* harmony reexport */ Object.defineProperty(exports, " + JSON.stringify(dep.name) + ", {configurable: false, enumerable: true, get: function() { return " + comment + name + "_default.a; }});";
} else if(dep.name && dep.id) {
content = "/* harmony reexport */ Object.defineProperty(exports, " + JSON.stringify(dep.name) + ", {configurable: false, enumerable: true, get: function() { return " + comment + (name + "[" + JSON.stringify(dep.id) + "]") + "; }});";
Expand Down
2 changes: 1 addition & 1 deletion lib/dependencies/HarmonyImportDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ HarmonyImportDependency.makeStatement = function(declare, dep, outputOptions, re
content = "throw new Error(" + JSON.stringify("Cannot find module \"" + dep.request + "\"") + ");\n";
} else if(dep.importedVar) {
content = "/* harmony import */ " + declaration + dep.importedVar + " = __webpack_require__(" + comment + JSON.stringify(dep.module.id) + ");\n";
if(!dep.module.meta.harmonyModule) {
if(!(dep.module.meta && dep.module.meta.harmonyModule)) {
content += "/* harmony import */ " + declaration + dep.importedVar + "_default = " + dep.importedVar + " && " + dep.importedVar + ".__esModule ? function() { return " + dep.importedVar + "['default'] } : function() { return " + dep.importedVar + "; }\n";
content += "/* harmony import */ Object.defineProperty(" + dep.importedVar + "_default, 'a', { get: " + dep.importedVar + "_default });\n";
}
Expand Down
2 changes: 1 addition & 1 deletion lib/dependencies/HarmonyImportSpecifierDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ HarmonyImportSpecifierDependency.Template = function HarmonyImportSpecifierDepen

HarmonyImportSpecifierDependency.Template.prototype.apply = function(dep, source) {
var content;
if(dep.id === "default" && !dep.importDependency.module.meta.harmonyModule) {
if(dep.id === "default" && !(dep.importDependency.module.meta && dep.importDependency.module.meta.harmonyModule)) {
content = "/* harmony import */ " + dep.importedVar + "_default.a";
} else if(dep.id) {
content = "/* harmony import */ " + dep.importedVar + "[" + JSON.stringify(dep.id) + "]";
Expand Down
5 changes: 5 additions & 0 deletions test/configCases/externals/harmony/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import external from "external";

it("should harmony import a dependency", function() {
external.should.be.eql("abc");
});
5 changes: 5 additions & 0 deletions test/configCases/externals/harmony/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
externals: {
external: "var 'abc'"
}
};

0 comments on commit 987d718

Please sign in to comment.