You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The replace and replaceAll functions are mimicking the standard method of the string prototype in JS.
If you enter a replacer function on standard JS, and you see some match you don't want to change, you're simply return the original match in the function body.
This strategy allows the replacer function to do a "no-op" replacement.
Today, you might think you can do the same on magic-string, but in the sourcemap I think it will be shown that the substring was changed(e.g. "blabla" was replaced by "blabla"), but this was not the intention.
Can we allow for the replacement function to return sometimes a value of undefined? This way, whenever this value is being returned, magic-string will know not to replace this incident.
It might make sense in some cases to mark a substring as "replaced" in the sourcemap, even though it didn't change at all. This is why I'm not suggesting to check if the replacer return value was different, but rather suggest to check if it was returning undefined.
The text was updated successfully, but these errors were encountered:
The
replace
andreplaceAll
functions are mimicking the standard method of the string prototype in JS.If you enter a replacer function on standard JS, and you see some match you don't want to change, you're simply return the original match in the function body.
This strategy allows the replacer function to do a "no-op" replacement.
Today, you might think you can do the same on magic-string, but in the sourcemap I think it will be shown that the substring was changed(e.g. "blabla" was replaced by "blabla"), but this was not the intention.
Can we allow for the replacement function to return sometimes a value of
undefined
? This way, whenever this value is being returned, magic-string will know not to replace this incident.It might make sense in some cases to mark a substring as "replaced" in the sourcemap, even though it didn't change at all. This is why I'm not suggesting to check if the replacer return value was different, but rather suggest to check if it was returning
undefined
.The text was updated successfully, but these errors were encountered: