-
Notifications
You must be signed in to change notification settings - Fork 100
Make powerplug fully treeshakable #104
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
Conversation
The latest a couple of bytes (rollup: 365, webpack: 1356) are just left imports. They can't be treeshaked by default because itself may have side effects. But we may be sure that everything else will not exist if powerplug will be used by unused library.
Oh, it's great! Powerplug diet 😄 |
Ops, I forgot to ask if I could merge. Is there any problem? |
No problem :) |
BTW, what's the magic here? Was the reduction of the bundle just because of |
Yes. It's just treeshaked size reduction. |
Nice! |
I don't quite understand what you mean here, what does "itself" refer to? What side effects does importing from |
I'm also trying to understand how releasing a single file has benefits for tree shaking over releasing the original structure of the js modules. I would have thought the only point to releasing a rollup bundle is in the UMD case where it puts |
Flat bundle gives more control over treeshakability. I just can test it with size-snapshot. Here's proof https://github.com/renatorib/react-powerplug/blob/master/.size-snapshot.json#L17-L23 I meant that rollup doesn't remove external imports because they may have potential side effects. That's why I introduced
|
Having structure introduces one important problem: internal stuff is available for user who can catch breaking change because of using undocumented api. |
The latest a couple of bytes (rollup: 365, webpack: 1356) are just left
imports. They can't be treeshaked by default because itself may have
side effects. But we may be sure that everything else will not exist if
powerplug will be used by unused library.