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

[plugin-replace] @rollup/plugin-replace@5.0.5 doesn't work when ternary operator is used and preventAssigment is true #1619

Open
EAGzzyCSL opened this issue Oct 30, 2023 · 1 comment · May be fixed by #1712

Comments

@EAGzzyCSL
Copy link

  • Rollup Plugin Name: @rollup/plugin-replace
  • Rollup Plugin Version: 3.7.5(unrelated)
  • Rollup Version: 5.0.5(important)
  • Operating System (or Browser): Mac OS(unrelated)
  • Node Version: v18.18.0(unrelated)
  • Link to reproduction (⚠️ read below): https://stackblitz.com/edit/rollup-case-unexpected-replace (run npm build)

Expected Behavior

dist/main.js will be

console.log(Math.random() > 0.5? 123: 456);

Actual Behavior

dist/main.js is

console.log(Math.random() > 0.5? FOO: 456);

Additional Information

  • @rollup/plugin-replace@5.0.4 works
  • the option preventAssigment of @rollup/plugin-replace@5.0.4 should be set true for reproduction
@shellscape
Copy link
Collaborator

@hhgnsc this is a regression from the last PR. (we didn't have a test for this, so it's not your fault no worries)

yyx990803 added a commit to vuejs/core that referenced this issue Feb 5, 2024
5.0.5 introduced a regression that causes replacements in the truthy
branch of ternaries to be skipped: rollup/plugins#1619

This causes the enum replacements to fail and leads to bundle size
regressions.
@smnhgn smnhgn linked a pull request Apr 21, 2024 that will close this issue
9 tasks
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 a pull request may close this issue.

2 participants