rollup-plugin-re icon indicating copy to clipboard operation
rollup-plugin-re copied to clipboard

Inconsistent arguments passed to pattern.replace function

Open blikblum opened this issue 6 years ago • 1 comments

When test is a Regex and the pattern.replace is a function, the match array is passed to pattern.replace

When test is a string, the file id is passed to pattern.replace

The former makes sense but not sure about the usefulness of the later.

blikblum avatar May 01 '18 21:05 blikblum

The former makes sense but not sure about the usefulness of the later.

i find that it's useful to get the id in both cases. for instance if i want to replace require("([\w/.-]+).json") with the contents of that file, i need to resolve the path relative to the module id path.

consistency is good, and IMO the id should be the first arg in both cases followed by matches.

ping @jetiny ?

leeoniya avatar Nov 01 '18 16:11 leeoniya