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

Drop unused last sequence element #4087

Merged
merged 8 commits into from
May 25, 2021

Conversation

lukastaegert
Copy link
Member

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:
Resolves #4083

Description

This will remove the last element in a sequence (comma) expression if the parent is an expression statement and it has no side effects. This is the most simple approach as it will not handle situations where e.g. the expression is nested in a conditional.

A more fully featured way of doing it could be.g. to introduce a flag to the include method to control if the value is needed. Such an extension could also be used to e.g. drop unused return expressions in functions if the return value is unused in all call expressions.

@lukastaegert lukastaegert changed the base branch from master to switch-to-eslint May 23, 2021 19:37
@github-actions
Copy link

github-actions bot commented May 23, 2021

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install rollup/rollup#gh-4083-unused-last-sequence-element

or load it into the REPL:
https://rollupjs.org/repl/?pr=4087

@codecov
Copy link

codecov bot commented May 23, 2021

Codecov Report

Merging #4087 (defb5d5) into master (ebb3ff6) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4087   +/-   ##
=======================================
  Coverage   98.01%   98.01%           
=======================================
  Files         201      201           
  Lines        6987     6992    +5     
  Branches     2051     2053    +2     
=======================================
+ Hits         6848     6853    +5     
  Misses         66       66           
  Partials       73       73           
Impacted Files Coverage Δ
src/ast/nodes/SequenceExpression.ts 89.18% <100.00%> (+1.68%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ebb3ff6...defb5d5. Read the comment docs.

Base automatically changed from switch-to-eslint to master May 25, 2021 10:36
@lukastaegert lukastaegert merged commit 32d1b60 into master May 25, 2021
@lukastaegert lukastaegert deleted the gh-4083-unused-last-sequence-element branch May 25, 2021 10:43
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.

suboptimal tree shaking of sequences
1 participant