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

Treeshake chained assignment expressions #3919

Merged
merged 1 commit into from Jan 5, 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:

Description

This will allow tree-shaking parts of chained assignment expressions. Example:

// input
let a, b, c, d;
a = b = 1;
c = d = 2;
console.log(a, d);

// output
let a, d;
a = 1;
d = 2;
console.log(a, d);

Special care is taken so that

  • Non-"=" Assignment operators such as "+=" are not tree-shaken
  • Side-effects on the left side are still observed

This will be helpful with some planned updates for the commonjs plugin as it will produce nicer output.

@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#tree-shake-chained-assignments

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

@codecov
Copy link

codecov bot commented Jan 5, 2021

Codecov Report

Merging #3919 (0ce5295) into master (1378cae) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3919   +/-   ##
=======================================
  Coverage   97.08%   97.08%           
=======================================
  Files         187      187           
  Lines        6546     6551    +5     
  Branches     1905     1909    +4     
=======================================
+ Hits         6355     6360    +5     
  Misses        101      101           
  Partials       90       90           
Impacted Files Coverage Δ
src/ast/nodes/AssignmentExpression.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 1378cae...0ce5295. Read the comment docs.

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.

None yet

2 participants