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 treat string.replace as side effect when used with a literal #4494

Merged
merged 12 commits into from May 13, 2022

Conversation

lukastaegert
Copy link
Member

@lukastaegert lukastaegert commented May 11, 2022

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 improves side effect detection for String.prototype.replace and String.prototype.replaceAll by not treating them as side effects when used with literals as second argument.

@github-actions
Copy link

@github-actions github-actions bot commented May 11, 2022

Thank you for your contribution! ❤️

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

npm install rollup/rollup#string-replace-side-effects

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

@codecov
Copy link

@codecov codecov bot commented May 11, 2022

Codecov Report

Merging #4494 (5958ade) into master (bbd54b7) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #4494      +/-   ##
==========================================
- Coverage   98.74%   98.74%   -0.01%     
==========================================
  Files         207      207              
  Lines        7343     7342       -1     
  Branches     2082     2081       -1     
==========================================
- Hits         7251     7250       -1     
  Misses         33       33              
  Partials       59       59              
Impacted Files Coverage Δ
src/ast/values.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 bbd54b7...5958ade. Read the comment docs.

@lukastaegert lukastaegert force-pushed the string-replace-side-effects branch from f5aa8ff to c1ff8b3 Compare May 11, 2022
@pschroen
Copy link

@pschroen pschroen commented May 11, 2022

Confirmed to be working locally with rollup/rollup#string-replace-side-effects and my test bundle.

With regards to mrdoob/three.js#24006 it didn't make too much of a difference as many of those declarations are still being used, but in my tests it does remove a little bit more unused code. 🙂

Base automatically changed from function-getter-side-effects to master May 13, 2022
@lukastaegert lukastaegert merged commit 4079fbe into master May 13, 2022
11 of 12 checks passed
@lukastaegert lukastaegert deleted the string-replace-side-effects branch May 13, 2022
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