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

Refactor assignment handling #1740

Merged
merged 3 commits into from
Nov 19, 2017
Merged

Conversation

lukastaegert
Copy link
Member

This pull requests profoundly improves rollup performance and will probably

It does so by radically simplifying how reassignments are handled.

Previously, reassigning a variable or a member of a variable would store the new assignment together with the variable and check all applicable assignments when determining if an operation on the variable has a relevant effect and should be retained in the bundle. This could lead to an exponential performance degradation in certain scenarios which could cause the impression that "rollup hangs".

Now for each variable we only track which keys have been reassigned. Once a variable or a relevant key is reassigned, we assume we no longer know what is assigned at that key and treat it as such when detecting effects.

This massively improves performance while keeping up the quality of the algorithm in most relevant situations. If you only use assignments inside const variable = … statements (and use object literals to assign object members, e.g. const variable1 = {y: variable2}) the algorithm will be able to track this properly with regard to treeshaking.

@lukastaegert lukastaegert added this to the 0.51.x milestone Nov 18, 2017
@@ -0,0 +1,3 @@
module.exports = {
description: 'does not fail fo cyclic assignments'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/fo/for/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx!

@lukastaegert lukastaegert merged commit 1042217 into master Nov 19, 2017
@lukastaegert lukastaegert deleted the refactor-assignment-handling branch November 19, 2017 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants