Skip to content

Commit

Permalink
Merge pull request #6889 from Janpot/issue-6867
Browse files Browse the repository at this point in the history
Issue 6867
  • Loading branch information
sokra committed Mar 29, 2018
2 parents 4b6ee73 + fdc4f9f commit 1e7cc39
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Parser.js
Expand Up @@ -1178,7 +1178,11 @@ class Parser extends Tapable {

walkExportDefaultDeclaration(statement) {
this.hooks.export.call(statement);
if (statement.declaration.id) {
if (
statement.declaration.id &&
statement.declaration.type !== "FunctionExpression" &&
statement.declaration.type !== "ClassExpression"
) {
if (
!this.hooks.exportDeclaration.call(statement, statement.declaration)
) {
Expand Down
1 change: 1 addition & 0 deletions test/cases/parsing/issue-6867/a.js
@@ -0,0 +1 @@
export default function() {}
1 change: 1 addition & 0 deletions test/cases/parsing/issue-6867/b.js
@@ -0,0 +1 @@
export default (function() {})
1 change: 1 addition & 0 deletions test/cases/parsing/issue-6867/c.js
@@ -0,0 +1 @@
export default function foo() {}
1 change: 1 addition & 0 deletions test/cases/parsing/issue-6867/d.js
@@ -0,0 +1 @@
export default (function bar() {})
1 change: 1 addition & 0 deletions test/cases/parsing/issue-6867/e.js
@@ -0,0 +1 @@
export default class {}
1 change: 1 addition & 0 deletions test/cases/parsing/issue-6867/f.js
@@ -0,0 +1 @@
export default (class {})
1 change: 1 addition & 0 deletions test/cases/parsing/issue-6867/g.js
@@ -0,0 +1 @@
export default class A {}
1 change: 1 addition & 0 deletions test/cases/parsing/issue-6867/h.js
@@ -0,0 +1 @@
export default (class A {})
57 changes: 57 additions & 0 deletions test/cases/parsing/issue-6867/index.js
@@ -0,0 +1,57 @@
it("should compile default export unnamed function declaration", function() {
return import(/* webpackChunkName: "a" */ "./a")
.then(({ default: a }) => {
a()
});
});


it("should compile default export unnamed function expression", function() {
return import(/* webpackChunkName: "b" */ "./b")
.then(({ default: b }) => {
b()
});
});

it("should compile default export named function declaration", function() {
return import(/* webpackChunkName: "c" */ "./c")
.then(({ default: c }) => {
c()
});
});

it("should compile default export named function expression", function() {
return import(/* webpackChunkName: "d" */ "./d")
.then(({ default: d }) => {
d()
});
});

it("should compile default export unnamed class declaration", function() {
return import(/* webpackChunkName: "e" */ "./e")
.then(({ default: E }) => {
new E()
});
});


it("should compile default export unnamed class expression", function() {
return import(/* webpackChunkName: "f" */ "./f")
.then(({ default: F }) => {
new F()
});
});

it("should compile default export named class declaration", function() {
return import(/* webpackChunkName: "g" */ "./g")
.then(({ default: G }) => {
new G()
});
});

it("should compile default export named class expression", function() {
return import(/* webpackChunkName: "h" */ "./h")
.then(({ default: H }) => {
new H()
});
});

0 comments on commit 1e7cc39

Please sign in to comment.