Skip to content

Commit

Permalink
hoist exports declarations too
Browse files Browse the repository at this point in the history
fixes #3972
  • Loading branch information
sokra committed Jan 16, 2017
1 parent 9796696 commit a44694a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Parser.js
Expand Up @@ -421,6 +421,8 @@ Parser.prototype.walkStatements = function walkStatements(statements) {
Parser.prototype.isHoistedStatement = function isHoistedStatement(statement) {
switch(statement.type) {
case "ImportDeclaration":
case "ExportAllDeclaration":
case "ExportNamedDeclaration":
return true;
}
return false;
Expand Down Expand Up @@ -621,7 +623,7 @@ Parser.prototype.walkExportDefaultDeclaration = function walkExportDefaultDeclar
Parser.prototype.walkExportAllDeclaration = function walkExportAllDeclaration(statement) {
var source = statement.source.value;
this.applyPluginsBailResult("export import", statement, source);
this.applyPluginsBailResult("export import specifier", statement, source, null, null);
this.applyPluginsBailResult("export import specifier", statement, source, null, null, 0);
};

Parser.prototype.walkVariableDeclaration = function walkVariableDeclaration(statement) {
Expand Down
2 changes: 2 additions & 0 deletions test/cases/parsing/harmony-commonjs/e.js
@@ -0,0 +1,2 @@
exports.a = "a";
exports.b = "b";
8 changes: 8 additions & 0 deletions test/cases/parsing/harmony-commonjs/index.js
Expand Up @@ -20,3 +20,11 @@ it("should double reexport from non-harmony modules correctly", function() {
y.should.be.eql("y");
x.should.be.eql("x");
});


import { a, b } from "./reexport"

it("should be possible to reexport a module with unknown exports", function() {
a.should.be.eql("a");
b.should.be.eql("b");
});
2 changes: 2 additions & 0 deletions test/cases/parsing/harmony-commonjs/reexport.js
@@ -0,0 +1,2 @@
export * from "./e";
import "./e";

0 comments on commit a44694a

Please sign in to comment.