-
-
Notifications
You must be signed in to change notification settings - Fork 601
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)!: issues with nested objects replacements #903
Conversation
Thanks for the PR. Since this does contain a breaking change (any change in default behavior is breaking, even a bug fix), I would encourage you to bring this up as an issue for discussion first. I'm sure this is perceived as a bug, but there's technically nothing incorrect about the current behavior, because the option exists to customize it. Since we already have a Other maintainers may weigh in on this, but it's my take that we should not merge this change as-is. |
@shellscape I was going to actually report an issue with
|
@shellscape as you requested, created an Issue to discuss this |
Ah thanks, I meant more so for the future. Since this is already open and discussion has commenced, the merits of the change can be discussed here. |
apologies for pinging, could you please let me know whether anyone is expected to be looking at this PR and when? |
c33e948
to
1ae22f4
Compare
Please update from upstream/master. We've made some improvements to repo workflows and we'll need them to run against your PR. |
7b77a7f
to
f9fb656
Compare
@shellscape rebased and force pushed, please let me know, if I should do anything else to speed up the review |
* fix(replace): issues with nested objects replacements * fix(replace): update tests & snapshots
* fix(replace): issues with nested objects replacements * fix(replace): update tests & snapshots
I just stumbled on this PR after noticing the breaking changes myself in the replace plugin - I'd like to highlight that this change in defaults breaks things where you might want to preserve property / method calls on the thing being replaced. For me, for example, I have a lot of things that look like: if (VERSION.startsWith('foo')) {
// things
} ... where I'm replacing I'm aware that all I need to do is change the delimiters I'm using and I'm cool with doing that - but since (as highlighted earlier in this thread) there doesn't seem to have been discussion of the relative merits of different default options, which cases they support and which cases they break - would it be worth opening a discussion to decide the best options here? If so, I'm happy to create a new issue for discussion. But if not, and if my example is much more edge-case than the |
Personally, I believe it's dangerous to replace
In the case above with the previous default to match VERSION when used with a |
Due to this breaking change in the replace plugin: rollup/plugins#903.
Rollup Plugin Name:
@rollup/plugin-replace
This PR contains:
Are tests included?
Breaking Changes?
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
Currently, developers have issues with replacements w/ nested access.
If you attempt to replace
typeof window
with"object"
, you would see the following scenarios:typeof window
will be replacedtypeof window.document
will be replaced, resulting in"object".document
(which is an error)typeof windowSmth
will not be replaced due to a\b
boundaryTherefore, it's important to change the default
delimiters
from:['\b', '\b']
to:
['\b', '\b(?!\.)']