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
Correctly associate pure annotations and remove invalid ones #4095
Conversation
cc @kzc |
Thank you for your contribution! ❤️You can try out this pull request locally by installing Rollup via npm install rollup/rollup#correctly-associate-annotations or load it into the REPL: |
Codecov Report
@@ Coverage Diff @@
## master #4095 +/- ##
=======================================
Coverage 98.01% 98.02%
=======================================
Files 201 201
Lines 6994 7029 +35
Branches 2054 2060 +6
=======================================
+ Hits 6855 6890 +35
Misses 66 66
Partials 73 73
Continue to review full report at Codecov.
|
Good stuff. This is difficult to get right. I trust if the results were vetted with terser then it ought to be fine. Should there be pure annotation disagreements between minifiers, use the defacto behavior of With the recent PR on sequences it ought to be easy to support pure annotated calls with side effects in their parameters:
|
Side note... the surprising complexity of correctly associating comments with AST nodes and preserving their intent across various javascript tools is why I strongly discourage extending pure annotations beyond calls and new expressions. Anything can be wrapped in pure IIFEs in the worst case anyway. |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Description
This PR will improve the handling of pure annotations in several respects:
I verified that the implemented behaviour seems to be in line with how terser behaves. This would also resolve discussions from #4068