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

Make the library tree-shakeable #9

Open
YuukanOO opened this issue Aug 19, 2020 · 3 comments
Open

Make the library tree-shakeable #9

YuukanOO opened this issue Aug 19, 2020 · 3 comments
Labels
enhancement New feature or request low energy Represents a task which does not need a lot of energy
Milestone

Comments

@YuukanOO
Copy link
Contributor

By using a bundler to provide 2 entrypoints, one exporting module as esnext and the other as commonjs should make the library tree-shakeable and lighter in certain cases.

@YuukanOO YuukanOO added the enhancement New feature or request label Aug 19, 2020
@YuukanOO YuukanOO added this to the Planned milestone Aug 19, 2020
@Vinnl
Copy link

Vinnl commented Sep 5, 2020

Small tip: just exporting ES modules is not enough to make it tree-shakeable. Bundlers will also need to know for sure that importing such a module does not cause side effects. See here for some docs on how to tell them that: https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free

(A good way to check whether it works is to view your package at https://bundlephobia.com/ and see if it could detect the separate modules.)

@YuukanOO
Copy link
Contributor Author

YuukanOO commented Sep 5, 2020

Thanks @Vinnl ! I've already add the sideEffects: false in the package.json. I'm also using bundlephobia a lot :)

@YuukanOO YuukanOO added the low energy Represents a task which does not need a lot of energy label Sep 7, 2020
@YuukanOO
Copy link
Contributor Author

Hmmm I guess I should distribute this lib as an ES module after all to keep things easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low energy Represents a task which does not need a lot of energy
Projects
None yet
Development

No branches or pull requests

2 participants