Skip to content

Commit

Permalink
Make sure unused default exports are deconflicted when tree-shaking i…
Browse files Browse the repository at this point in the history
…s false (#2758)
  • Loading branch information
lukastaegert committed Mar 20, 2019
1 parent 88ceebd commit 26d2b31
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ast/nodes/ExportDefaultDeclaration.ts
Expand Up @@ -46,6 +46,13 @@ export default class ExportDefaultDeclaration extends NodeBase {
variable: ExportDefaultVariable;
private declarationName: string;

include(includeAllChildrenRecursively: boolean) {
super.include(includeAllChildrenRecursively);
if (includeAllChildrenRecursively) {
this.context.includeVariable(this.variable);
}
}

initialise() {
this.included = false;
this.declarationName =
Expand Down
@@ -0,0 +1,6 @@
module.exports = {
description: 'properly deconflicts default exports when not tree-shaking',
options: {
treeshake: false
}
};
@@ -0,0 +1,7 @@
function foo() {
return 'foo';
}

function foo$1() {
return 'default';
}
7 changes: 7 additions & 0 deletions test/form/samples/no-treeshake-default-export-conflict/foo.js
@@ -0,0 +1,7 @@
export function foo() {
return 'foo';
}

export default function() {
return 'default';
}
@@ -0,0 +1 @@
import './foo';

0 comments on commit 26d2b31

Please sign in to comment.