diff --git a/src/ast/nodes/ExportDefaultDeclaration.js b/src/ast/nodes/ExportDefaultDeclaration.js index 716ffcf..ab4a776 100644 --- a/src/ast/nodes/ExportDefaultDeclaration.js +++ b/src/ast/nodes/ExportDefaultDeclaration.js @@ -49,7 +49,7 @@ export default class ExportDefaultDeclaration extends Node { const treeshake = this.module.bundle.treeshake; const name = this.getName( es ); - if ( this.shouldInclude ) { + if ( this.shouldInclude || this.declaration.activated ) { if ( this.activated ) { if ( functionOrClassDeclaration.test( this.declaration.type ) ) { if ( this.declaration.id ) { @@ -76,7 +76,7 @@ export default class ExportDefaultDeclaration extends Node { super.render( code, es ); } else { if ( treeshake ) { - if ( functionOrClassDeclaration.test( this.declaration.type ) && !this.declaration.activated ) { + if ( functionOrClassDeclaration.test( this.declaration.type ) ) { code.remove( this.leadingCommentStart || this.start, this.next || this.end ); } else { const hasEffects = this.declaration.hasEffects( this.module.scope ); diff --git a/test/function/includes-internally-used-default-export/_config.js b/test/function/includes-internally-used-default-export/_config.js new file mode 100644 index 0000000..3eab340 --- /dev/null +++ b/test/function/includes-internally-used-default-export/_config.js @@ -0,0 +1,3 @@ +module.exports = { + description: 'includes default exports that are only used internally' +}; diff --git a/test/function/includes-internally-used-default-export/main.js b/test/function/includes-internally-used-default-export/main.js new file mode 100644 index 0000000..c196b10 --- /dev/null +++ b/test/function/includes-internally-used-default-export/main.js @@ -0,0 +1,3 @@ +import { b } from './module.js'; + +assert.equal(b(), 15); diff --git a/test/function/includes-internally-used-default-export/module.js b/test/function/includes-internally-used-default-export/module.js new file mode 100644 index 0000000..ba2c4ee --- /dev/null +++ b/test/function/includes-internally-used-default-export/module.js @@ -0,0 +1,7 @@ +export default function a() { + return 5; +} + +export function b() { + return a() + 10; +}