Skip to content

Conversation

TrySound
Copy link
Collaborator

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.

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.
@TrySound TrySound requested a review from renatorib May 20, 2018 22:08
@renatorib
Copy link
Owner

Oh, it's great! Powerplug diet 😄

@renatorib renatorib merged commit e4cdd16 into master May 22, 2018
@renatorib renatorib deleted the fully-treeshakable branch May 22, 2018 17:07
@renatorib
Copy link
Owner

Ops, I forgot to ask if I could merge. Is there any problem?

@TrySound
Copy link
Collaborator Author

No problem :)

@renatorib
Copy link
Owner

BTW, what's the magic here? Was the reduction of the bundle just because of static removal?

@TrySound
Copy link
Collaborator Author

Yes. It's just treeshaked size reduction.

@renatorib
Copy link
Owner

Nice!

@jedwards1211
Copy link
Contributor

jedwards1211 commented Jul 23, 2018

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.

I don't quite understand what you mean here, what does "itself" refer to? What side effects does importing from react-powerplug have?

@jedwards1211
Copy link
Contributor

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 ReactPowerPlug on the global scope as a side effect?

@TrySound
Copy link
Collaborator Author

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 import_statements line in size snapshot which shows how big piece of code is just imports.

I don't quite understand what you mean here, what does "itself" refer to? What side effects does importing from react-powerplug have?

@TrySound
Copy link
Collaborator Author

Having structure introduces one important problem: internal stuff is available for user who can catch breaking change because of using undocumented api.

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.

3 participants