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

fix(replace): ignore values option when pass an empty value #1821

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yuuk
Copy link

@yuuk yuuk commented Nov 30, 2024

Rollup Plugin Name: plugin-replace

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

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

Description

The values option is used for separating with other options, but if you passed a empty value, like null, undefine, 0, false may cause a unexpected replacements.

{
    plugins: [
        replace({
            preventAssignment: true,
            values: isDev
                ? undefined // Dot not pass any replacements in dev
                : {
                    "old value": "new value",
                },
        })
    ]
}

@yuuk yuuk requested a review from shellscape as a code owner November 30, 2024 05:19
@shellscape
Copy link
Collaborator

Thanks for the PR. To truly protect and assert against breaking changes, this needs to have a new test (it can be a duplicate with a small change like you've done in the PR) to prove that the existing tests don't break. Please revert your test changes in this PR and add a new test that proves your changes to the values handling.

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.

2 participants