-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
implement --treeshake.propertyReadSideEffects=always to handle getters with side effects #3985
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3985 +/- ##
=======================================
Coverage 97.21% 97.21%
=======================================
Files 191 191
Lines 6709 6712 +3
Branches 1962 1963 +1
=======================================
+ Hits 6522 6525 +3
Misses 99 99
Partials 88 88
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks a lot. Just one comment regarding the wording.
docs/999-big-list-of-options.md
Outdated
CLI: `--treeshake.propertyReadSideEffects`/`--no-treeshake.propertyReadSideEffects`<br> | ||
Default: `true` | ||
|
||
If `true`, only retain property reads that are determined to be needed. Note: this setting assumes that all getters are side effect free. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is somewhat confusing and also not true, we do not assume all getters are side-effect free. true
means retain property reads that Rollup can resolve to have side-effects.
If `true`, only retain property reads that are determined to be needed. Note: this setting assumes that all getters are side effect free. | |
If `true`, retain unused property reads that Rollup can determine to have side-effects. This includes accessing properties of `null` or `undefined` or triggering explicit getters via property access. Note that this does not cover destructuring assignment or getters on objects passed as function parameters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wording was changed as requested. I struggled to describe this option because of the known getter issues.
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
#2219
#3234
#3974
#3984
Description
Rollup does not correctly handle code dealing with getters with side effects when
treeshake
is enabled (the default setting). To address this shortcoming, this PR adds an'always'
setting totreeshake.propertyReadSideEffects
first proposed in #3234 (comment).