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

Do not partially tree-shake unused declarations in for loops #3943

Merged
merged 1 commit into from Jan 31, 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 #3941

Description

This is a fix for an issue introduced by partial declaration tree-shaking in for-loops. The simple solution here is not to tree-shake declarations in the first argument of a for-loop. A more involved solution would be to always include ids here, but I was not sure if it was worth the effort.

@rollup-bot
Copy link
Collaborator

Thank you for your contribution! ❤️

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

npm install rollup/rollup#gh-3941-unused-for-loop-declaration

or load it into the REPL:
https://rollupjs.org/repl/?circleci=14111

@codecov
Copy link

codecov bot commented Jan 31, 2021

Codecov Report

Merging #3943 (a517adc) into master (363e15d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3943   +/-   ##
=======================================
  Coverage   97.18%   97.18%           
=======================================
  Files         188      188           
  Lines        6681     6684    +3     
  Branches     1944     1946    +2     
=======================================
+ Hits         6493     6496    +3     
  Misses         99       99           
  Partials       89       89           
Impacted Files Coverage Δ
src/ast/nodes/ForStatement.ts 100.00% <100.00%> (ø)
src/ast/nodes/VariableDeclaration.ts 97.97% <100.00%> (+0.02%) ⬆️
src/ast/nodes/VariableDeclarator.ts 100.00% <100.00%> (ø)

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 363e15d...a517adc. Read the comment docs.

@lukastaegert lukastaegert merged commit bc2bf95 into master Jan 31, 2021
@lukastaegert lukastaegert deleted the gh-3941-unused-for-loop-declaration branch January 31, 2021 07:07
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.

Treeshaking introduces stray semi colons which cause the code to break
2 participants