Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generates namespace objects when not tree-shaking #4175

Merged
merged 1 commit into from Jul 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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() {}