Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/NormalModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,9 @@ NormalModule.prototype.source = function(dependencyTemplates, outputOptions, req

var emitFunction = function emitFunction() {
if(varNames.length === 0) return;

varStartCode += "/* WEBPACK VAR INJECTION */(function(" + varNames.join(", ") + ") {";
// exports === this in the topLevelBlock, but exports do compress better...
varEndCode = (topLevelBlock === block ? "}.call(exports, " : "}.call(this, ") +
varEndCode = (topLevelBlock === block ? "}.call(" + (topLevelBlock.exportsArgument || "exports") + ", " : "}.call(this, ") +
varExpressions.map(function(e) {
return e.source();
}).join(", ") + "))" + varEndCode;
Expand Down
5 changes: 5 additions & 0 deletions test/configCases/parsing/harmony-global/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require("should");
it("should be able to use global in a harmony module", function() {
var x = require("./module1");
(x.default === global).should.be.ok();
});
1 change: 1 addition & 0 deletions test/configCases/parsing/harmony-global/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 1;
3 changes: 3 additions & 0 deletions test/configCases/parsing/harmony-global/module1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var freeGlobal = typeof global === "object" && global && global.Object === Object && global;

export default freeGlobal;
6 changes: 6 additions & 0 deletions test/configCases/parsing/harmony-global/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
target: "web",
performance: {
hints: false
}
};