Skip to content

Commit ba80387

Browse files
Fix issue webpack#2221 by adding a newline character to generated code
Add a newline prefix to the code generated for non-immutable harmony exports. This resolves a case where export statements without a trailing semicolon would cause webpack to generate a bundle with invalid syntax.
1 parent b0fffd5 commit ba80387

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

lib/dependencies/HarmonyExportSpecifierDependency.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ HarmonyExportSpecifierDependency.Template.prototype.apply = function(dep, source
3939
} else if(dep.immutable) {
4040
content = "/* harmony export */ exports[" + JSON.stringify(used) + "] = " + dep.id + ";";
4141
} else {
42-
content = "/* harmony export */ Object.defineProperty(exports, " + JSON.stringify(used) + ", {configurable: false, enumerable: true, get: function() { return " + dep.id + "; }});";
42+
content = "\n/* harmony export */ Object.defineProperty(exports, " + JSON.stringify(used) + ", {configurable: false, enumerable: true, get: function() { return " + dep.id + "; }});";
4343
}
4444
source.insert(dep.position, content);
4545

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export var foo = "bar"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
it("should compile non-immutable exports with missing semicolons", function(){
2+
require("./exportvar");
3+
});

0 commit comments

Comments
 (0)