Skip to content

Commit

Permalink
Generates namespace objects when not tree-shaking (#4175)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Jul 11, 2021
1 parent 7435d31 commit 076b608
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Module.ts
Expand Up @@ -621,6 +621,7 @@ export default class Module {

includeAllInBundle(): void {
this.ast!.include(createInclusionContext(), true);
this.includeAllExports(false);
}

isIncluded(): boolean {
Expand Down
6 changes: 6 additions & 0 deletions test/form/samples/no-treeshake-namespace-object/_config.js
@@ -0,0 +1,6 @@
module.exports = {
description: 'generates namespace objects when not tree-shaking',
options: {
treeshake: false
}
};
11 changes: 11 additions & 0 deletions test/form/samples/no-treeshake-namespace-object/_expected.js
@@ -0,0 +1,11 @@
function foo() {}

var namespace = /*#__PURE__*/Object.freeze({
__proto__: null,
foo: foo
});

const a = 1;
const b = 2;

export { a, b, namespace as ns1, namespace as ns2 };
8 changes: 8 additions & 0 deletions test/form/samples/no-treeshake-namespace-object/main.js
@@ -0,0 +1,8 @@
import * as ns1 from './namespace';

export { ns1 };

export * as ns2 from './namespace';

export const a = 1;
export const b = 2;
@@ -0,0 +1 @@
export function foo() {}

0 comments on commit 076b608

Please sign in to comment.