8000 fix: preserve constant identifiers in unary expressions instead of magic numbers by OmkarJ13 · Pull Request #5968 · rollup/rollup · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: preserve constant identifiers in unary expressions instead of magic numbers #5968

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

Merged
merged 5 commits into from
Jun 6, 2025

Conversation

OmkarJ13
Copy link
Contributor
@OmkarJ13 OmkarJ13 commented May 29, 2025

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 was likely a regression after PR feat: enhance the treehshaking for unary expression #5775 which caused unary expressions with constant identifiers (like !MY_CONSTANT) to be inlined with magic numbers (false), losing code readability.
  • Have added logic to check if the unary expression's argument is an identifier referencing an included variable, and if so, preserves the full expression instead of inlining the literal value
  • This helps maintain both the tree-shaking optimization benefits that the original PR added while benefits while preserving readable constant names in the output

Copy link
vercel bot commented May 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rollup ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 4:30am

@OmkarJ13 OmkarJ13 marked this pull request as ready for review May 29, 2025 19:26
Copy link
codecov bot commented Jun 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.77%. Comparing base (8f0dbc9) to head (a99d8f8).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5968   +/-   ##
=======================================
  Coverage   98.77%   98.77%           
=======================================
  Files         270      270           
  Lines        8731     8732    +1     
  Branches     1507     1508    +1     
=======================================
+ Hits         8624     8625    +1     
  Misses         73       73           
  Partials       34       34           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member
@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must admit it really makes a difference for readability.

@lukastaegert lukastaegert enabled auto-merge June 6, 2025 04:29
@lukastaegert lukastaegert added this pull request to the merge queue Jun 6, 2025
Merged via the queue into rollup:master with commit 224c900 Jun 6, 2025
74 of 75 checks passed
Copy link
github-actions bot commented Jun 6, 2025

This PR has been released as part of rollup@4.41.2. 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.

Application constants get replaced with magic number when an operator is used
2 participants
0