Skip to content

Conversation

@LeeSamFong
Copy link

I hope to add this codes to support friendlier tree-shaking

@sindresorhus
Copy link
Owner

Tree-shaking should work fine even without this. If not, the problem is the bundler you use.

@LeeSamFong
Copy link
Author

LeeSamFong commented Dec 5, 2024

Thank you, sindresorhus, for your reply.

For this, I have provided 2 demos.

Before add export * from "./base.js"

When I try to import the following code, the output generated by Rollup will be over 600 lines of code.
QQ_1733417060906

input: https://github.com/LeeSamFong/query-string/blob/before/test.js
output: https://github.com/LeeSamFong/query-string/blob/before/dist/bundle.js


When I import them separately, the build output will only be around 200 lines of code.
QQ_1733417181667

input: https://github.com/LeeSamFong/query-string/blob/after/test.js
output: https://github.com/LeeSamFong/query-string/blob/after/dist/bundle.js

@LeeSamFong
Copy link
Author

If I have any misunderstandings, can sindresorhus point them out for me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants