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

Only consider Object.freeze a side effect if the argument is used #4720

Merged
merged 1 commit into from Nov 22, 2022

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 change the side effect logic used for Object.freeze to be similar to the logic we currently use for Object.defineProperty: If the argument or return value is used, it is included in the bundle, otherwise it is removed. Also, we assume that the argument is deoptimized, i.e. all properties are treated as "unknown" after being passed to that function.

@github-actions
Copy link

Thank you for your contribution! ❤️

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

npm install rollup/rollup#object-freeze-effects

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

@codecov
Copy link

codecov bot commented Nov 21, 2022

Codecov Report

Merging #4720 (a6ad86c) into master (9a74163) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #4720   +/-   ##
=======================================
  Coverage   99.03%   99.03%           
=======================================
  Files         216      216           
  Lines        7663     7663           
  Branches     2116     2116           
=======================================
  Hits         7589     7589           
  Misses         24       24           
  Partials       50       50           
Impacted Files Coverage Δ
src/ast/nodes/shared/knownGlobals.ts 100.00% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@lukastaegert lukastaegert merged commit 780e342 into master Nov 22, 2022
@lukastaegert lukastaegert deleted the object-freeze-effects branch November 22, 2022 05:13
@rollup-bot
Copy link
Collaborator

This PR has been released as part of rollup@3.4.0. You can test it via npm install rollup.

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