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

Wrap leading function expression iifes in conditionals #4099

Merged
merged 2 commits into from
May 26, 2021

Conversation

lukastaegert
Copy link
Member

@lukastaegert lukastaegert commented May 26, 2021

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 #4092

Description

This will make sure that when a function expression life without parentheses (i.e. function(){}()) is the leading expression in a conditional, logical or binary expression and tree-shaking leads to this being wrapped in an expression statement, then the function expression receives additional parentheses.

REPL

@github-actions
Copy link

github-actions bot commented May 26, 2021

Thank you for your contribution! ❤️

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

npm install rollup/rollup#gh-4092-invalid-iife-conditional

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

@codecov
Copy link

codecov bot commented May 26, 2021

Codecov Report

Merging #4099 (535abc9) into master (ce2592d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4099   +/-   ##
=======================================
  Coverage   98.02%   98.02%           
=======================================
  Files         201      201           
  Lines        7029     7036    +7     
  Branches     2060     2063    +3     
=======================================
+ Hits         6890     6897    +7     
  Misses         66       66           
  Partials       73       73           
Impacted Files Coverage Δ
src/ast/nodes/BinaryExpression.ts 97.50% <100.00%> (+0.27%) ⬆️
src/ast/nodes/ConditionalExpression.ts 100.00% <100.00%> (ø)
src/ast/nodes/LogicalExpression.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 ce2592d...535abc9. Read the comment docs.

@lukastaegert lukastaegert merged commit 438a507 into master May 26, 2021
@lukastaegert lukastaegert deleted the gh-4092-invalid-iife-conditional branch May 26, 2021 07:26
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.

Unused variable optimization leads to SyntaxErrors for IIFE-like function statements
1 participant