Rework treeshaking algorithm - #1582
Merged
Rich-Harris merged 3 commits intoAug 27, 2017
Merged
Conversation
Member
Author
|
Changes without whitespace adjustments: |
This was referenced Aug 25, 2017
Contributor
|
@lukastaegert Nice work! This PR fixes at least a couple of open issue (above). |
Contributor
Member
Author
|
@Rich-Harris Thanks for the kind words 😃. So I hope you merge that one soon so I no longer have to bear the shame of having broken Rollup 😧 |
Contributor
we've all been there 😉 thanks for the speedy fixes — no harm, no foul |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a huge refactoring of several core aspects of rollups tree-shaking algorithm. Before going into implementation details, I will present you some things this pull request fixes or improves by showing you the output of the new/modified tests against the previous implementation (for the actual tests, please look at the code).
New test results
effect-in-for-loop
output with old implementation
output with new implementation
As you can see, this code was completely ignored by the old implementation because the declaration of e was searched for in the scope before it had been added to the scope. This is now handled properly.
nested-tree-shaking
output with old implementation
output with new implementation
side-effects-call-arguments
output with old implementation
output with new implementation
side-effects-delete
output with old implementation
output with new implementation
side-effects-pattern-assignment
output with old implementation
output with new implementation
side-effects-pattern-defaults
output with old implementation
output with new implementation
This is fixed now.
side-effects-reassignment
output with old implementation
output with new implementation
Algorithmic/architecture changes
The main goal was to get rid of custom logic such as isUsedByBundle or assignToForLoopLeft that is hard to maintain and move logic to the individual nodes.
.included
Bundle
Module
Module.includeInBundle() includes each node that .shouldBeIncluded(), see below
Node
By default, Node inclusion works like this:
There are other new methods:
Assignments and Mutations
And more that I can no longer remember :)
I hope you like it, feedback always welcome.