Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Does tree shaking works on CommonJS modules? #362

Closed
artall64 opened this issue Dec 12, 2018 · 3 comments
Closed

Does tree shaking works on CommonJS modules? #362

artall64 opened this issue Dec 12, 2018 · 3 comments

Comments

@artall64
Copy link

artall64 commented Dec 12, 2018

I have a lot of Node.js(CommonJS) modules that I want a load with rollup-plugin-commonjs plugin.
Does rollup tree shaking is applied to that modules?
I open an issue because can't find the answer anywhere in the docs.
If no - do you have plans to support that?

You also will be glad to see your comment on that question on StackOverflow

@lukastaegert
Copy link
Member

Yes, usually it is. If the module in question registers its exports by adding properties to exports or module.exports, this plugin usually translates this to named exports which in turn can be tree-shaken individually. If the module directly assigns to module.exports, then exports will probably not be tree-shaken individually. Nevertheless, dependencies of CJS modules that are not used will always be tree-shaken as well.

@shellscape
Copy link
Contributor

Hey folks (this is a canned reply, but we mean it!). Thanks to everyone who participated in this issue. We're getting ready to move this plugin to a new home at https://github.com/rollup/plugins, and we have to do some spring cleaning of the issues to make that happen. We're going to close this one, but it doesn't mean that it's not still valid.

We've got some time yet before the move while we resolve pending Pull Requests, so if this issue is still relevant, please @ me and I'll make sure it gets reopened and transferred to the new repo. 🍺

@eight04
Copy link

eight04 commented Nov 24, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants