plugins icon indicating copy to clipboard operation
plugins copied to clipboard

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

Open yuuk opened this issue 1 year ago • 2 comments

Rollup Plugin Name: plugin-replace

This PR contains:

  • [x] bugfix
  • [ ] feature
  • [ ] refactor
  • [ ] documentation
  • [ ] other

Are tests included?

  • [x] yes (bugfixes and features will not be merged without tests)
  • [ ] no

Breaking Changes?

  • [ ] yes (breaking changes will not be merged unless absolutely necessary)
  • [x] 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 avatar Nov 30 '24 05:11 yuuk

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.

shellscape avatar Dec 15 '24 16:12 shellscape

@yuuk last call before this is closed as abandoned

shellscape avatar Mar 06 '25 15:03 shellscape

Closing as abandoned.

shellscape avatar Jun 17 '25 13:06 shellscape